If volume is 0, don't actually play anything

This commit is contained in:
Gwilym Kuiper 2023-01-12 21:54:08 +00:00
parent 6ebe08e528
commit 8009ffea09

View file

@ -446,26 +446,28 @@ impl MixerBuffer {
} }
} }
if channel.is_stereo { if channel.volume != 0.into() {
unsafe { if channel.is_stereo {
agb_rs__mixer_add_stereo( unsafe {
channel.data.as_ptr().add(channel.pos.floor()), agb_rs__mixer_add_stereo(
self.working_buffer.as_mut_ptr(), channel.data.as_ptr().add(channel.pos.floor()),
channel.volume, self.working_buffer.as_mut_ptr(),
); channel.volume,
} );
} else { }
let right_amount = ((channel.panning + 1) / 2) * channel.volume; } else {
let left_amount = ((-channel.panning + 1) / 2) * channel.volume; let right_amount = ((channel.panning + 1) / 2) * channel.volume;
let left_amount = ((-channel.panning + 1) / 2) * channel.volume;
unsafe { unsafe {
agb_rs__mixer_add( agb_rs__mixer_add(
channel.data.as_ptr().add(channel.pos.floor()), channel.data.as_ptr().add(channel.pos.floor()),
self.working_buffer.as_mut_ptr(), self.working_buffer.as_mut_ptr(),
playback_speed, playback_speed,
left_amount, left_amount,
right_amount, right_amount,
); );
}
} }
} }