Struct Project

Source
pub struct Project { /* private fields */ }

Implementations§

Source§

impl<'a> Project

Source

pub fn new(context: ProjectContext) -> Self

New object from the project context.

It will never hold pseudo-context of CURRENT_PROJECT, but hold real pointer. So, for example, project, returned from Reaper::current_project will not always remain the project in the active project tab, if the tab changes.

§Note

It is better to get all opened projects in once by Reaper::iter_projects.

Source

pub fn from_name(name: impl Into<String>) -> ReaperResult<Self>

Get opened project with a given name, if any.

§Note

This operation, probably, of O(n³) complexity in the worst case, do not use a lot.

Source

pub fn context(&self) -> ProjectContext

Get [reaper_medium::ProjectContext] to use with rea-rs crates.

Source

pub fn make_current_project(&self)

Activate project tab with the project.

Source

pub fn is_current_project(&self) -> bool

If the project tab is active.

Source

pub fn with_current_project( &self, f: impl FnMut() -> ReaperResult<()>, ) -> ReaperResult<()>

Source

pub fn is_dirty(&self) -> bool

Whether project is dirty (i.e. needing save).

Source

pub fn mark_dirty(&mut self)

Mark project dirty (i.e. needing save).

Source

pub fn pause(&mut self)

Direct way to simulate pause button hit.

Source

pub fn is_paused(&self) -> bool

Source

pub fn play(&mut self)

Direct way to simulate play button hit.

Source

pub fn is_playing(&self) -> bool

Source

pub fn record(&mut self)

Hit record button.

§Note

This is sugar on top of the cation invocation.

Source

pub fn is_recording(&self) -> bool

Source

pub fn stop(&mut self)

Direct way to simulate stop button hit.

Source

pub fn is_stopped(&self) -> bool

Source

pub fn length(&self) -> Duration

Source

