diff --git a/extension/src/lib.rs b/extension/src/lib.rs index 6ea351782..d387e85fe 100644 --- a/extension/src/lib.rs +++ b/extension/src/lib.rs @@ -83,6 +83,16 @@ impl HookCommand for HelgoboxExtension { } fn add_and_show_playtime() -> Result<()> { + // Unwanted scenario + let current_project = Reaper::get().current_project(); + let mut project = current_project.resolve().context("project doesn't exist")?; + let track = project + .tracks() + .next() + .context("project doesn't have tracks")?; + project.delete_track(track); + track.guid(); + let instance_id = Reaper::get() .insert_track_at(0, TrackDefaultsBehavior::OmitDefaultEnvAndFx) .normal_fx_chain() diff --git a/reafluent/src/fx_chain.rs b/reafluent/src/fx_chain.rs index f82d33a82..a5c09a379 100644 --- a/reafluent/src/fx_chain.rs +++ b/reafluent/src/fx_chain.rs @@ -31,7 +31,7 @@ impl FxChainDesc { impl<'a> FxChain<'a> { pub fn add_fx_by_name<'b>( - &self, + &mut self, name: impl Into>, behavior: AddFxBehavior, ) -> Result { diff --git a/reafluent/src/project.rs b/reafluent/src/project.rs index d78c3aec1..6166597ae 100644 --- a/reafluent/src/project.rs +++ b/reafluent/src/project.rs @@ -46,6 +46,12 @@ impl<'a> Project<'a> { self.raw } + pub fn delete_track(&mut self, track: Track) { + unsafe { + Reaper::get().medium_reaper().delete_track(track.raw()); + } + } + pub fn tracks( &self, ) -> impl Iterator> + ExactSizeIterator + FusedIterator + DoubleEndedIterator + '_