diff --git a/examples/the-dungeon-puzzlers-lament/src/lib.rs b/examples/the-dungeon-puzzlers-lament/src/lib.rs index 91a7926a..2ab0b021 100644 --- a/examples/the-dungeon-puzzlers-lament/src/lib.rs +++ b/examples/the-dungeon-puzzlers-lament/src/lib.rs @@ -109,7 +109,7 @@ pub fn entry(mut gba: agb::Gba) -> ! { let _ = save::save_max_level(&mut gba.save, 0); } - let mut mixer = gba.mixer.mixer(Frequency::Hz18157); + let mut mixer = gba.mixer.mixer(Frequency::Hz32768); let sfx = Sfx::new(&mut mixer); let mut g = Agb { diff --git a/examples/the-dungeon-puzzlers-lament/src/sfx.rs b/examples/the-dungeon-puzzlers-lament/src/sfx.rs index b4b9cd18..f73d8e62 100644 --- a/examples/the-dungeon-puzzlers-lament/src/sfx.rs +++ b/examples/the-dungeon-puzzlers-lament/src/sfx.rs @@ -1,4 +1,5 @@ use agb::{ + fixnum::num, include_wav, sound::mixer::{Mixer, SoundChannel}, }; @@ -37,38 +38,38 @@ impl<'a> Sfx<'a> { } pub fn bad_selection(&mut self) { - self.mixer.play_sound(SoundChannel::new(BAD_SELECTION)); + self.play_effect(BAD_SELECTION); } pub fn select(&mut self) { - self.mixer.play_sound(SoundChannel::new(SELECT)); + self.play_effect(SELECT); } pub fn place(&mut self) { - self.mixer.play_sound(SoundChannel::new(PLACE)); + self.play_effect(PLACE); } pub fn play_sound_effect(&mut self, effect: Option) { if let Some(effect) = effect { match effect { SoundEffect::WallHit => { - self.mixer.play_sound(SoundChannel::new(WALL_HIT)); + self.play_effect(WALL_HIT); } SoundEffect::SlimeDie => { - self.mixer.play_sound(SoundChannel::new(SLIME_DEATH)); + self.play_effect(SLIME_DEATH); } SoundEffect::HeroDie => {} SoundEffect::SquidDie => {} SoundEffect::SwordPickup => { - self.mixer.play_sound(SoundChannel::new(SWORD_PICKUP)); + self.play_effect(SWORD_PICKUP); } SoundEffect::SwordKill => {} SoundEffect::KeyPickup => {} SoundEffect::DoorOpen => { - self.mixer.play_sound(SoundChannel::new(DOOR_OPEN)); + self.play_effect(DOOR_OPEN); } SoundEffect::SwitchToggle => { - self.mixer.play_sound(SoundChannel::new(SWICTH_TOGGLES[0])); + self.play_effect(SWICTH_TOGGLES[0]); } SoundEffect::KeyDrop => {} SoundEffect::SwordDrop => {} @@ -77,6 +78,12 @@ impl<'a> Sfx<'a> { } } } + + fn play_effect(&mut self, effect: &'static [u8]) { + let mut channel = SoundChannel::new(effect); + channel.playback(num!(0.5)); + self.mixer.play_sound(channel); + } } #[derive(Clone, Copy, PartialEq, Eq, Debug, Hash)] diff --git a/tracker/agb-tracker/examples/basic.rs b/tracker/agb-tracker/examples/basic.rs index bab1e138..023a1b1f 100644 --- a/tracker/agb-tracker/examples/basic.rs +++ b/tracker/agb-tracker/examples/basic.rs @@ -12,7 +12,7 @@ const DB_TOFFE: Track = include_xm!("examples/db_toffe.xm"); fn main(mut gba: Gba) -> ! { let vblank_provider = agb::interrupt::VBlank::get(); - let mut mixer = gba.mixer.mixer(Frequency::Hz18157); + let mut mixer = gba.mixer.mixer(Frequency::Hz32768); mixer.enable(); let mut tracker = Tracker::new(&DB_TOFFE); diff --git a/tracker/agb-tracker/examples/timing.rs b/tracker/agb-tracker/examples/timing.rs index f676ba76..7bc70bd7 100644 --- a/tracker/agb-tracker/examples/timing.rs +++ b/tracker/agb-tracker/examples/timing.rs @@ -18,7 +18,7 @@ fn main(mut gba: Gba) -> ! { timer.set_enabled(true); timer2.set_cascade(true).set_enabled(true); - let mut mixer = gba.mixer.mixer(Frequency::Hz18157); + let mut mixer = gba.mixer.mixer(Frequency::Hz32768); mixer.enable(); let mut tracker = Tracker::new(&DB_TOFFE); diff --git a/tracker/agb-xm-core/src/lib.rs b/tracker/agb-xm-core/src/lib.rs index dd7c0636..36e9a749 100644 --- a/tracker/agb-xm-core/src/lib.rs +++ b/tracker/agb-xm-core/src/lib.rs @@ -475,7 +475,7 @@ fn note_to_speed( FrequencyType::AmigaFrequencies => note_to_frequency_amega(note, fine_tune, relative_note), }; - let gba_audio_frequency = 18157f64; + let gba_audio_frequency = 32768f64; let speed = frequency / gba_audio_frequency; Num::from_f64(speed)