pub struct Reaper {
pub control_surfaces: Vec<Box<dyn ControlSurface>>,
/* private fields */
}
Fields
control_surfaces: Vec<Box<dyn ControlSurface>>
Implementations
sourceimpl Reaper
impl Reaper
sourcepub fn make_available_globally(reaper: Reaper)
pub fn make_available_globally(reaper: Reaper)
Makes the given instance available globally.
After this has been called, the instance can be queried globally using
get()
.
This can be called once only. Subsequent calls won’t have any effect!
pub fn load(context: PluginContext)
pub fn low(&self) -> &Reaper
pub fn medium_session(&self) -> &ReaperSession
pub fn medium_session_mut(&mut self) -> &mut ReaperSession
pub fn medium(&self) -> &Reaper
sourcepub fn get() -> &'static Reaper
pub fn get() -> &'static Reaper
Gives access to the instance which you made available globally before.
Panics
This panics if make_available_globally()
has not been called
before.
pub fn get_mut() -> &'static mut Reaper
pub fn register_action(
&mut self,
command_name: &'static str,
description: &'static str,
operation: impl Fn(i32) -> Result<(), Box<dyn Error>> + 'static,
kind: ActionKind
) -> Result<RegisteredAction, Box<dyn Error>>
sourceimpl Reaper
impl Reaper
sourcepub fn show_console_msg(&self, msg: impl Into<String>)
pub fn show_console_msg(&self, msg: impl Into<String>)
pub fn clear_console(&self)
sourcepub fn perform_action(
&self,
action_id: impl Into<CommandId>,
flag: i32,
project: Option<&Project>
)
pub fn perform_action(
&self,
action_id: impl Into<CommandId>,
flag: i32,
project: Option<&Project>
)
Run action by it’s command id.
Note
It seems, that flag should be always 0. If project is None — will perform on current project.
sourcepub fn current_project(&self) -> Project
pub fn current_project(&self) -> Project
Get project from the current tab.
sourcepub fn add_project_tab(&self, make_current_project: bool) -> Project
pub fn add_project_tab(&self, make_current_project: bool) -> Project
Open new project tab.
To open project in new tab use Reaper::open_project
sourcepub fn open_project(
&self,
file: &Path,
in_new_tab: bool,
make_current_project: bool
) -> Result<Project, &str>
pub fn open_project(
&self,
file: &Path,
in_new_tab: bool,
make_current_project: bool
) -> Result<Project, &str>
Open project from the filename.
sourcepub fn add_reascript(
&self,
file: &Path,
section: Section,
commit: bool
) -> Result<CommandId, Box<dyn Error>>
pub fn add_reascript(
&self,
file: &Path,
section: Section,
commit: bool
) -> Result<CommandId, Box<dyn Error>>
Add reascript from file and put to the action list.
commit must be used in the last call, but it is faster to make it false in a bulk.
sourcepub fn remove_reascript(
&self,
file: &Path,
section: Section,
commit: bool
) -> Result<(), Box<dyn Error>>
pub fn remove_reascript(
&self,
file: &Path,
section: Section,
commit: bool
) -> Result<(), Box<dyn Error>>
Remove reascript.
commit must be used in the last call, but it is faster to make it false in a bulk.
sourcepub fn browse_for_file(
&self,
window_title: impl Into<String>,
extension: impl Into<String>
) -> Result<Box<Path>, Box<dyn Error>>
pub fn browse_for_file(
&self,
window_title: impl Into<String>,
extension: impl Into<String>
) -> Result<Box<Path>, Box<dyn Error>>
Ask user to select a file.
extension — extension for file, e.g. “mp3”, “txt”. Or empty string.
sourcepub fn arm_command(&self, command: CommandId, section: impl Into<String>)
pub fn arm_command(&self, command: CommandId, section: impl Into<String>)
Arm or disarm command.
Original doc
arms a command (or disarms if 0 passed) in section (empty string for main)
pub fn disarm_command(&self)
sourcepub fn armed_command(&self) -> Option<(CommandId, String)>
pub fn armed_command(&self) -> Option<(CommandId, String)>
Get armed command.
If string is empty (len() = 0
), then it’s main section.
sourcepub fn clear_peak_cache(&self)
pub fn clear_peak_cache(&self)
Reset global peak cache.
sourcepub fn get_action_id(&self, action_name: impl Into<String>) -> Option<CommandId>
pub fn get_action_id(&self, action_name: impl Into<String>) -> Option<CommandId>
Get ID for action with the given name.
Note
name is the ID string, that was made, when registered as action, but not the description line.
If action name doesn’t start with underscore, it will be added.
sourcepub fn get_action_name(&self, id: CommandId) -> Option<String>
pub fn get_action_name(&self, id: CommandId) -> Option<String>
Get action name (string ID) of an action with the given ID.
sourcepub fn get_binary_directory(&self) -> String
pub fn get_binary_directory(&self) -> String
Return REAPER bin directory (e.g. “C:\Program Files\REAPER”).
sourcepub fn get_global_automation_mode(&self) -> Option<AutomationMode>
pub fn get_global_automation_mode(&self) -> Option<AutomationMode>
Get globally overrided automation mode.
None if do not overrides.
sourcepub fn set_global_automation_mode(&self, mode: AutomationMode)
pub fn set_global_automation_mode(&self, mode: AutomationMode)
Override global automation mode.
sourcepub fn get_user_inputs<'a>(
&self,
title: impl Into<String>,
captions: Vec<&'a str>,
buf_size: impl Into<Option<usize>>
) -> ReaperResult<HashMap<String, String>>
pub fn get_user_inputs<'a>(
&self,
title: impl Into<String>,
captions: Vec<&'a str>,
buf_size: impl Into<Option<usize>>
) -> ReaperResult<HashMap<String, String>>
sourcepub fn with_prevent_ui_refresh(&self, f: impl Fn())
pub fn with_prevent_ui_refresh(&self, f: impl Fn())
Call function while freezing the UI.
sourcepub fn with_undo_block(
&self,
undo_name: impl Into<String>,
flags: UndoFlags,
project: Option<&Project>,
f: impl FnMut() -> ReaperResult<()>
) -> ReaperResult<()>
pub fn with_undo_block(
&self,
undo_name: impl Into<String>,
flags: UndoFlags,
project: Option<&Project>,
f: impl FnMut() -> ReaperResult<()>
) -> ReaperResult<()>
Call function in undo block with given name.
Note
Probably, it’s better to use UndoFlags.all()
by default.
sourcepub fn show_message_box(
&self,
title: impl Into<String>,
text: impl Into<String>,
box_type: MessageBoxType
) -> ReaperResult<MessageBoxValue>
pub fn show_message_box(
&self,
title: impl Into<String>,
text: impl Into<String>,
box_type: MessageBoxType
) -> ReaperResult<MessageBoxValue>
Show message box to user and get result.
sourcepub fn update_arrange(&self)
pub fn update_arrange(&self)
Redraw the arrange view.
sourcepub fn update_timeline(&self)
pub fn update_timeline(&self)
Redraw timeline.
sourcepub fn view_prefs(
&self,
page: impl Into<Option<u32>>,
name: impl Into<Option<String>>
)
pub fn view_prefs(
&self,
page: impl Into<Option<u32>>,
name: impl Into<Option<String>>
)
Open preferences window.
page should be positive or None.
if not page — then name will be used.
sourcepub fn iter_projects<'a>(&self) -> ProjectIteratorⓘNotable traits for ProjectIteratorimpl Iterator for ProjectIterator type Item = Project;
pub fn iter_projects<'a>(&self) -> ProjectIteratorⓘNotable traits for ProjectIteratorimpl Iterator for ProjectIterator type Item = Project;
Iter through all opened projects.
Warning
This operation, probably, of O(n²) complexity. So, it’s better not to use it in loop or too often.
sourcepub fn validate_ptr<'a>(&self, pointer: impl Into<ReaperPointer<'a>>) -> bool
pub fn validate_ptr<'a>(&self, pointer: impl Into<ReaperPointer<'a>>) -> bool
Checks if the given pointer is still valid.
Returns true if the pointer is a valid object of the correct type in the current project.
sourcepub fn validate_ptr_2<'a>(
&self,
project: &Project,
pointer: impl Into<ReaperPointer<'a>>
) -> bool
pub fn validate_ptr_2<'a>(
&self,
project: &Project,
pointer: impl Into<ReaperPointer<'a>>
) -> bool
Checks if the given pointer is still valid.
Example
use reaper_medium::ProjectContext::CurrentProject;
let track = session.reaper().get_track(CurrentProject, 0)
.ok_or("No track")?;
let track_is_valid = session.reaper()
.validate_ptr_2(CurrentProject, track);
assert!(track_is_valid);
Returns true
if the pointer is a valid object of the
correct type in the given project.
The project is ignored if the pointer itself is a project.
sourceimpl Reaper
impl Reaper
sourcepub fn get_latency(&self) -> (SampleAmount, SampleAmount)
pub fn get_latency(&self) -> (SampleAmount, SampleAmount)
Get latency in samples.
Returns (input, output)
latency.
sourcepub fn get_approximate_samplerate(&self) -> u32
pub fn get_approximate_samplerate(&self) -> u32
Try to evaluate samplerate from the latency parameters.
Not stable, and can be not precise.
sourcepub fn audio_init(&self)
pub fn audio_init(&self)
Open all audio and MIDI devices (if not opened).
sourcepub fn midi_reinit(&self)
pub fn midi_reinit(&self)
Reset all MIDI devices.
sourcepub fn audio_is_pre_buffer(&self) -> bool
pub fn audio_is_pre_buffer(&self) -> bool
Return whether audio is in pre-buffer (thread safe).
sourcepub fn audio_is_running(&self) -> bool
pub fn audio_is_running(&self) -> bool
Return whether audio is running (thread safe).
pub fn get_n_audio_inputs(&self) -> usize
pub fn get_n_audio_outputs(&self) -> usize
pub fn iter_audio_inputs(&self) -> AudioInputsIteratorⓘNotable traits for AudioInputsIteratorimpl Iterator for AudioInputsIterator type Item = HardwareSocket;
pub fn iter_audio_outputs(&self) -> AudioOutputsIteratorⓘNotable traits for AudioOutputsIteratorimpl Iterator for AudioOutputsIterator type Item = HardwareSocket;
pub fn get_max_midi_inputs(&self) -> usize
pub fn get_midi_input(&self, index: usize) -> Option<HardwareSocket>
pub fn get_max_midi_outputs(&self) -> usize
pub fn get_midi_output(&self, index: usize) -> Option<HardwareSocket>
pub fn get_audio_input(&self, index: usize) -> Option<HardwareSocket>
pub fn get_audio_output(&self, index: usize) -> Option<HardwareSocket>
pub fn get_n_midi_inputs(&self) -> usize
pub fn get_n_midi_outputs(&self) -> usize
pub fn iter_midi_inputs(&self) -> MidiInputsIteratorⓘNotable traits for MidiInputsIteratorimpl Iterator for MidiInputsIterator type Item = HardwareSocket;
pub fn iter_midi_outputs(&self) -> MidiOutputsIteratorⓘNotable traits for MidiOutputsIteratorimpl Iterator for MidiOutputsIterator type Item = HardwareSocket;
Trait Implementations
sourceimpl HasExtState for Reaper
impl HasExtState for Reaper
Auto Trait Implementations
impl !RefUnwindSafe for Reaper
impl !Send for Reaper
impl !Sync for Reaper
impl Unpin for Reaper
impl !UnwindSafe for Reaper
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
sourceimpl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
sourcefn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
. Read moresourcefn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
. Read moresourcefn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s. Read moresourcefn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s. Read more