mirror of
https://github.com/italicsjenga/agb.git
synced 2024-12-23 08:11:33 +11:00
Use 32768Hz for the tracker (#479)
Sounds way better and we can get away with it in DPL - [x] no changelog update needed
This commit is contained in:
commit
7edc6d16ab
|
@ -109,7 +109,7 @@ pub fn entry(mut gba: agb::Gba) -> ! {
|
||||||
let _ = save::save_max_level(&mut gba.save, 0);
|
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 sfx = Sfx::new(&mut mixer);
|
||||||
|
|
||||||
let mut g = Agb {
|
let mut g = Agb {
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
use agb::{
|
use agb::{
|
||||||
|
fixnum::num,
|
||||||
include_wav,
|
include_wav,
|
||||||
sound::mixer::{Mixer, SoundChannel},
|
sound::mixer::{Mixer, SoundChannel},
|
||||||
};
|
};
|
||||||
|
@ -37,38 +38,38 @@ impl<'a> Sfx<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn bad_selection(&mut self) {
|
pub fn bad_selection(&mut self) {
|
||||||
self.mixer.play_sound(SoundChannel::new(BAD_SELECTION));
|
self.play_effect(BAD_SELECTION);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn select(&mut self) {
|
pub fn select(&mut self) {
|
||||||
self.mixer.play_sound(SoundChannel::new(SELECT));
|
self.play_effect(SELECT);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn place(&mut self) {
|
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>) {
|
pub fn play_sound_effect(&mut self, effect: Option<SoundEffect>) {
|
||||||
if let Some(effect) = effect {
|
if let Some(effect) = effect {
|
||||||
match effect {
|
match effect {
|
||||||
SoundEffect::WallHit => {
|
SoundEffect::WallHit => {
|
||||||
self.mixer.play_sound(SoundChannel::new(WALL_HIT));
|
self.play_effect(WALL_HIT);
|
||||||
}
|
}
|
||||||
SoundEffect::SlimeDie => {
|
SoundEffect::SlimeDie => {
|
||||||
self.mixer.play_sound(SoundChannel::new(SLIME_DEATH));
|
self.play_effect(SLIME_DEATH);
|
||||||
}
|
}
|
||||||
SoundEffect::HeroDie => {}
|
SoundEffect::HeroDie => {}
|
||||||
SoundEffect::SquidDie => {}
|
SoundEffect::SquidDie => {}
|
||||||
SoundEffect::SwordPickup => {
|
SoundEffect::SwordPickup => {
|
||||||
self.mixer.play_sound(SoundChannel::new(SWORD_PICKUP));
|
self.play_effect(SWORD_PICKUP);
|
||||||
}
|
}
|
||||||
SoundEffect::SwordKill => {}
|
SoundEffect::SwordKill => {}
|
||||||
SoundEffect::KeyPickup => {}
|
SoundEffect::KeyPickup => {}
|
||||||
SoundEffect::DoorOpen => {
|
SoundEffect::DoorOpen => {
|
||||||
self.mixer.play_sound(SoundChannel::new(DOOR_OPEN));
|
self.play_effect(DOOR_OPEN);
|
||||||
}
|
}
|
||||||
SoundEffect::SwitchToggle => {
|
SoundEffect::SwitchToggle => {
|
||||||
self.mixer.play_sound(SoundChannel::new(SWICTH_TOGGLES[0]));
|
self.play_effect(SWICTH_TOGGLES[0]);
|
||||||
}
|
}
|
||||||
SoundEffect::KeyDrop => {}
|
SoundEffect::KeyDrop => {}
|
||||||
SoundEffect::SwordDrop => {}
|
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)]
|
#[derive(Clone, Copy, PartialEq, Eq, Debug, Hash)]
|
||||||
|
|
|
@ -12,7 +12,7 @@ const DB_TOFFE: Track = include_xm!("examples/db_toffe.xm");
|
||||||
fn main(mut gba: Gba) -> ! {
|
fn main(mut gba: Gba) -> ! {
|
||||||
let vblank_provider = agb::interrupt::VBlank::get();
|
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();
|
mixer.enable();
|
||||||
|
|
||||||
let mut tracker = Tracker::new(&DB_TOFFE);
|
let mut tracker = Tracker::new(&DB_TOFFE);
|
||||||
|
|
|
@ -18,7 +18,7 @@ fn main(mut gba: Gba) -> ! {
|
||||||
timer.set_enabled(true);
|
timer.set_enabled(true);
|
||||||
timer2.set_cascade(true).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();
|
mixer.enable();
|
||||||
|
|
||||||
let mut tracker = Tracker::new(&DB_TOFFE);
|
let mut tracker = Tracker::new(&DB_TOFFE);
|
||||||
|
|
|
@ -35,7 +35,7 @@
|
||||||
//! fn main(mut gba: Gba) -> ! {
|
//! fn main(mut gba: Gba) -> ! {
|
||||||
//! let vblank_provider = agb::interrupt::VBlank::get();
|
//! 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();
|
//! mixer.enable();
|
||||||
//!
|
//!
|
||||||
//! let mut tracker = Tracker::new(&DB_TOFFE);
|
//! let mut tracker = Tracker::new(&DB_TOFFE);
|
||||||
|
@ -49,7 +49,7 @@
|
||||||
//! }
|
//! }
|
||||||
//! ```
|
//! ```
|
||||||
//!
|
//!
|
||||||
//! Note that currently you have to select 18157Hz as the frequency for the mixer.
|
//! Note that currently you have to select 32768Hz as the frequency for the mixer.
|
||||||
//! This restriction will be lifted in a future version.
|
//! This restriction will be lifted in a future version.
|
||||||
//!
|
//!
|
||||||
//! # Concepts
|
//! # Concepts
|
||||||
|
|
|
@ -475,7 +475,7 @@ fn note_to_speed(
|
||||||
FrequencyType::AmigaFrequencies => note_to_frequency_amega(note, fine_tune, relative_note),
|
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;
|
let speed = frequency / gba_audio_frequency;
|
||||||
Num::from_f64(speed)
|
Num::from_f64(speed)
|
||||||
|
|
Loading…
Reference in a new issue