pub struct Project { /* private fields */ }
Implementations
sourceimpl<'a> Project
impl<'a> Project
sourcepub fn new(context: ProjectContext) -> Self
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.
sourcepub fn from_name(name: impl Into<String>) -> ReaperResult<Self>
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.
sourcepub fn context(&self) -> ProjectContext
pub fn context(&self) -> ProjectContext
Get reaper_medium::ProjectContext to use with
rea-rs
crates.
sourcepub fn make_current_project(&self)
pub fn make_current_project(&self)
Activate project tab with the project.
sourcepub fn is_current_project(&self) -> bool
pub fn is_current_project(&self) -> bool
If the project tab is active.
pub fn with_current_project(
&self,
f: impl FnMut() -> ReaperResult<()>
) -> ReaperResult<()>
sourcepub fn mark_dirty(&mut self)
pub fn mark_dirty(&mut self)
Mark project dirty (i.e. needing save).
pub fn is_paused(&self) -> bool
pub fn is_playing(&self) -> bool
pub fn is_recording(&self) -> bool
pub fn is_stopped(&self) -> bool
pub fn length(&self) -> Duration
pub fn get_time_range(&'a mut self, kind: TimeRangeKind) -> TimeRange<'a>
pub fn get_loop_selection(&'a mut self) -> TimeRange<'a>
pub fn get_time_selection(&'a mut self) -> TimeRange<'a>
pub fn is_loop_enabled(&self) -> bool
pub fn set_loop_enabled(&mut self, should_loop: bool)
sourcepub fn time_signature_at_position(
&self,
position: Position
) -> (TimeSignature, f64)
pub fn time_signature_at_position(
&self,
position: Position
) -> (TimeSignature, f64)
Get time signature and tempo (BPM) at given position.
sourcepub 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>
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.
sourcepub 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>
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.
sourcepub fn set_marker_or_region(
&mut self,
info: MarkerRegionInfo
) -> ReaperResult<()>
pub fn set_marker_or_region(
&mut self,
info: MarkerRegionInfo
) -> ReaperResult<()>
Set marker or region from info.
pub fn delete_marker(&mut self, user_index: usize) -> ReaperResult<()>
pub fn delete_region(&mut self, user_index: usize) -> ReaperResult<()>
sourcepub fn iter_markers_and_regions(&self) -> MarkerRegionIterator<'_>ⓘNotable traits for MarkerRegionIterator<'a>impl<'a> Iterator for MarkerRegionIterator<'a> type Item = MarkerRegionInfo;
pub fn iter_markers_and_regions(&self) -> MarkerRegionIterator<'_>ⓘNotable traits for MarkerRegionIterator<'a>impl<'a> Iterator for MarkerRegionIterator<'a> type Item = MarkerRegionInfo;
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
);
pub fn n_tracks(&self) -> usize
pub fn n_selected_tracks(&self) -> usize
pub fn n_items(&self) -> usize
pub fn n_selected_items(&self) -> usize
pub fn n_tempo_markers(&self) -> usize
pub fn n_markers(&self) -> usize
pub fn n_regions(&self) -> usize
pub fn add_track(
&mut self,
index: impl Into<Option<usize>>,
name: impl Into<String>
) -> Track<'_, Mutable>
pub fn get_track(&self, index: usize) -> Option<Track<'_, Immutable>>
pub fn get_track_mut(&mut self, index: usize) -> Option<Track<'_, Mutable>>
pub fn get_selected_track(&self, index: usize) -> Option<Track<'_, Immutable>>
pub fn get_selected_track_mut(
&mut self,
index: usize
) -> Option<Track<'_, Mutable>>
pub fn get_master_track(&self) -> Track<'_, Immutable>
pub fn get_master_track_mut(&mut self) -> Track<'_, Mutable>
pub fn iter_tracks(&self) -> TracksIterator<'_>ⓘNotable traits for TracksIterator<'a>impl<'a> Iterator for TracksIterator<'a> type Item = Track<'a, Immutable>;
pub fn iter_tracks_mut(
&mut self,
f: impl FnMut(Track<'_, Mutable>) -> ReaperResult<()>
) -> ReaperResult<()>
pub fn iter_selected_tracks(&self) -> SelectedTracksIterator<'_>ⓘNotable traits for SelectedTracksIterator<'a>impl<'a> Iterator for SelectedTracksIterator<'a> type Item = Track<'a, Immutable>;
pub fn iter_selected_tracks_mut(
&mut self,
f: impl FnMut(Track<'_, Mutable>) -> ReaperResult<()>
) -> ReaperResult<()>
pub fn iter_items(&'a self) -> ItemsIterator<'a>ⓘNotable traits for ItemsIterator<'a>impl<'a> Iterator for ItemsIterator<'a> type Item = Item<'a, Immutable>;
pub fn iter_selected_items(&'a self) -> SelectedItemsIterator<'a>ⓘNotable traits for SelectedItemsIterator<'a>impl<'a> Iterator for SelectedItemsIterator<'a> type Item = Item<'a, Immutable>;
pub fn get_item(&self, index: usize) -> Option<Item<'_, Immutable>>
pub fn get_item_mut(&mut self, index: usize) -> Option<Item<'_, Mutable>>
pub fn get_selected_item(&self, index: usize) -> Option<Item<'_, Immutable>>
sourcepub fn glue_selected_items(&mut self, within_time_selection: bool)
pub fn glue_selected_items(&mut self, within_time_selection: bool)
Glue items (action shortcut).
pub fn any_track_solo(&self) -> bool
sourcepub fn begin_undo_block(&mut self)
pub fn begin_undo_block(&mut self)
sourcepub fn end_undo_block(&mut self, name: impl Into<String>, flags: UndoFlags)
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.
sourcepub fn with_undo_block(
&mut self,
undo_name: impl Into<String>,
flags: UndoFlags,
f: impl FnMut() -> ReaperResult<()>
) -> ReaperResult<()>
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.
sourcepub fn undo(&mut self) -> Result<(), ReaperError>
pub fn undo(&mut self) -> Result<(), ReaperError>
Try to undo last action.
sourcepub fn redo(&mut self) -> Result<(), ReaperError>
pub fn redo(&mut self) -> Result<(), ReaperError>
Try to redo last undone action.
sourcepub fn next_buffer_position(&self) -> Position
pub fn next_buffer_position(&self) -> Position
Position of next audio block being processed.
sourcepub fn play_position(&self) -> Position
pub fn play_position(&self) -> Position
Latency-compensated actual-what-you-hear position.
sourcepub fn bypass_fx_on_all_tracks(&mut self, bypass: bool)
pub fn bypass_fx_on_all_tracks(&mut self, bypass: bool)
Bypass (true
) or un-bypass (false
) FX on all tracks.
sourcepub fn next_redo(&self) -> Option<String>
pub fn next_redo(&self) -> Option<String>
Get the name of the next action in redo queue, if any.
sourcepub fn next_undo(&self) -> Option<String>
pub fn next_undo(&self) -> Option<String>
Get the name of the next action in undo queue, if any.
sourcepub fn get_cursor_position(&self) -> Position
pub fn get_cursor_position(&self) -> Position
Edit cursor position.
sourcepub fn set_cursor_position(
&mut self,
position: Position,
move_view: bool,
seek_play: bool
)
pub fn set_cursor_position(
&mut self,
position: Position,
move_view: bool,
seek_play: bool
)
Set edit cursor position.
sourcepub fn disarm_rec_on_all_tracks(&mut self)
pub fn disarm_rec_on_all_tracks(&mut self)
Disarm record on all tracks.
sourcepub fn focused_fx(&self) -> Option<FocusedFxResult>
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.
sourcepub fn set_string_param_size(&mut self, size: usize)
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,
};
pub fn name(&self) -> String
sourcepub fn get_title(&self) -> ReaperResult<String>
pub fn get_title(&self) -> ReaperResult<String>
title field from Project Settings/Notes dialog
sourcepub fn set_title(&mut self, title: impl Into<String>) -> ReaperResult<()>
pub fn set_title(&mut self, title: impl Into<String>) -> ReaperResult<()>
title field from Project Settings/Notes dialog
author field from Project Settings/Notes dialog
author field from Project Settings/Notes dialog
pub fn get_marker_guid(&self, marker_index: usize) -> ReaperResult<String>
pub fn get_track_group_name(&self, group_index: usize) -> ReaperResult<String>
pub fn set_track_group_name(
&mut self,
group_index: usize,
track_group_name: impl Into<String>
) -> ReaperResult<()>
pub fn get_record_path(&self, secondary_path: bool) -> ReaperResult<PathBuf>
sourcepub fn get_path(&self) -> ReaperResult<PathBuf>
pub fn get_path(&self) -> ReaperResult<PathBuf>
Project path.
pub fn set_record_path(
&mut self,
secondary_path: bool,
directory: impl Into<PathBuf>
) -> ReaperResult<()>
pub fn get_render_directory(&self) -> ReaperResult<PathBuf>
pub fn set_render_directory(
&mut self,
directory: impl Into<PathBuf>
) -> ReaperResult<()>
sourcepub fn get_render_file(&self) -> ReaperResult<String>
pub fn get_render_file(&self) -> ReaperResult<String>
render file name (may contain wildcards)
sourcepub fn set_render_file(&mut self, file: impl Into<String>) -> ReaperResult<()>
pub fn set_render_file(&mut self, file: impl Into<String>) -> ReaperResult<()>
render file name (may contain wildcards)
sourcepub fn get_render_format(&self, secondary_format: bool) -> ReaperResult<String>
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.
sourcepub fn set_render_format(
&mut self,
format: impl Into<String>,
secondary_format: bool
) -> ReaperResult<()>
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”
sourcepub fn get_render_targets(&self) -> ReaperResult<Vec<String>>
pub fn get_render_targets(&self) -> ReaperResult<Vec<String>>
Filenames, that will be rendered.
sourcepub fn get_play_rate(&self, position: impl Into<Position>) -> PlayRate
pub fn get_play_rate(&self, position: impl Into<Position>) -> PlayRate
Will return PlayRate::from(1.0)
in normal conditions.
pub fn save(&mut self, force_save_as: bool)
pub fn select_all_items(&mut self, should_select: bool)
pub fn select_all_tracks(&mut self, should_select: bool)
pub fn solo_all_tracks(&mut self, solo: bool)
pub fn mute_all_tracks(&mut self, mute: bool)
pub fn clear_all_rec_armed_tracks(&mut self)
pub fn get_render_bounds_mode(&self) -> BoundsMode
pub fn set_render_bounds_mode(&mut self, mode: BoundsMode)
pub fn get_render_settings(&self) -> RenderSettings
pub fn set_render_settings(&mut self, settings: RenderSettings)
pub fn get_render_channels_amount(&self) -> u32
pub fn set_render_channels_amount(&mut self, channels_amount: u32)
sourcepub fn set_srate(&mut self, srate: impl Into<Option<u32>>)
pub fn set_srate(&mut self, srate: impl Into<Option<u32>>)
If None — then sample rate from Reaper settings used.
sourcepub fn get_render_srate(&self) -> Option<u32>
pub fn get_render_srate(&self) -> Option<u32>
If None — then project sample rate used.
sourcepub fn set_render_srate(&mut self, srate: impl Into<Option<u32>>)
pub fn set_render_srate(&mut self, srate: impl Into<Option<u32>>)
If None — then project sample rate used.
sourcepub fn get_render_bounds(&self) -> (Position, Position)
pub fn get_render_bounds(&self) -> (Position, Position)
Get in tuple (start, end)
Valid only when Project::get_render_bounds_mode is BoundsMode::Custom
sourcepub fn set_render_bounds(
&mut self,
start: impl Into<Position>,
end: impl Into<Position>
)
pub fn set_render_bounds(
&mut self,
start: impl Into<Position>,
end: impl Into<Position>
)
Valid only when Project::get_render_bounds_mode is BoundsMode::Custom
pub fn get_render_tail(&self) -> RenderTail
pub fn set_render_tail(&mut self, render_tail: RenderTail)
Trait Implementations
sourceimpl HasExtState for Project
impl HasExtState for Project
sourceimpl<'a> WithReaperPtr<'a> for Project
impl<'a> WithReaperPtr<'a> for Project
type Ptr = NonNull<ReaProject>
sourcefn get_pointer(&self) -> Self::Ptr
fn get_pointer(&self) -> Self::Ptr
sourcefn make_unchecked(&mut self)
fn make_unchecked(&mut self)
sourcefn make_checked(&mut self)
fn make_checked(&mut self)
sourcefn should_check(&self) -> bool
fn should_check(&self) -> bool
sourcefn require_valid(&self) -> ReaperResult<()>
fn require_valid(&self) -> ReaperResult<()>
sourcefn require_valid_2(&self, project: &Project) -> ReaperResult<()>
fn require_valid_2(&self, project: &Project) -> ReaperResult<()>
sourcefn with_valid_ptr(
&mut self,
f: impl FnMut(&mut Self) -> ReaperResult<()>
) -> ReaperResult<()>
fn with_valid_ptr(
&mut self,
f: impl FnMut(&mut Self) -> ReaperResult<()>
) -> ReaperResult<()>
impl StructuralPartialEq for Project
Auto Trait Implementations
impl RefUnwindSafe for Project
impl Send for Project
impl !Sync for Project
impl Unpin for Project
impl UnwindSafe for Project
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