Use a macro for the silence threshold

This commit is contained in:
Chris Robinson 2013-10-06 17:25:47 -07:00
parent 6425480d40
commit 79edd2cf3b
13 changed files with 28 additions and 25 deletions

View File

@ -155,7 +155,7 @@ static ALvoid ALautowahState_process(ALautowahState *state, ALuint SamplesToDo,
for(kt = 0;kt < MaxChannels;kt++)
{
ALfloat gain = state->Gain[kt];
if(!(gain > 0.00001f))
if(!(gain > GAIN_SILENCE_THRESHOLD))
continue;
for(it = 0;it < td;it++)

View File

@ -203,14 +203,14 @@ static void Process##func(ALchorusState *state, ALuint SamplesToDo, \
for(kt = 0;kt < MaxChannels;kt++) \
{ \
ALfloat gain = state->Gain[0][kt]; \
if(gain > 0.00001f) \
if(gain > GAIN_SILENCE_THRESHOLD) \
{ \
for(it = 0;it < td;it++) \
SamplesOut[kt][it+base] += temps[it][0] * gain; \
} \
\
gain = state->Gain[1][kt]; \
if(gain > 0.00001f) \
if(gain > GAIN_SILENCE_THRESHOLD) \
{ \
for(it = 0;it < td;it++) \
SamplesOut[kt][it+base] += temps[it][1] * gain; \

View File

@ -117,7 +117,7 @@ static ALvoid ALcompressorState_process(ALcompressorState *state, ALuint Samples
for(kt = 0;kt < MaxChannels;kt++)
{
ALfloat gain = state->Gain[kt] * envgain * 2.0f;
if(!(gain > 0.00001f))
if(!(gain > GAIN_SILENCE_THRESHOLD))
continue;
for(it = 0;it < td;it++)

View File

@ -78,7 +78,7 @@ static ALvoid ALdedicatedState_process(ALdedicatedState *state, ALuint SamplesTo
for(c = 0;c < MaxChannels;c++)
{
if(!(gains[c] > 0.00001f))
if(!(gains[c] > GAIN_SILENCE_THRESHOLD))
continue;
for(i = 0;i < SamplesToDo;i++)

View File

@ -169,7 +169,7 @@ static ALvoid ALdistortionState_process(ALdistortionState *state, ALuint Samples
for(kt = 0;kt < MaxChannels;kt++)
{
ALfloat gain = state->Gain[kt];
if(!(gain > 0.00001f))
if(!(gain > GAIN_SILENCE_THRESHOLD))
continue;
for(it = 0;it < td;it++)

View File

@ -148,14 +148,14 @@ static ALvoid ALechoState_process(ALechoState *state, ALuint SamplesToDo, const
for(k = 0;k < MaxChannels;k++)
{
ALfloat gain = state->Gain[0][k];
if(gain > 0.00001f)
if(gain > GAIN_SILENCE_THRESHOLD)
{
for(i = 0;i < td;i++)
SamplesOut[k][i+base] += temps[i][0] * gain;
}
gain = state->Gain[1][k];
if(gain > 0.00001f)
if(gain > GAIN_SILENCE_THRESHOLD)
{
for(i = 0;i < td;i++)
SamplesOut[k][i+base] += temps[i][1] * gain;

View File

@ -154,7 +154,7 @@ static ALvoid ALequalizerState_process(ALequalizerState *state, ALuint SamplesTo
for(kt = 0;kt < MaxChannels;kt++)
{
ALfloat gain = state->Gain[kt];
if(!(gain > 0.00001f))
if(!(gain > GAIN_SILENCE_THRESHOLD))
continue;
for(it = 0;it < td;it++)

View File

@ -203,14 +203,14 @@ static void Process##func(ALflangerState *state, ALuint SamplesToDo, \
for(kt = 0;kt < MaxChannels;kt++) \
{ \
ALfloat gain = state->Gain[0][kt]; \
if(gain > 0.00001f) \
if(gain > GAIN_SILENCE_THRESHOLD) \
{ \
for(it = 0;it < td;it++) \
SamplesOut[kt][it+base] += temps[it][0] * gain; \
} \
\
gain = state->Gain[1][kt]; \
if(gain > 0.00001f) \
if(gain > GAIN_SILENCE_THRESHOLD) \
{ \
for(it = 0;it < td;it++) \
SamplesOut[kt][it+base] += temps[it][1] * gain; \

View File

@ -102,7 +102,7 @@ static void Process##func(ALmodulatorState *state, ALuint SamplesToDo, \
for(k = 0;k < MaxChannels;k++) \
{ \
ALfloat gain = state->Gain[k]; \
if(!(gain > 0.00001f)) \
if(!(gain > GAIN_SILENCE_THRESHOLD)) \
continue; \
\
for(i = 0;i < td;i++) \

View File

@ -575,11 +575,11 @@ static ALvoid ALreverbState_processStandard(ALreverbState *State, ALuint Samples
for(c = 0;c < MaxChannels;c++)
{
ALfloat gain = State->Gain[c];
if(gain > 0.00001f)
{
for(index = 0;index < SamplesToDo;index++)
SamplesOut[c][index] += gain * out[index][c&3];
}
if(!(gain > GAIN_SILENCE_THRESHOLD))
continue;
for(index = 0;index < SamplesToDo;index++)
SamplesOut[c][index] += gain * out[index][c&3];
}
}
@ -595,15 +595,16 @@ static ALvoid ALreverbState_processEax(ALreverbState *State, ALuint SamplesToDo,
for(c = 0;c < MaxChannels;c++)
{
ALfloat earlyGain = State->Early.PanGain[c];
ALfloat lateGain = State->Late.PanGain[c];
ALfloat earlyGain, lateGain;
if(earlyGain > 0.00001f)
earlyGain = State->Early.PanGain[c];
if(earlyGain > GAIN_SILENCE_THRESHOLD)
{
for(index = 0;index < SamplesToDo;index++)
SamplesOut[c][index] += earlyGain*early[index][c&3];
}
if(lateGain > 0.00001f)
lateGain = State->Late.PanGain[c];
if(lateGain > GAIN_SILENCE_THRESHOLD)
{
for(index = 0;index < SamplesToDo;index++)
SamplesOut[c][index] += lateGain*late[index][c&3];

View File

@ -96,7 +96,7 @@ void MixDirect_C(const DirectParams *params, const ALfloat *restrict data, ALuin
for(c = 0;c < MaxChannels;c++)
{
DrySend = params->Gains[srcchan][c];
if(!(DrySend > 0.00001f))
if(!(DrySend > GAIN_SILENCE_THRESHOLD))
continue;
if(OutPos == 0)
@ -119,7 +119,7 @@ void MixSend_C(const SendParams *params, const ALfloat *restrict data,
ALuint pos;
WetSend = params->Gain;
if(!(WetSend > 0.00001f))
if(!(WetSend > GAIN_SILENCE_THRESHOLD))
return;
if(OutPos == 0)

View File

@ -154,7 +154,7 @@ void MixDirect_SSE(const DirectParams *params, const ALfloat *restrict data, ALu
for(c = 0;c < MaxChannels;c++)
{
DrySend = params->Gains[srcchan][c];
if(!(DrySend > 0.00001f))
if(!(DrySend > GAIN_SILENCE_THRESHOLD))
continue;
if(OutPos == 0)
@ -188,7 +188,7 @@ void MixSend_SSE(const SendParams *params, const ALfloat *restrict data,
ALuint pos;
WetGain = params->Gain;
if(!(WetGain > 0.00001f))
if(!(WetGain > GAIN_SILENCE_THRESHOLD))
return;
if(OutPos == 0)

View File

@ -43,6 +43,8 @@ typedef ALvoid (*WetMixerFunc)(const struct SendParams *params,
ALuint BufferSize);
#define GAIN_SILENCE_THRESHOLD (0.00001f)
#define SPEEDOFSOUNDMETRESPERSEC (343.3f)
#define AIRABSORBGAINHF (0.99426f) /* -0.05dB */