mirror of
https://github.com/italicsjenga/agb.git
synced 2025-01-22 23:26:33 +11:00
Keep track of whether a channel is done
This commit is contained in:
parent
063af3fc40
commit
f82ed3d7c1
2 changed files with 7 additions and 0 deletions
|
@ -82,6 +82,10 @@ impl MixerBuffer {
|
|||
let mut buffer: [Num<i16, 4>; SOUND_BUFFER_SIZE * 2] = [Num::new(0); SOUND_BUFFER_SIZE * 2];
|
||||
|
||||
for channel in channels {
|
||||
if channel.is_done {
|
||||
continue;
|
||||
}
|
||||
|
||||
let mut current_point = channel.pos;
|
||||
|
||||
let right_amount = (channel.panning - 1) / 2;
|
||||
|
@ -96,6 +100,7 @@ impl MixerBuffer {
|
|||
if channel.should_loop {
|
||||
channel.pos -= channel.data.len();
|
||||
} else {
|
||||
channel.is_done = true;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,6 +26,7 @@ pub struct SoundChannel {
|
|||
playback_speed: Num<usize, 8>,
|
||||
|
||||
panning: Num<i16, 4>, // between -1 and 1
|
||||
is_done: bool,
|
||||
}
|
||||
|
||||
impl SoundChannel {
|
||||
|
@ -36,6 +37,7 @@ impl SoundChannel {
|
|||
should_loop: false,
|
||||
playback_speed: 1.into(),
|
||||
panning: 0.into(),
|
||||
is_done: false,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue