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 double noiseGateRate = 0.010;
|
||||||
static bool noiseGateActive = true;
|
static bool noiseGateActive = true;
|
||||||
static bool muteSoundOutput = false;
|
static bool muteSoundOutput = false;
|
||||||
|
static bool fillInit = 1;
|
||||||
|
|
||||||
static int s_mute = 0;
|
static int s_mute = 0;
|
||||||
|
|
||||||
|
@ -69,6 +70,34 @@ fillaudio(void *udata,
|
||||||
int16 *tmps = (int16*)stream;
|
int16 *tmps = (int16*)stream;
|
||||||
len >>= 1;
|
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;
|
mute = EmulationPaused || muteSoundOutput;
|
||||||
|
|
||||||
if ( mute || noiseGateActive )
|
if ( mute || noiseGateActive )
|
||||||
|
@ -106,7 +135,7 @@ fillaudio(void *udata,
|
||||||
s_BufferRead = (s_BufferRead + 1) % s_BufferSize;
|
s_BufferRead = (s_BufferRead + 1) % s_BufferSize;
|
||||||
s_BufferIn--;
|
s_BufferIn--;
|
||||||
|
|
||||||
*tmps = sample;
|
*tmps = sample * noiseGate;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -210,6 +239,7 @@ InitSound()
|
||||||
noiseGate = 0.0;
|
noiseGate = 0.0;
|
||||||
noiseGateRate = 1.0 / (double)spec.samples;
|
noiseGateRate = 1.0 / (double)spec.samples;
|
||||||
noiseGateActive = true;
|
noiseGateActive = true;
|
||||||
|
fillInit = 1;
|
||||||
|
|
||||||
s_Buffer = (int *)FCEU_dmalloc(sizeof(int) * s_BufferSize);
|
s_Buffer = (int *)FCEU_dmalloc(sizeof(int) * s_BufferSize);
|
||||||
|
|
||||||
|
@ -294,7 +324,7 @@ WriteSound(int32 *buf,
|
||||||
|
|
||||||
if ( s_BufferIn >= s_BufferSize50 )
|
if ( s_BufferIn >= s_BufferSize50 )
|
||||||
{
|
{
|
||||||
ovrFlowSkip += 100;
|
ovrFlowSkip += 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -409,6 +439,8 @@ WriteSound(int32 *buf,
|
||||||
SDL_LockAudio();
|
SDL_LockAudio();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//printf("%i >= %i \n", skipCounter, ovrFlowSkip );
|
||||||
|
|
||||||
if ( skipCounter >= ovrFlowSkip )
|
if ( skipCounter >= ovrFlowSkip )
|
||||||
{
|
{
|
||||||
s_Buffer[s_BufferWrite] = *buf;
|
s_Buffer[s_BufferWrite] = *buf;
|
||||||
|
|
Loading…
Reference in New Issue