mirror of
https://github.com/italicsjenga/agb.git
synced 2024-12-23 00:01:34 +11:00
Actually use the new first methods
This commit is contained in:
parent
3b35061a3a
commit
13f5fe01d7
|
@ -35,7 +35,7 @@ agb_arm_func \fn_name
|
|||
ldrsb r6, [r4] @ load the current sound sample to r6
|
||||
add r5, r5, r2 @ calculate the position to read the next sample from
|
||||
|
||||
.ifc is_first,true
|
||||
.ifc \is_first,true
|
||||
mul r4, r6, r7 @ r4 = r6 * r7 (calculating both the left and right samples together)
|
||||
.else
|
||||
ldr r4, [r1] @ read the current value
|
||||
|
@ -82,7 +82,7 @@ agb_arm_func \fn_name
|
|||
lsl r6, r6, #16
|
||||
orr r6, r6, lsr #16
|
||||
|
||||
.ifc is_first,true
|
||||
.ifc \is_first,true
|
||||
mov r4, r6, lsl r3 @ r4 = r6 << r3
|
||||
.else
|
||||
ldr r4, [r1] @ read the current value
|
||||
|
|
|
@ -420,9 +420,7 @@ impl MixerBuffer {
|
|||
working_buffer: &mut [Num<i16, 4>],
|
||||
channels: impl Iterator<Item = &'a mut SoundChannel>,
|
||||
) {
|
||||
working_buffer.fill(0.into());
|
||||
|
||||
let channels = channels
|
||||
let mut channels = channels
|
||||
.filter(|channel| !channel.is_done)
|
||||
.filter_map(|channel| {
|
||||
let playback_speed = if channel.is_stereo {
|
||||
|
@ -446,6 +444,39 @@ impl MixerBuffer {
|
|||
Some((channel, playback_speed))
|
||||
});
|
||||
|
||||
if let Some((channel, playback_speed)) = channels.next() {
|
||||
if channel.volume != 0.into() {
|
||||
if channel.is_stereo {
|
||||
unsafe {
|
||||
agb_rs__mixer_add_stereo_first(
|
||||
channel.data.as_ptr().add(channel.pos.floor() as usize),
|
||||
working_buffer.as_mut_ptr(),
|
||||
channel.volume,
|
||||
);
|
||||
}
|
||||
} else {
|
||||
let right_amount = ((channel.panning + 1) / 2) * channel.volume;
|
||||
let left_amount = ((-channel.panning + 1) / 2) * channel.volume;
|
||||
|
||||
unsafe {
|
||||
agb_rs__mixer_add_first(
|
||||
channel.data.as_ptr().add(channel.pos.floor() as usize),
|
||||
working_buffer.as_mut_ptr(),
|
||||
playback_speed,
|
||||
left_amount,
|
||||
right_amount,
|
||||
);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
working_buffer.fill(0.into());
|
||||
}
|
||||
|
||||
channel.pos += playback_speed * self.frequency.buffer_size() as u32;
|
||||
} else {
|
||||
working_buffer.fill(0.into());
|
||||
}
|
||||
|
||||
for (channel, playback_speed) in channels {
|
||||
if channel.volume != 0.into() {
|
||||
if channel.is_stereo {
|
||||
|
|
Loading…
Reference in a new issue