diff --git a/agb/examples/mixer_basic.rs b/agb/examples/mixer_basic.rs index a9761403..c96103a7 100644 --- a/agb/examples/mixer_basic.rs +++ b/agb/examples/mixer_basic.rs @@ -17,7 +17,7 @@ fn main() -> ! { let mut input = ButtonController::new(); let vblank_provider = agb::interrupt::VBlank::get(); - let mut mixer = gba.mixer.mixer(gba.timers.timer0); + let mut mixer = gba.mixer.mixer(&mut gba.timers.timer0); mixer.enable(); let channel = SoundChannel::new(DEAD_CODE); diff --git a/agb/examples/stereo_sound.rs b/agb/examples/stereo_sound.rs index 8050f602..0eda7f42 100644 --- a/agb/examples/stereo_sound.rs +++ b/agb/examples/stereo_sound.rs @@ -14,11 +14,11 @@ fn main() -> ! { let mut gba = Gba::new(); let vblank_provider = agb::interrupt::VBlank::get(); - let timer_controller = gba.timers; + let mut timer_controller = gba.timers; let mut timer = timer_controller.timer1; timer.set_enabled(true); - let mut mixer = gba.mixer.mixer(timer_controller.timer0); + let mut mixer = gba.mixer.mixer(&mut timer_controller.timer0); mixer.enable(); let mut channel = SoundChannel::new(LET_IT_IN); diff --git a/agb/src/sound/mixer/mod.rs b/agb/src/sound/mixer/mod.rs index e6f598ff..80a009d6 100644 --- a/agb/src/sound/mixer/mod.rs +++ b/agb/src/sound/mixer/mod.rs @@ -15,7 +15,7 @@ impl MixerController { MixerController {} } - pub fn mixer(&mut self, timer: Timer) -> Mixer { + pub fn mixer<'a>(&mut self, timer: &'a mut Timer) -> Mixer<'a> { Mixer::new(timer) } } diff --git a/agb/src/sound/mixer/sw_mixer.rs b/agb/src/sound/mixer/sw_mixer.rs index f35bf6d5..d9229404 100644 --- a/agb/src/sound/mixer/sw_mixer.rs +++ b/agb/src/sound/mixer/sw_mixer.rs @@ -19,18 +19,18 @@ extern "C" { fn agb_rs__mixer_collapse(sound_buffer: *mut i8, input_buffer: *const Num); } -pub struct Mixer { +pub struct Mixer<'a> { buffer: MixerBuffer, channels: [Option; 8], indices: [i32; 8], - timer: Timer, + timer: &'a mut Timer, } pub struct ChannelId(usize, i32); -impl Mixer { - pub(super) fn new(timer: Timer) -> Self { +impl<'a> Mixer<'a> { + pub(super) fn new(timer: &'a mut Timer) -> Self { Mixer { buffer: MixerBuffer::new(), channels: Default::default(),