From c91dc3d23039cab452b9871e3bc06ba8283a7a66 Mon Sep 17 00:00:00 2001 From: ashley Date: Fri, 25 Aug 2023 12:51:05 -0400 Subject: [PATCH] Implement portamentoup/portamentodown effects --- src/reskit/soundtrack/engines/echo.rs | 40 +++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/src/reskit/soundtrack/engines/echo.rs b/src/reskit/soundtrack/engines/echo.rs index 9a3c923..e9a7c32 100644 --- a/src/reskit/soundtrack/engines/echo.rs +++ b/src/reskit/soundtrack/engines/echo.rs @@ -306,6 +306,44 @@ fn apply_effects_to_channel( channel: &mut Channel, effects: &LinkedHashSet { + let speed = *speed; + + // Remove all prior portamentos (you cannot portamento up and down at the same time) + channel.active_effects = channel.active_effects + .clone() + .into_iter() + .filter( | effect | + !( + matches!( effect, Effect::PortamentoDown { speed: _ } ) || + matches!( effect, Effect::PortamentoUp { speed: _ } ) + ) + ) + .collect(); + + if speed > 0 { + channel.active_effects.insert( Effect::PortamentoUp { speed } ); + } + }, + Effect::PortamentoDown { speed } => { + let speed = *speed; + + // Remove all prior portamentos (you cannot portamento up and down at the same time) + channel.active_effects = channel.active_effects + .clone() + .into_iter() + .filter( | effect | + !( + matches!( effect, Effect::PortamentoDown { speed: _ } ) || + matches!( effect, Effect::PortamentoUp { speed: _ } ) + ) + ) + .collect(); + + if speed > 0 { + channel.active_effects.insert( Effect::PortamentoDown { speed } ); + } + }, Effect::SetPanning { left, right } => { let left = *left; let right = *right; @@ -357,6 +395,8 @@ fn compact_delays( events: Vec ) -> Result, Box