1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
//! Easy to use ReaScript API.
//!
//! While [reaper-rs](https://github.com/helgoboss/reaper-rs) is
//! full-implemented at low-level, and, partially implemented at medium-level,
//! on top of it (mostly, on top of low-level) this crate builds API that is
//! pleasure to use.
//!
//! Actually, for the moment it is the better version of
//! [Reapy](https://github.com/Levitanus/reapy-boost) project.
//! The main skeleton of this API is cloned from the Reapy, but reimplemented
//! in a more "rusty" way. Also, a bunch of new functions are added to [Track],
//! [Item] and [Take], as well as a good new implementation for [ExtState] and
//! [midi] was made. I would say, that currently wrapped ~95% of Track, Take,
//! Item, [AudioAccessor] and [FX] original functions; about of 70% for
//! [Envelope] and [Source]. And the rest is probably, less, then 50%.
//!
//! It should also be possible to use from VST Plugin, but this has not yet
//! been tested at all.
//!
//! These are the dependencies:
//! ```toml
//! [dependencies]
//! rea-rs = "0.1.2"
//! rea-rs-low = "0.1.2" # optional
//! rea-rs-macros = "0.1.2"
//! ```
//!
//! But, actually, all medium- and low-level functionality is still existing in
//! the [Reaper] object. Just use [Reaper::low], [Reaper::medium] and
//! [Reaper::medium_session].
//!
//! The Common entry point should look like this:
//!
//! ```no_run
//! use rea_rs::{errors::ReaperResult, ActionKind, Reaper, PluginContext};
//! use rea_rs_macros::reaper_extension_plugin;
//! use std::error::Error;
//!
//! #[reaper_extension_plugin]
//! fn plugin_main(context: PluginContext) -> Result<(), Box<dyn Error>> {
//! Reaper::init_global(context);
//! let reaper = Reaper::get_mut();
//! let message = "Hello from small extension";
//! reaper.show_console_msg(message);
//! Ok(())
//! }
//! ```
//!
//! Since, there are not many things to be done at the start time of Reaper,
//! there are two common ways to invoke the code: Actions and [ControlSurface].
//!
//! ```no_run
//! use rea_rs::{PluginContext, Reaper, RegisteredAccel, Timer};
//! use rea_rs_macros::reaper_extension_plugin;
//! use std::error::Error;
//!
//! #[derive(Debug)]
//! struct Listener {
//! action: RegisteredAccel,
//! }
//!
//! // Full list of function larger.
//! impl Timer for Listener {
//! fn run(&mut self) -> Result<(), Box<dyn Error>> {
//! Reaper::get().perform_action(self.action.command_id, 0, None);
//! Ok(())
//! }
//! fn id_string(&self) -> String {"test listener".to_string()}
//! }
//!
//! fn my_action_func(_flag: i32) -> Result<(), Box<dyn Error>> {
//! Reaper::get().show_console_msg("running");
//! Ok(())
//! }
//!
//! #[reaper_extension_plugin]
//! fn plugin_main(context: PluginContext) -> Result<(), Box<dyn Error>> {
//! Reaper::init_global(context);
//! let reaper = Reaper::get_mut();
//!
//! let action = reaper.register_action(
//! // This will be capitalized and used as action ID in action window
//! "command_name",
//! // This is the line user searches action for
//! "description",
//! my_action_func,
//! // Only type currently supported
//! None
//! )?;
//!
//! reaper.register_timer(Box::new(Listener{action}));
//! Ok(())
//! }
//! ```
//!
//! There are float values in API. I recommend to use `float_eq` crate.
//!
//! # API structure.
//!
//! Most of the time, API is used hierarchically: [Reaper] holds top-level
//! functions and can return [Project], [Item] etc. While [Project] can
//! manipulate by [Track], [Item], [Take]. The key point of the hierarchical
//! structure — to be sure safe as long as possible. Since Project is alive, it
//! is safe to refer from track to it. The same with other children. By the
//! same reason, it's almost impossible to mutate two object at a time. If one
//! track is mutable, it responses for the whole underlying objects. And we can
//! be almost sure, that the rest of tracks consist of objects, we left them
//! before.
//!
//! The most part of API is covered by
//! [tests](https://github.com/Levitanus/rea-rs/blob/main/test/test/src/tests.rs),
//! and they are a good set of usage examples.
//!
//! ```no_run
//! use rea_rs::Reaper;
//! use std::collections::HashMap;
//!
//! let rpr = Reaper::get();
//! let captions =
//! vec!["age(18)", "name(user)", "leave blank", "fate(atheist)"];
//! let mut answers = HashMap::new();
//! answers.insert(String::from("age(18)"), String::from("18"));
//! answers.insert(String::from("name(user)"), String::from("user"));
//! answers.insert(String::from("leave blank"), String::from(""));
//! answers.insert(String::from("fate(atheist)"), String::from("atheist"));
//!
//! let result = rpr.get_user_inputs(
//! "Fill values as asked in fields",
//! captions,
//! None,
//! ).unwrap();
//! assert_eq!(result, answers);
//! ```
//!
//! # Better to know about
//!
//! For the moment, downsides of API are:
//! - top-level functionality: I'm not sure, that at least a half of little
//! reaper functions is wrapped. Like all windowing and theming stuff.
//! - GUI. As well as with `reapy`, GUI is an issue. I've started
//! `reaper-imgui` crate, that makes possible to use ReaImGui extension from
//! rust. But it waits for being properly wrapped by `rea-rs`.
//! - Thread-safety. It's important to know, that almost nothing of [Reaper]
//! should left the main thread. There are some functions, that are designed
//! for audio thread, and some, that are safe to execute from any thread.
//! But, basically, here is a rule: if you make a listener, gui or socket
//! communication — `Reaper` lives in main thread, and else made by
//! [std::sync::mpsc].
//!
//! Enjoy the coding!
pub use Duration;
pub use IntEnum;
pub use PluginContext;
pub use *;
pub use *;
pub use *;
pub use *;
pub use WithReaperPtr;
pub use *;
pub use *;
pub use *;
pub use *;
pub use *;
pub use *;
pub use *;
pub use *;
pub use *;
pub use *;
pub use *;
pub use *;
pub use *;
pub use *;