pub fn get_time_range(&'a self, kind: TimeRangeKind) -> TimeRange<'a>

Source

pub fn get_loop_selection(&'a self) -> TimeRange<'a>

Source

pub fn get_time_selection(&'a self) -> TimeRange<'a>

Source

pub fn is_loop_enabled(&self) -> bool

Source

pub fn set_loop_enabled(&mut self, should_loop: bool)

Source

pub fn close(self)

Close the project.

Source

pub fn time_signature_at_position( &self, position: Position, ) -> (TimeSignature, f64)

Get time signature and tempo (BPM) at given position.

Source

pub fn add_marker( &mut self, position: Position, name: Option<impl Into<String>>, color: impl Into<Option<Color>>, desired_index: impl Into<Option<usize>>, ) -> ReaperResult<usize>

Create new marker and return its index.

Return ReaperError::Unexpected if reaper can’t add marker.

If it is possible, the index will be the same as desired, but if it is busy, new index will be returned.

If a marker with the same position and name exists, no new marker will be created, and existing index will be returned.

index is not an enum index, but user-index.

Source

pub fn add_region( &mut self, start: Position, end: Position, name: Option<impl Into<String>>, color: impl Into<Option<Color>>, desired_index: impl Into<Option<usize>>, ) -> ReaperResult<usize>

Create new region and return its index.

Return ReaperError::Unexpected if reaper can’t add marker.

If it is possible, the index will be the same as desired, but if it is busy, new index will be returned.

If a marker with the same position and name exists, no new marker will be created, and existing index will be returned.

index is not an enum index, but user-index.

Source

pub fn set_marker_or_region( &mut self, info: MarkerRegionInfo, ) -> ReaperResult<()>

Set marker or region from info.

Source

pub fn delete_marker(&mut self, user_index: usize) -> ReaperResult<()>

Source

pub fn delete_region(&mut self, user_index: usize) -> ReaperResult<()>

Source

pub fn iter_markers_and_regions(&self) -> MarkerRegionIterator<'_>

Get iterator through all project markers and regions.

Since markers and regions are messed up in indexes and API, it’s better to work with them through iteration.

§Example
let project = Project::new(ProjectContext::CurrentProject);
assert_eq!(
    project
    .iter_markers_and_regions()
    .find(|info| !info.is_region && info.user_index == 2)
    .unwrap()
    .position
    .as_duration()
    .as_secs_f64(),
4.0
);
Source

pub fn n_tracks(&self) -> usize

Source

pub fn n_selected_tracks(&self) -> usize

Source

pub fn n_items(&self) -> usize

Source

pub fn n_selected_items(&self) -> usize

Source

pub fn n_tempo_markers(&self) -> usize

Source

pub fn n_markers(&self) -> usize

Source

pub fn n_regions(&self) -> usize

Source

pub fn add_track( &mut self, index: impl Into<Option<usize>>, name: impl Into<String>, ) -> Track<'_, Mutable>

Source

pub fn get_track(&self, index: usize) -> Option<Track<'_, Immutable>>

Source

pub fn get_track_mut(&mut self, index: usize) -> Option<Track<'_, Mutable>>

Source

pub fn get_selected_track(&self, index: usize) -> Option<Track<'_, Immutable>>

Source

pub fn get_selected_track_mut( &mut self, index: usize, ) -> Option<Track<'_, Mutable>>

Source

pub fn get_master_track(&self) -> Track<'_, Immutable>

Source

pub fn get_master_track_mut(&mut self) -> Track<'_, Mutable>

Source

pub fn iter_tracks(&self) -> TracksIterator<'_>

Source

pub fn iter_tracks_mut( &mut self, f: impl FnMut(Track<'_, Mutable>) -> ReaperResult<()>, ) -> ReaperResult<()>

Source

pub fn iter_selected_tracks(&self) -> SelectedTracksIterator<'_>

Source

pub fn iter_selected_tracks_mut( &mut self, f: impl FnMut(Track<'_, Mutable>) -> ReaperResult<()>, ) -> ReaperResult<()>

Source

pub fn iter_items(&'a self) -> ItemsIterator<'a>

Source

pub fn iter_selected_items(&'a self) -> SelectedItemsIterator<'a>

Source

pub fn get_item(&self, index: usize) -> Option<Item<'_, Immutable>>

Source

pub fn get_item_mut(&mut self, index: usize) -> Option<Item<'_, Mutable>>

Source

pub fn get_selected_item(&self, index: usize) -> Option<Item<'_, Immutable>>

Source

pub fn get_selected_item_mut( &mut self, index: usize, ) -> Option<Item<'_, Mutable>>

Source

pub fn glue_selected_items(&mut self, within_time_selection: bool)

Glue items (action shortcut).

Source

pub fn any_track_solo(&self) -> bool

Source

pub fn begin_undo_block(&mut self)

Verbose way to make undo.

§Safety

Project::end_undo_block has to be called after.

Source

pub fn end_undo_block(&mut self, name: impl Into<String>, flags: UndoFlags)

Verbose way to make undo: name is the name shown in undo list.

§Safety

Project::begin_undo_block has to be called before.

Source

pub fn with_undo_block( &mut self, undo_name: impl Into<String>, flags: UndoFlags, f: impl FnMut() -> ReaperResult<()>, ) -> ReaperResult<()>

Call function in undo block with given name.

§Note

Probably, it’s better to use UndoFlags.all() by default.

Source

pub fn undo(&mut self) -> Result<(), ReaperError>

Try to undo last action.

Source

pub fn redo(&mut self) -> Result<(), ReaperError>

Try to redo last undone action.

Source

pub fn next_buffer_position(&self) -> Position

Position of next audio block being processed.

Project::play_position

Source

pub fn play_position(&self) -> Position

Latency-compensated actual-what-you-hear position.

Project::next_buffer_position

Source

pub fn bypass_fx_on_all_tracks(&mut self, bypass: bool)

Bypass (true) or un-bypass (false) FX on all tracks.

Source

pub fn next_redo(&self) -> Option<String>

Get the name of the next action in redo queue, if any.

Source

pub fn next_undo(&self) -> Option<String>

Get the name of the next action in undo queue, if any.

Source

pub fn get_cursor_position(&self) -> Position

Edit cursor position.

Source

pub fn set_cursor_position( &mut self, position: Position, move_view: bool, seek_play: bool, )

Set edit cursor position.

Source

pub fn disarm_rec_on_all_tracks(&mut self)

Disarm record on all tracks.

Source

pub fn focused_fx(&self) -> Option<FocusedFxResult>

Check if there is any FX window in focus.

Returns enough data for getting Fx by yourself, as it will be easier, than conquer borrow checker or force you to pass closure inside.

FocusedFxResult

Source

pub fn set_string_param_size(&mut self, size: usize)

Overwrite default size of string buffer, used to set and get string values:

Project::get_info_string Project::set_info_string

§Example
use rea_rs::{Reaper, Project};
let mut pr = Reaper::get().current_project();
let directory = match pr.get_render_directory(){
    Err(_) => {
                pr.set_string_param_size(2048);
                pr.get_render_directory()
                    .expect("another reason of error")
            },
    Ok(dir) => dir,
};
Source

pub fn name(&self) -> String

Source

pub fn get_title(&self) -> ReaperResult<String>

title field from Project Settings/Notes dialog

Source

pub fn set_title(&mut self, title: impl Into<String>) -> ReaperResult<()>

title field from Project Settings/Notes dialog

Source

pub fn get_author(&self) -> ReaperResult<String>

author field from Project Settings/Notes dialog

Source

pub fn set_author(&mut self, author: impl Into<String>) -> ReaperResult<()>

author field from Project Settings/Notes dialog

Source

pub fn get_marker_guid(&self, marker_index: usize) -> ReaperResult<String>

Source

pub fn get_track_group_name(&self, group_index: usize) -> ReaperResult<String>

Source

pub fn set_track_group_name( &mut self, group_index: usize, track_group_name: impl Into<String>, ) -> ReaperResult<()>

Source

pub fn get_record_path(&self, secondary_path: bool) -> ReaperResult<PathBuf>

Source

pub fn get_path(&self) -> ReaperResult<PathBuf>

Project path.

Source

pub fn set_record_path( &mut self, secondary_path: bool, directory: impl Into<PathBuf>, ) -> ReaperResult<()>

Source

pub fn get_render_directory(&self) -> ReaperResult<PathBuf>

Source

pub fn set_render_directory( &mut self, directory: impl Into<PathBuf>, ) -> ReaperResult<()>

Source

pub fn get_render_file(&self) -> ReaperResult<String>

render file name (may contain wildcards)

Source

pub fn set_render_file(&mut self, file: impl Into<String>) -> ReaperResult<()>

render file name (may contain wildcards)

Source

pub fn get_render_format(&self, secondary_format: bool) -> ReaperResult<String>

base64-encoded sink configuration (see project files, etc).

Set secondary_format to true, if you want the secondary render section format.

Source

pub fn set_render_format( &mut self, format: impl Into<String>, secondary_format: bool, ) -> ReaperResult<()>

base64-encoded secondary sink configuration.

Set secondary_format to true, if you want the secondary render section format.

Callers can also pass a simple 4-byte string (non-base64-encoded), e.g. “evaw” or “l3pm”, to use default settings for that sink type.

§Typical formats

“wave” “aiff” “caff” “iso “ “ddp “ “flac” “mp3l” “oggv” “OggS”

Source

pub fn get_render_targets(&self) -> ReaperResult<Vec<String>>

Filenames, that will be rendered.

Source

pub fn get_play_rate(&self, position: impl Into<Position>) -> PlayRate

Will return PlayRate::from(1.0) in normal conditions.

Source

pub fn save(&mut self, force_save_as: bool)

Source

pub fn select_all_items(&mut self, should_select: bool)

Source

pub fn select_all_tracks(&mut self, should_select: bool)

Source

pub fn solo_all_tracks(&mut self, solo: bool)

Source

pub fn mute_all_tracks(&mut self, mute: bool)

Source

pub fn clear_all_rec_armed_tracks(&mut self)

Source

pub fn get_render_bounds_mode(&self) -> BoundsMode

Source

pub fn set_render_bounds_mode(&mut self, mode: BoundsMode)

Source

pub fn get_render_settings(&self) -> RenderSettings

Source

pub fn set_render_settings(&mut self, settings: RenderSettings)

Source

pub fn get_render_channels_amount(&self) -> u32

Source

pub fn set_render_channels_amount(&mut self, channels_amount: u32)

Source

pub fn get_srate(&self) -> Option<u32>

If None — then sample rate from Reaper settings used.

Source

pub fn set_srate(&mut self, srate: impl Into<Option<u32>>)

If None — then sample rate from Reaper settings used.

Source

pub fn get_render_srate(&self) -> Option<u32>

If None — then project sample rate used.

Source

pub fn set_render_srate(&mut self, srate: impl Into<Option<u32>>)

If None — then project sample rate used.

Source

pub fn get_render_bounds(&self) -> (Position, Position)

Get in tuple (start, end)

Valid only when Project::get_render_bounds_mode is BoundsMode::Custom

Source

pub fn set_render_bounds( &mut self, start: impl Into<Position>, end: impl Into<Position>, )

Source

pub fn get_render_tail(&self) -> RenderTail

Source

pub fn set_render_tail(&mut self, render_tail: RenderTail)

Trait Implementations§

Source§

impl Debug for Project

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl HasExtState for Project

Source§

fn set_ext_value(&self, section: &CStr, key: &CStr, value: *mut i8)

Source§

fn get_ext_value( &self, section: &CStr, key: &CStr, buf_size: usize, ) -> Option<CString>

Source§

fn delete_ext_value(&self, section: &CStr, key: &CStr)

Source§

impl PartialEq for Project

Source§

fn eq(&self, other: &Project) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'a> WithReaperPtr for Project

Source§

type Ptr = NonNull<ReaProject>

Source§

fn get_pointer(&self) -> Self::Ptr

Get underlying ReaperPointer.
Source§

fn get(&self) -> Self::Ptr

Get underlying ReaperPointer with validity check.
Source§

fn make_unchecked(&mut self)

Turn validity checks off.
Source§

fn make_checked(&mut self)

Turn validity checks on.
Source§

fn should_check(&self) -> bool

State of validity checks.
Source§

fn require_valid(&self) -> ReaperResult<()>

Return ReaperError::NullPtr if check failed. Read more
Source§

fn require_valid_2(&self, project: &Project) -> ReaperResult<()>

Return ReaperError::NullPtr if check failed. Read more
Source§

fn with_valid_ptr( &mut self, f: impl FnMut(&mut Self) -> ReaperResult<()>, ) -> ReaperResult<()>

Perform function with only one validity check. Read more
Source§

impl StructuralPartialEq for Project

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert 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.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.