mirror of
https://github.com/italicsjenga/agb.git
synced 2024-12-23 08:11:33 +11:00
Add a method to stop the tracker
This commit is contained in:
parent
84a3c0b6a0
commit
8cec568a5b
|
@ -286,6 +286,21 @@ impl<'track, TChannelId> TrackerInner<'track, TChannelId> {
|
|||
self.realise(mixer);
|
||||
}
|
||||
|
||||
/// Stops all channels.
|
||||
///
|
||||
/// It is expected that you don't call step after this. But doing so will continue from
|
||||
/// where you left off. However, notes which were playing won't resume.
|
||||
pub fn stop<M: Mixer<ChannelId = TChannelId>>(&mut self, mixer: &mut M) {
|
||||
for channel_id in &mut self.mixer_channels {
|
||||
if let Some(channel) = channel_id
|
||||
.take()
|
||||
.and_then(|channel_id| mixer.channel(&channel_id))
|
||||
{
|
||||
channel.stop();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn realise<M: Mixer<ChannelId = TChannelId>>(&mut self, mixer: &mut M) {
|
||||
for (i, (mixer_channel, tracker_channel)) in self
|
||||
.mixer_channels
|
||||
|
|
Loading…
Reference in a new issue