mirror of
https://github.com/italicsjenga/agb.git
synced 2024-12-24 00:31:34 +11:00
Merge pull request #61 from gwilymk/allow-not-exactly-correct-length-sounds
Handle sounds of length not exactly a multiple of SOUND_BUFFER_SIZE
This commit is contained in:
commit
773e893421
|
@ -115,10 +115,10 @@ impl MixerBuffer {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn write_channel(&mut self, channel: &SoundChannel) {
|
fn write_channel(&mut self, channel: &SoundChannel) {
|
||||||
let data_to_copy = &channel.data[channel.pos..(channel.pos + SOUND_BUFFER_SIZE)];
|
let data_to_copy = &channel.data[channel.pos..];
|
||||||
let place_to_write_to = self.get_write_buffer();
|
let place_to_write_to = self.get_write_buffer();
|
||||||
|
|
||||||
for (i, v) in data_to_copy.iter().enumerate() {
|
for (i, v) in data_to_copy.iter().take(SOUND_BUFFER_SIZE).enumerate() {
|
||||||
let v = *v as i8;
|
let v = *v as i8;
|
||||||
place_to_write_to[i] = place_to_write_to[i].saturating_add(v);
|
place_to_write_to[i] = place_to_write_to[i].saturating_add(v);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue