mirror of
https://github.com/italicsjenga/agb.git
synced 2024-12-23 08:11:33 +11:00
Add Portamento
This commit is contained in:
parent
1b8f4bbdc9
commit
b6cccf3b5a
|
@ -49,6 +49,7 @@ pub enum PatternEffect {
|
||||||
Volume(Num<i16, 4>),
|
Volume(Num<i16, 4>),
|
||||||
VolumeSlide(Num<i16, 4>),
|
VolumeSlide(Num<i16, 4>),
|
||||||
NoteCut(u32),
|
NoteCut(u32),
|
||||||
|
Portamento(Num<u16, 8>),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "quote")]
|
#[cfg(feature = "quote")]
|
||||||
|
@ -204,6 +205,10 @@ impl quote::ToTokens for PatternEffect {
|
||||||
quote! { VolumeSlide(agb_tracker::__private::Num::from_raw(#amount))}
|
quote! { VolumeSlide(agb_tracker::__private::Num::from_raw(#amount))}
|
||||||
}
|
}
|
||||||
PatternEffect::NoteCut(wait) => quote! { NoteCut(#wait) },
|
PatternEffect::NoteCut(wait) => quote! { NoteCut(#wait) },
|
||||||
|
PatternEffect::Portamento(amount) => {
|
||||||
|
let amount = amount.to_raw();
|
||||||
|
quote! { Portamento(agb_tracker::__private::Num::from_raw(#amount))}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
tokens.append_all(quote! {
|
tokens.append_all(quote! {
|
||||||
|
|
|
@ -61,7 +61,7 @@ impl Tracker {
|
||||||
tick: 0,
|
tick: 0,
|
||||||
|
|
||||||
current_row: 0,
|
current_row: 0,
|
||||||
current_pattern: 0,
|
current_pattern: 31,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -78,7 +78,7 @@ impl Tracker {
|
||||||
let pattern_slots =
|
let pattern_slots =
|
||||||
&self.track.pattern_data[pattern_data_pos..pattern_data_pos + self.track.num_channels];
|
&self.track.pattern_data[pattern_data_pos..pattern_data_pos + self.track.num_channels];
|
||||||
|
|
||||||
for (channel, pattern_slot) in self.channels.iter_mut().zip(pattern_slots) {
|
for (channel, pattern_slot) in self.channels.iter_mut().zip(pattern_slots).skip(3) {
|
||||||
if pattern_slot.sample != 0 && self.tick == 0 {
|
if pattern_slot.sample != 0 && self.tick == 0 {
|
||||||
let sample = &self.track.samples[pattern_slot.sample as usize - 1];
|
let sample = &self.track.samples[pattern_slot.sample as usize - 1];
|
||||||
channel.play_sound(mixer, sample);
|
channel.play_sound(mixer, sample);
|
||||||
|
@ -214,6 +214,12 @@ impl TrackerChannel {
|
||||||
self.volume = 0.into();
|
self.volume = 0.into();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
PatternEffect::Portamento(amount) => {
|
||||||
|
if tick != 0 {
|
||||||
|
self.base_speed *= amount.change_base();
|
||||||
|
channel.playback(self.base_speed);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -197,6 +197,32 @@ pub fn parse_module(module: &Module) -> TokenStream {
|
||||||
PatternEffect::None
|
PatternEffect::None
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
0x1 => {
|
||||||
|
let c4_speed = note_to_speed(Note::C4, 0.0, 0, module.frequency_type);
|
||||||
|
let speed = note_to_speed(
|
||||||
|
Note::C4,
|
||||||
|
slot.effect_parameter as f64,
|
||||||
|
0,
|
||||||
|
module.frequency_type,
|
||||||
|
);
|
||||||
|
|
||||||
|
let portamento_amount = speed / c4_speed;
|
||||||
|
|
||||||
|
PatternEffect::Portamento(portamento_amount.try_change_base().unwrap())
|
||||||
|
}
|
||||||
|
0x2 => {
|
||||||
|
let c4_speed = note_to_speed(Note::C4, 0.0, 0, module.frequency_type);
|
||||||
|
let speed = note_to_speed(
|
||||||
|
Note::C4,
|
||||||
|
-(slot.effect_parameter as f64),
|
||||||
|
0,
|
||||||
|
module.frequency_type,
|
||||||
|
);
|
||||||
|
|
||||||
|
let portamento_amount = speed / c4_speed;
|
||||||
|
|
||||||
|
PatternEffect::Portamento(portamento_amount.try_change_base().unwrap())
|
||||||
|
}
|
||||||
0x8 => {
|
0x8 => {
|
||||||
PatternEffect::Panning(Num::new(slot.effect_parameter as i16 - 128) / 128)
|
PatternEffect::Panning(Num::new(slot.effect_parameter as i16 - 128) / 128)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue