ProcessSound: do not optimize for special values

this makes the code easier to understand and the execution more predictable
pull/952/head
Gergo Koteles 6 days ago
parent ce9f82ca51
commit 7c68142b6b
  1. 31
      src/minidexed.cpp

@ -1354,8 +1354,6 @@ void CMiniDexed::ProcessSound (void)
float32_t tmp_float[nFrames*Channels];
int32_t tmp_int[nFrames*Channels];
if(nMasterVolume > 0.0)
{
// Convert dual float array (8 chan) to single int16 array (8 chan)
for(uint16_t i=0; i<nFrames;i++)
{
@ -1363,23 +1361,12 @@ void CMiniDexed::ProcessSound (void)
// reading directly from the TG OutputLevel buffer with
// no additional processing.
for (uint8_t tg = 0; tg < Channels; tg++)
{
if(nMasterVolume >0.0 && nMasterVolume <1.0)
{
tmp_float[(i*Channels)+tg]=m_OutputLevel[tg][i] * nMasterVolume;
}
else if(nMasterVolume == 1.0)
{
tmp_float[(i*Channels)+tg]=m_OutputLevel[tg][i];
}
}
}
arm_float_to_q23(tmp_float,tmp_int,nFrames*Channels);
}
else
{
arm_fill_q31(0, tmp_int, nFrames*Channels);
}
// Prevent PCM510x analog mute from kicking in
for (uint8_t tg = 0; tg < Channels; tg++)
@ -1404,8 +1391,6 @@ void CMiniDexed::ProcessSound (void)
float32_t tmp_float[nFrames*2];
int32_t tmp_int[nFrames*2];
if(nMasterVolume > 0.0)
{
// get the mix buffer of all TGs
float32_t *SampleBuffer[2];
tg_mixer->getBuffers(SampleBuffer);
@ -1457,24 +1442,12 @@ void CMiniDexed::ProcessSound (void)
// Convert dual float array (left, right) to single int16 array (left/right)
for(uint16_t i=0; i<nFrames;i++)
{
if(nMasterVolume >0.0 && nMasterVolume <1.0)
{
tmp_float[i*2]=SampleBuffer[indexL][i] * nMasterVolume;
tmp_float[(i*2)+1]=SampleBuffer[indexR][i] * nMasterVolume;
}
else if(nMasterVolume == 1.0)
{
tmp_float[i*2]=SampleBuffer[indexL][i];
tmp_float[(i*2)+1]=SampleBuffer[indexR][i];
}
}
arm_float_to_q23(tmp_float,tmp_int,nFrames*2);
}
else
{
arm_fill_q31(0, tmp_int, nFrames * 2);
}
// Prevent PCM510x analog mute from kicking in
if (tmp_int[nFrames * 2 - 1] == 0)

Loading…
Cancel
Save