Add note delay support (effect EDx)

This commit is contained in:
Gwilym Inzani 2024-05-15 22:30:13 +01:00
parent c099fc9a61
commit 2e0f89978a
3 changed files with 12 additions and 0 deletions

View file

@ -62,6 +62,7 @@ pub enum PatternEffect {
VolumeSlide(Num<i16, 8>),
FineVolumeSlide(Num<i16, 8>),
NoteCut(u32),
NoteDelay(u32),
Portamento(Num<u16, 12>),
/// Slide each tick the first amount to at most the second amount
TonePortamento(Num<u16, 12>, Num<u16, 12>),
@ -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))}

View file

@ -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();

View file

@ -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 {