[Core/Sound] optimized Blip Buffer implementation for stereo streams (thanks to David Knight for original idea)

This commit is contained in:
EkeEke 2016-12-18 23:09:16 +01:00 committed by twinaphex
parent 25626ea251
commit cb2193583b

View File

@ -167,45 +167,23 @@ int SN76489_GetContextSize(void)
/* Updates tone amplitude in delta buffer. Call whenever amplitude might have changed. */ /* Updates tone amplitude in delta buffer. Call whenever amplitude might have changed. */
INLINE void UpdateToneAmplitude(int i, int time) INLINE void UpdateToneAmplitude(int i, int time)
{ {
int delta; /* left & right output */
int delta_l = (SN76489.Channel[i][0] * SN76489.ToneFreqPos[i]) - SN76489.ChanOut[i][0];
/* left output */ int delta_r = (SN76489.Channel[i][1] * SN76489.ToneFreqPos[i]) - SN76489.ChanOut[i][1];
delta = (SN76489.Channel[i][0] * SN76489.ToneFreqPos[i]) - SN76489.ChanOut[i][0]; blip_add_delta(snd.blips[0], time, delta_l, delta_r);
if (delta != 0) SN76489.ChanOut[i][0] += delta_l;
{ SN76489.ChanOut[i][1] += delta_r;
SN76489.ChanOut[i][0] += delta;
blip_add_delta(snd.blips[0][0], time, delta);
}
/* right output */
delta = (SN76489.Channel[i][1] * SN76489.ToneFreqPos[i]) - SN76489.ChanOut[i][1];
if (delta != 0)
{
SN76489.ChanOut[i][1] += delta;
blip_add_delta(snd.blips[0][1], time, delta);
}
} }
/* Updates noise amplitude in delta buffer. Call whenever amplitude might have changed. */ /* Updates noise amplitude in delta buffer. Call whenever amplitude might have changed. */
INLINE void UpdateNoiseAmplitude(int time) INLINE void UpdateNoiseAmplitude(int time)
{ {
int delta; /* left & right output */
int delta_l = (SN76489.Channel[3][0] * ( SN76489.NoiseShiftRegister & 0x1 )) - SN76489.ChanOut[3][0];
/* left output */ int delta_r = (SN76489.Channel[3][1] * ( SN76489.NoiseShiftRegister & 0x1 )) - SN76489.ChanOut[3][1];
delta = (SN76489.Channel[3][0] * ( SN76489.NoiseShiftRegister & 0x1 )) - SN76489.ChanOut[3][0]; blip_add_delta(snd.blips[0], time, delta_l, delta_r);
if (delta != 0) SN76489.ChanOut[3][0] += delta_l;
{ SN76489.ChanOut[3][1] += delta_r;
SN76489.ChanOut[3][0] += delta;
blip_add_delta(snd.blips[0][0], time, delta);
}
/* right output */
delta = (SN76489.Channel[3][1] * ( SN76489.NoiseShiftRegister & 0x1 )) - SN76489.ChanOut[3][1];
if (delta != 0)
{
SN76489.ChanOut[3][1] += delta;
blip_add_delta(snd.blips[0][1], time, delta);
}
} }
/* Runs tone channel for clock_length clocks */ /* Runs tone channel for clock_length clocks */