Use 32768Hz for the tracker

This commit is contained in:
Gwilym Inzani 2023-09-05 23:22:50 +01:00
parent ff4154699a
commit 0c19988699
5 changed files with 19 additions and 12 deletions

View file

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

View file

@ -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<SoundEffect>) {
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)]

View file

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

View file

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

View file

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