From 80ce5173e19fbeeeb8f60216cb5a41140de9ce99 Mon Sep 17 00:00:00 2001 From: Gwilym Kuiper Date: Fri, 25 Jun 2021 21:41:35 +0100 Subject: [PATCH] Provide a way to get the channel again --- agb/src/sound/mixer/sw_mixer.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/agb/src/sound/mixer/sw_mixer.rs b/agb/src/sound/mixer/sw_mixer.rs index aef9acfe..755025b0 100644 --- a/agb/src/sound/mixer/sw_mixer.rs +++ b/agb/src/sound/mixer/sw_mixer.rs @@ -62,6 +62,16 @@ impl Mixer { panic!("Cannot play more than 16 sounds at once"); } + + pub fn get_channel(&mut self, id: ChannelId) -> Option<&'_ mut SoundChannel> { + if let Some(channel) = &mut self.channels[id.0] { + if self.indices[id.0] == id.1 { + return Some(channel); + } + } + + None + } } // I've picked one frequency that works nicely. But there are others that work nicely