From 2e0f89978ab82b71682313699b319e4815a489dc Mon Sep 17 00:00:00 2001 From: Gwilym Inzani Date: Wed, 15 May 2024 22:30:13 +0100 Subject: [PATCH] Add note delay support (effect EDx) --- tracker/agb-tracker-interop/src/lib.rs | 2 ++ tracker/agb-tracker/src/lib.rs | 9 +++++++++ tracker/agb-xm-core/src/lib.rs | 1 + 3 files changed, 12 insertions(+) diff --git a/tracker/agb-tracker-interop/src/lib.rs b/tracker/agb-tracker-interop/src/lib.rs index d0eb1aac..e9ccebc0 100644 --- a/tracker/agb-tracker-interop/src/lib.rs +++ b/tracker/agb-tracker-interop/src/lib.rs @@ -62,6 +62,7 @@ pub enum PatternEffect { VolumeSlide(Num), FineVolumeSlide(Num), NoteCut(u32), + NoteDelay(u32), Portamento(Num), /// Slide each tick the first amount to at most the second amount TonePortamento(Num, Num), @@ -289,6 +290,7 @@ impl quote::ToTokens for PatternEffect { quote! { FineVolumeSlide(agb_tracker::__private::Num::from_raw(#amount))} } PatternEffect::NoteCut(wait) => quote! { NoteCut(#wait) }, + PatternEffect::NoteDelay(wait) => quote! { NoteDelay(#wait) }, PatternEffect::Portamento(amount) => { let amount = amount.to_raw(); quote! { Portamento(agb_tracker::__private::Num::from_raw(#amount))} diff --git a/tracker/agb-tracker/src/lib.rs b/tracker/agb-tracker/src/lib.rs index 11212b20..9e1b55ab 100644 --- a/tracker/agb-tracker/src/lib.rs +++ b/tracker/agb-tracker/src/lib.rs @@ -405,6 +405,15 @@ impl TrackerChannel { } } } + PatternEffect::NoteDelay(wait) => { + if tick <= *wait { + channel.volume(0); + } + + if tick == *wait + 1 { + channel.volume((self.volume * global_settings.volume).try_change_base().unwrap()); + } + } PatternEffect::Portamento(amount) => { if tick != 0 { self.base_speed *= amount.change_base(); diff --git a/tracker/agb-xm-core/src/lib.rs b/tracker/agb-xm-core/src/lib.rs index fcc20e0a..ee644b01 100644 --- a/tracker/agb-xm-core/src/lib.rs +++ b/tracker/agb-xm-core/src/lib.rs @@ -347,6 +347,7 @@ pub fn parse_module(module: &Module) -> TokenStream { -Num::new((slot.effect_parameter & 0xf) as i16) / 128, ), 0xC => PatternEffect::NoteCut((slot.effect_parameter & 0xf).into()), + 0xD => PatternEffect::NoteDelay((slot.effect_parameter & 0xf).into()), _ => PatternEffect::None, }, 0xF => match slot.effect_parameter {