diff --git a/examples/the-dungeon-puzzlers-lament/src/sfx.rs b/examples/the-dungeon-puzzlers-lament/src/sfx.rs index d5d5952f..2eadd8dc 100644 --- a/examples/the-dungeon-puzzlers-lament/src/sfx.rs +++ b/examples/the-dungeon-puzzlers-lament/src/sfx.rs @@ -20,7 +20,7 @@ static SWICTH_TOGGLES: &[&[u8]] = &[include_wav!("sfx/switch_toggle1.wav")]; pub struct Sfx<'a> { mixer: &'a mut Mixer<'a>, - tracker: Tracker>, + tracker: Tracker, } impl<'a> Sfx<'a> { diff --git a/tracker/agb-tracker/src/lib.rs b/tracker/agb-tracker/src/lib.rs index b4d952d4..a8af2f20 100644 --- a/tracker/agb-tracker/src/lib.rs +++ b/tracker/agb-tracker/src/lib.rs @@ -95,9 +95,9 @@ pub mod __private { pub use agb_tracker_interop::Track; /// Stores the required state in order to play tracker music. -pub struct Tracker { +pub struct TrackerInner { track: &'static Track, - channels: Vec>, + channels: Vec>, envelopes: Vec>, frame: Num, @@ -110,8 +110,8 @@ pub struct Tracker { current_pattern: usize, } -struct TrackerChannel { - channel_id: Option, +struct TrackerChannel { + channel_id: Option, original_speed: Num, base_speed: Num, volume: Num, @@ -132,7 +132,7 @@ struct GlobalSettings { volume: Num, } -impl Tracker { +impl TrackerInner { /// Create a new tracker playing a specified track. See the [example](crate#example) for how to use the tracker. pub fn new(track: &'static Track) -> Self { let mut channels = Vec::new(); @@ -165,7 +165,7 @@ impl Tracker { /// Call this once per frame before calling [`mixer.frame`](agb::sound::mixer::Mixer::frame()). /// See the [example](crate#example) for how to use the tracker. - pub fn step(&mut self, mixer: &mut M) { + pub fn step>(&mut self, mixer: &mut M) { if !self.increment_frame() { self.update_envelopes(mixer); return; @@ -215,7 +215,7 @@ impl Tracker { self.update_envelopes(mixer); } - fn update_envelopes(&mut self, mixer: &mut M) { + fn update_envelopes>(&mut self, mixer: &mut M) { for (channel, envelope_state_option) in self.channels.iter_mut().zip(&mut self.envelopes) { if let Some(envelope_state) = envelope_state_option { let envelope = &self.track.envelopes[envelope_state.envelope_id]; @@ -288,8 +288,13 @@ impl Tracker { } } -impl TrackerChannel { - fn play_sound(&mut self, mixer: &mut M, sample: &Sample, global_settings: &GlobalSettings) { +impl TrackerChannel { + fn play_sound>( + &mut self, + mixer: &mut M, + sample: &Sample, + global_settings: &GlobalSettings, + ) { if let Some(channel) = self .channel_id .take() @@ -316,7 +321,7 @@ impl TrackerChannel { self.volume = sample.volume.change_base(); } - fn set_speed(&mut self, mixer: &mut M, speed: Num) { + fn set_speed>(&mut self, mixer: &mut M, speed: Num) { if let Some(channel) = self .channel_id .as_ref() @@ -331,7 +336,7 @@ impl TrackerChannel { } } - fn apply_effect( + fn apply_effect>( &mut self, mixer: &mut M, effect: &PatternEffect, @@ -473,7 +478,7 @@ impl TrackerChannel { } #[must_use] - fn update_volume_envelope( + fn update_volume_envelope>( &mut self, mixer: &mut M, envelope_state: &EnvelopeState, @@ -504,7 +509,7 @@ impl TrackerChannel { } } -impl Default for TrackerChannel { +impl Default for TrackerChannel { fn default() -> Self { Self { channel_id: None, @@ -578,3 +583,7 @@ impl<'gba> Mixer for agb::sound::mixer::Mixer<'gba> { self.play_sound(channel) } } + +#[cfg(feature = "agb")] +/// The type to use if you're using agb-tracker with agb +pub type Tracker = TrackerInner; diff --git a/tracker/desktop-player/src/main.rs b/tracker/desktop-player/src/main.rs index 60b8ed99..b138e935 100644 --- a/tracker/desktop-player/src/main.rs +++ b/tracker/desktop-player/src/main.rs @@ -18,7 +18,7 @@ fn main() -> Result<(), Box> { let track = Box::leak::<'static>(Box::new(agb_xm_core::parse_module(&module))); let mut mixer = Mixer::new(); - let mut tracker = agb_tracker::Tracker::new(track); + let mut tracker = agb_tracker::TrackerInner::new(track); let host = cpal::default_host(); let device = host