Minor audio sink tuning to better play sound when running emulation speeds > 100%. Added logic to prevent the audio sink from emtpying when emulation is paused. This provides a seemless transition when transitioning in/out of pause.
This commit is contained in:
parent
80ca06224b
commit
cd4d22cc6a
|
@ -47,6 +47,7 @@ static double noiseGate = 0.0;
|
|||
static double noiseGateRate = 0.010;
|
||||
static bool noiseGateActive = true;
|
||||
static bool muteSoundOutput = false;
|
||||
static bool fillInit = 1;
|
||||
|
||||
static int s_mute = 0;
|
||||
|
||||
|
@ -69,6 +70,34 @@ fillaudio(void *udata,
|
|||
int16 *tmps = (int16*)stream;
|
||||
len >>= 1;
|
||||
|
||||
if ( s_BufferIn > s_BufferSize25 )
|
||||
{
|
||||
fillInit = 0;
|
||||
}
|
||||
// If emulation is paused:
|
||||
// 1. preserve sound buffer as is
|
||||
// 2. fade from last known sample to zero
|
||||
// 3. activate noise gate to avoid popping when coming out of pause.
|
||||
if ( EmulationPaused || fillInit )
|
||||
{
|
||||
while ( len )
|
||||
{
|
||||
if ( sample > 0 )
|
||||
{
|
||||
sample--;
|
||||
}
|
||||
else if ( sample < 0 )
|
||||
{
|
||||
sample++;
|
||||
}
|
||||
*tmps = sample;
|
||||
tmps++;
|
||||
len--;
|
||||
}
|
||||
noiseGate = 0.0;
|
||||
noiseGateActive = 1;
|
||||
return;
|
||||
}
|
||||
mute = EmulationPaused || muteSoundOutput;
|
||||
|
||||
if ( mute || noiseGateActive )
|
||||
|
@ -106,7 +135,7 @@ fillaudio(void *udata,
|
|||
s_BufferRead = (s_BufferRead + 1) % s_BufferSize;
|
||||
s_BufferIn--;
|
||||
|
||||
*tmps = sample;
|
||||
*tmps = sample * noiseGate;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -210,6 +239,7 @@ InitSound()
|
|||
noiseGate = 0.0;
|
||||
noiseGateRate = 1.0 / (double)spec.samples;
|
||||
noiseGateActive = true;
|
||||
fillInit = 1;
|
||||
|
||||
s_Buffer = (int *)FCEU_dmalloc(sizeof(int) * s_BufferSize);
|
||||
|
||||
|
@ -294,7 +324,7 @@ WriteSound(int32 *buf,
|
|||
|
||||
if ( s_BufferIn >= s_BufferSize50 )
|
||||
{
|
||||
ovrFlowSkip += 100;
|
||||
ovrFlowSkip += 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -409,6 +439,8 @@ WriteSound(int32 *buf,
|
|||
SDL_LockAudio();
|
||||
}
|
||||
|
||||
//printf("%i >= %i \n", skipCounter, ovrFlowSkip );
|
||||
|
||||
if ( skipCounter >= ovrFlowSkip )
|
||||
{
|
||||
s_Buffer[s_BufferWrite] = *buf;
|
||||
|
|
Loading…
Reference in New Issue