Fixes for ALSA and OpenAL

This patch resolves two issues:

1) No sound using ALSA, caused by a lack of clipping in the ALSA Sound::AudioThread() function.

2) m_fGlobalTime getting stuck at 512 seconds due to float precision issues in the OpenAL Sound::AudioThread() function.
pull/137/head
scripticuk 5 years ago committed by GitHub
parent b539b144aa
commit e5a46836d3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 14
      Extensions/olcPGEX_Sound.h

@ -64,7 +64,7 @@
Author
~~~~~~
David Barr, aka javidx9, ©OneLoneCoder 2019
David Barr, aka javidx9, ©OneLoneCoder 2019
*/
@ -696,7 +696,7 @@ namespace olc
// User Process
for (unsigned int c = 0; c < m_nChannels; c++)
{
nNewSample = (short)(GetMixerOutput(c, m_fGlobalTime + fTimeStep * (float)n, fTimeStep), 1.0) * fMaxSample;
nNewSample = (short)(clip(GetMixerOutput(c, m_fGlobalTime + fTimeStep * (float)n, fTimeStep), 1.0) * fMaxSample);
m_pBlockMemory[n + c] = nNewSample;
nPreviousSample = nNewSample;
}
@ -838,14 +838,14 @@ namespace olc
// User Process
for (unsigned int c = 0; c < m_nChannels; c++)
{
nNewSample = (short)(clip(GetMixerOutput(c, m_fGlobalTime, fTimeStep), 1.0) * fMaxSample);
nNewSample = (short)(clip(GetMixerOutput(c, m_fGlobalTime + fTimeStep * (float)n, fTimeStep), 1.0) * fMaxSample);
m_pBlockMemory[n + c] = nNewSample;
nPreviousSample = nNewSample;
}
m_fGlobalTime = m_fGlobalTime + fTimeStep;
}
}
m_fGlobalTime = m_fGlobalTime + fTimeStep * (float)m_nBlockSamples;
// Fill OpenAL data buffer
alBufferData(
m_qAvailableBuffers.front(),
@ -903,4 +903,4 @@ namespace olc
#endif
#endif
#endif // OLC_PGEX_SOUND
#endif // OLC_PGEX_SOUND

Loading…
Cancel
Save