diff --git a/tracker/agb-tracker-interop/src/lib.rs b/tracker/agb-tracker-interop/src/lib.rs index 61b4deb9..26026d9a 100644 --- a/tracker/agb-tracker-interop/src/lib.rs +++ b/tracker/agb-tracker-interop/src/lib.rs @@ -19,7 +19,7 @@ pub struct Sample<'a> { pub data: &'a [u8], pub should_loop: bool, pub restart_point: u32, - pub volume: Num, + pub volume: Num, } #[derive(Debug)] @@ -46,9 +46,9 @@ pub enum PatternEffect { /// Plays an arpeggiation of three notes in one row, cycling betwen the current note, current note + first speed, current note + second speed Arpeggio(Num, Num), Panning(Num), - Volume(Num), - VolumeSlide(Num), - FineVolumeSlide(Num), + Volume(Num), + VolumeSlide(Num), + FineVolumeSlide(Num), NoteCut(u32), Portamento(Num), /// Slide each tick the first amount to at most the second amount diff --git a/tracker/agb-tracker/src/lib.rs b/tracker/agb-tracker/src/lib.rs index 22ffb5d0..297b40bc 100644 --- a/tracker/agb-tracker/src/lib.rs +++ b/tracker/agb-tracker/src/lib.rs @@ -102,7 +102,7 @@ pub struct Tracker { struct TrackerChannel { channel_id: Option, base_speed: Num, - volume: Num, + volume: Num, } impl Tracker { @@ -143,7 +143,7 @@ impl Tracker { let pattern_slots = &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).skip(3) { + for (channel, pattern_slot) in self.channels.iter_mut().zip(pattern_slots) { if pattern_slot.sample != 0 && self.tick == 0 { let sample = &self.track.samples[pattern_slot.sample as usize - 1]; channel.play_sound(mixer, sample); @@ -210,7 +210,7 @@ impl TrackerChannel { let mut new_channel = SoundChannel::new(sample.data); - new_channel.volume(sample.volume); + new_channel.volume(sample.volume.change_base()); if sample.should_loop { new_channel @@ -219,7 +219,7 @@ impl TrackerChannel { } self.channel_id = mixer.play_sound(new_channel); - self.volume = sample.volume; + self.volume = sample.volume.change_base(); } fn set_speed(&mut self, mixer: &mut Mixer<'_>, speed: Num) { @@ -259,19 +259,19 @@ impl TrackerChannel { channel.panning(*panning); } PatternEffect::Volume(volume) => { - channel.volume(*volume); - self.volume = *volume; + channel.volume(volume.change_base()); + self.volume = volume.change_base(); } PatternEffect::VolumeSlide(amount) => { if tick != 0 { - self.volume = (self.volume + *amount).max(0.into()); - channel.volume(self.volume); + self.volume = (self.volume + amount.change_base()).max(0.into()); + channel.volume(self.volume.try_change_base().unwrap()); } } PatternEffect::FineVolumeSlide(amount) => { if tick == 0 { - self.volume = (self.volume + *amount).max(0.into()); - channel.volume(self.volume); + self.volume = (self.volume + amount.change_base()).max(0.into()); + channel.volume(self.volume.try_change_base().unwrap()); } } PatternEffect::NoteCut(wait) => { diff --git a/tracker/agb-xm-core/src/lib.rs b/tracker/agb-xm-core/src/lib.rs index 34fd935c..1bf6803a 100644 --- a/tracker/agb-xm-core/src/lib.rs +++ b/tracker/agb-xm-core/src/lib.rs @@ -55,7 +55,7 @@ pub fn parse_module(module: &Module) -> TokenStream { fine_tune: f64, relative_note: i8, restart_point: u32, - volume: Num, + volume: Num, } let mut samples = vec![]; @@ -76,7 +76,7 @@ pub fn parse_module(module: &Module) -> TokenStream { usize::MAX }; - let volume = Num::from_raw((sample.volume * (1 << 4) as f32) as i16); + let volume = Num::from_raw((sample.volume * (1 << 8) as f32) as i16); let sample = match &sample.data { SampleDataType::Depth8(depth8) => depth8 @@ -163,10 +163,10 @@ pub fn parse_module(module: &Module) -> TokenStream { .unwrap_or(1.into()), ), 0x80..=0x8F => PatternEffect::FineVolumeSlide( - -Num::new((slot.volume - 0x80) as i16) / 16, + -Num::new((slot.volume - 0x80) as i16) / 64, ), 0x90..=0x9F => PatternEffect::FineVolumeSlide( - Num::new((slot.volume - 0x90) as i16) / 16, + Num::new((slot.volume - 0x90) as i16) / 64, ), 0xC0..=0xCF => PatternEffect::Panning( Num::new(slot.volume as i16 - (0xC0 + (0xCF - 0xC0) / 2)) / 64, @@ -299,10 +299,10 @@ pub fn parse_module(module: &Module) -> TokenStream { } 0xE => match slot.effect_parameter >> 4 { 0xA => PatternEffect::FineVolumeSlide( - Num::new((slot.effect_parameter & 0xf) as i16) / 16, + Num::new((slot.effect_parameter & 0xf) as i16) / 64, ), 0xB => PatternEffect::FineVolumeSlide( - -Num::new((slot.effect_parameter & 0xf) as i16) / 16, + -Num::new((slot.effect_parameter & 0xf) as i16) / 64, ), 0xC => PatternEffect::NoteCut((slot.effect_parameter & 0xf).into()), _ => PatternEffect::None,