aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2014-05-03 17:51:06 -0700
committerChris Robinson <[email protected]>2014-05-03 17:51:06 -0700
commitb2e533fbfc3c61bbf3936750e85039f9f664f007 (patch)
tree8ae5aa0a168ac979b40d7dc7c74c409b055823c9
parent34e96aef601e8e417bbc61708d68e5f6bbd2842e (diff)
Clamp the current and target gain lower bound to epsilon
Should give a bit more wiggle room for the gain stepping to get lower than the silence threshold.
-rw-r--r--Alc/ALu.c20
-rw-r--r--OpenAL32/Include/alu.h2
2 files changed, 11 insertions, 11 deletions
diff --git a/Alc/ALu.c b/Alc/ALu.c
index 560c9a58..4bff7525 100644
--- a/Alc/ALu.c
+++ b/Alc/ALu.c
@@ -437,8 +437,8 @@ ALvoid CalcNonAttnSourceParams(ALactivesource *src, const ALCcontext *ALContext)
{
for(j = 0;j < MaxChannels;j++)
{
- ALfloat cur = maxf(Current[i][j], GAIN_SILENCE_THRESHOLD);
- ALfloat trg = maxf(Matrix[i][j], GAIN_SILENCE_THRESHOLD);
+ ALfloat cur = maxf(Current[i][j], FLT_EPSILON);
+ ALfloat trg = maxf(Matrix[i][j], FLT_EPSILON);
if(fabs(trg - cur) >= GAIN_SILENCE_THRESHOLD)
Step[i][j] = powf(trg/cur, 1.0f/64.0f);
else
@@ -527,8 +527,8 @@ ALvoid CalcNonAttnSourceParams(ALactivesource *src, const ALCcontext *ALContext)
{
for(j = 0;j < MaxChannels;j++)
{
- ALfloat trg = maxf(Matrix[i][j], GAIN_SILENCE_THRESHOLD);
- ALfloat cur = maxf(Current[i][j], GAIN_SILENCE_THRESHOLD);
+ ALfloat trg = maxf(Matrix[i][j], FLT_EPSILON);
+ ALfloat cur = maxf(Current[i][j], FLT_EPSILON);
if(fabs(trg - cur) >= GAIN_SILENCE_THRESHOLD)
Step[i][j] = powf(trg/cur, 1.0f/64.0f);
else
@@ -560,8 +560,8 @@ ALvoid CalcNonAttnSourceParams(ALactivesource *src, const ALCcontext *ALContext)
{
if(src->Send[i].Moving)
{
- ALfloat cur = maxf(src->Send[i].Gain.Current, GAIN_SILENCE_THRESHOLD);
- ALfloat trg = maxf(src->Send[i].Gain.Target, GAIN_SILENCE_THRESHOLD);
+ ALfloat cur = maxf(src->Send[i].Gain.Current, FLT_EPSILON);
+ ALfloat trg = maxf(src->Send[i].Gain.Target, FLT_EPSILON);
if(fabs(trg - cur) >= GAIN_SILENCE_THRESHOLD)
src->Send[i].Gain.Step = powf(trg/cur, 1.0f/64.0f);
else
@@ -1025,8 +1025,8 @@ ALvoid CalcSourceParams(ALactivesource *src, const ALCcontext *ALContext)
ALfloat (*restrict Step)[MaxChannels] = src->Direct.Mix.Gains.Step;
for(j = 0;j < MaxChannels;j++)
{
- ALfloat cur = maxf(Current[0][j], GAIN_SILENCE_THRESHOLD);
- ALfloat trg = maxf(Matrix[0][j], GAIN_SILENCE_THRESHOLD);
+ ALfloat cur = maxf(Current[0][j], FLT_EPSILON);
+ ALfloat trg = maxf(Matrix[0][j], FLT_EPSILON);
if(fabs(trg - cur) >= GAIN_SILENCE_THRESHOLD)
Step[0][j] = powf(trg/cur, 1.0f/64.0f);
else
@@ -1057,8 +1057,8 @@ ALvoid CalcSourceParams(ALactivesource *src, const ALCcontext *ALContext)
{
if(src->Send[i].Moving)
{
- ALfloat cur = maxf(src->Send[i].Gain.Current, GAIN_SILENCE_THRESHOLD);
- ALfloat trg = maxf(src->Send[i].Gain.Target, GAIN_SILENCE_THRESHOLD);
+ ALfloat cur = maxf(src->Send[i].Gain.Current, FLT_EPSILON);
+ ALfloat trg = maxf(src->Send[i].Gain.Target, FLT_EPSILON);
if(fabs(trg - cur) >= GAIN_SILENCE_THRESHOLD)
src->Send[i].Gain.Step = powf(trg/cur, 1.0f/64.0f);
else
diff --git a/OpenAL32/Include/alu.h b/OpenAL32/Include/alu.h
index f931b737..bf2a7f77 100644
--- a/OpenAL32/Include/alu.h
+++ b/OpenAL32/Include/alu.h
@@ -111,7 +111,7 @@ typedef ALvoid (*WetMixerFunc)(struct SendParams *params,
ALuint OutPos, ALuint BufferSize);
-#define GAIN_SILENCE_THRESHOLD (0.00001f)
+#define GAIN_SILENCE_THRESHOLD (0.00001f) /* -100dB */
#define SPEEDOFSOUNDMETRESPERSEC (343.3f)
#define AIRABSORBGAINHF (0.99426f) /* -0.05dB */