diff options
Diffstat (limited to 'Alc')
-rw-r--r-- | Alc/ALu.c | 31 | ||||
-rw-r--r-- | Alc/alcReverb.c | 13 | ||||
-rw-r--r-- | Alc/hrtf.c | 14 |
3 files changed, 21 insertions, 37 deletions
@@ -180,9 +180,7 @@ ALvoid CalcNonAttnSourceParams(ALsource *ALSource, const ALCcontext *ALContext) } /* Calculate gains */ - DryGain = SourceVolume; - DryGain = __min(DryGain,MaxVolume); - DryGain = __max(DryGain,MinVolume); + DryGain = clampF(SourceVolume, MinVolume, MaxVolume); DryGainHF = 1.0f; switch(ALSource->DirectFilter.type) { @@ -193,9 +191,7 @@ ALvoid CalcNonAttnSourceParams(ALsource *ALSource, const ALCcontext *ALContext) } for(i = 0;i < NumSends;i++) { - WetGain[i] = SourceVolume; - WetGain[i] = __min(WetGain[i],MaxVolume); - WetGain[i] = __max(WetGain[i],MinVolume); + WetGain[i] = clampF(SourceVolume, MinVolume, MaxVolume); WetGainHF[i] = 1.0f; switch(ALSource->Send[i].WetFilter.type) { @@ -501,8 +497,7 @@ ALvoid CalcSourceParams(ALsource *ALSource, const ALCcontext *ALContext) ALContext->DistanceModel) { case InverseDistanceClamped: - ClampedDist=__max(ClampedDist,MinDist); - ClampedDist=__min(ClampedDist,MaxDist); + ClampedDist = clampF(ClampedDist, MinDist, MaxDist); if(MaxDist < MinDist) break; //fall-through @@ -520,8 +515,7 @@ ALvoid CalcSourceParams(ALsource *ALSource, const ALCcontext *ALContext) break; case LinearDistanceClamped: - ClampedDist=__max(ClampedDist,MinDist); - ClampedDist=__min(ClampedDist,MaxDist); + ClampedDist = clampF(ClampedDist, MinDist, MaxDist); if(MaxDist < MinDist) break; //fall-through @@ -529,18 +523,17 @@ ALvoid CalcSourceParams(ALsource *ALSource, const ALCcontext *ALContext) if(MaxDist != MinDist) { Attenuation = 1.0f - (Rolloff*(ClampedDist-MinDist)/(MaxDist - MinDist)); - Attenuation = __max(Attenuation, 0.0f); + Attenuation = maxF(Attenuation, 0.0f); for(i = 0;i < NumSends;i++) { RoomAttenuation[i] = 1.0f - (RoomRolloff[i]*(ClampedDist-MinDist)/(MaxDist - MinDist)); - RoomAttenuation[i] = __max(RoomAttenuation[i], 0.0f); + RoomAttenuation[i] = maxF(RoomAttenuation[i], 0.0f); } } break; case ExponentDistanceClamped: - ClampedDist=__max(ClampedDist,MinDist); - ClampedDist=__min(ClampedDist,MaxDist); + ClampedDist = clampF(ClampedDist, MinDist, MaxDist); if(MaxDist < MinDist) break; //fall-through @@ -608,13 +601,9 @@ ALvoid CalcSourceParams(ALsource *ALSource, const ALCcontext *ALContext) } // Clamp to Min/Max Gain - DryGain = __min(DryGain,MaxVolume); - DryGain = __max(DryGain,MinVolume); + DryGain = clampF(DryGain, MinVolume, MaxVolume); for(i = 0;i < NumSends;i++) - { - WetGain[i] = __min(WetGain[i],MaxVolume); - WetGain[i] = __max(WetGain[i],MinVolume); - } + WetGain[i] = clampF(WetGain[i], MinVolume, MaxVolume); // Apply filter gains and filters switch(ALSource->DirectFilter.type) @@ -772,7 +761,7 @@ ALvoid CalcSourceParams(ALsource *ALSource, const ALCcontext *ALContext) ALfloat length; ALint pos; - length = __max(Distance, MinDist); + length = maxF(Distance, MinDist); if(length > 0.0f) { ALfloat invlen = 1.0f/length; diff --git a/Alc/alcReverb.c b/Alc/alcReverb.c index 4f9360b8..e4fb4ebf 100644 --- a/Alc/alcReverb.c +++ b/Alc/alcReverb.c @@ -388,13 +388,10 @@ static ALfloat CalcLimitedHfRatio(ALfloat hfRatio, ALfloat airAbsorptionGainHF, */ limitRatio = 1.0f / (CalcDecayLength(airAbsorptionGainHF, decayTime) * SPEEDOFSOUNDMETRESPERSEC); - // Need to limit the result to a minimum of 0.1, just like the HF ratio - // parameter. - limitRatio = __max(limitRatio, 0.1f); - - // Using the limit calculated above, apply the upper bound to the HF - // ratio. - return __min(hfRatio, limitRatio); + /* Using the limit calculated above, apply the upper bound to the HF + * ratio. Also need to limit the result to a minimum of 0.1, just like the + * HF ratio parameter. */ + return clampF(limitRatio, 0.1f, hfRatio); } // Calculate the coefficient for a HF (and eventually LF) decay damping @@ -418,7 +415,7 @@ static __inline ALfloat CalcDampingCoeff(ALfloat hfRatio, ALfloat length, ALfloa // Very low decay times will produce minimal output, so apply an // upper bound to the coefficient. - coeff = __min(coeff, 0.98f); + coeff = minF(coeff, 0.98f); } return coeff; } @@ -65,7 +65,7 @@ static void CalcEvIndices(ALfloat ev, ALuint *evidx, ALfloat *evmu) { ev = (M_PI/2.0f + ev) * (ELEV_COUNT-1) / M_PI; evidx[0] = (ALuint)ev; - evidx[1] = __min(evidx[0] + 1, ELEV_COUNT-1); + evidx[1] = minF(evidx[0] + 1, ELEV_COUNT-1); *evmu = ev - evidx[0]; } @@ -86,11 +86,11 @@ static void CalcAzIndices(ALuint evidx, ALfloat az, ALuint *azidx, ALfloat *azmu // values. ALfloat CalcHrtfDelta(ALfloat oldGain, ALfloat newGain, const ALfloat olddir[3], const ALfloat newdir[3]) { - ALfloat gainChange, angleChange, delta; + ALfloat gainChange, angleChange; // Calculate the normalized dB gain change. - newGain = __max(newGain, 0.0001f); - oldGain = __max(oldGain, 0.0001f); + newGain = maxF(newGain, 0.0001f); + oldGain = maxF(oldGain, 0.0001f); gainChange = aluFabs(log10(newGain / oldGain) / log10(0.0001f)); // Calculate the normalized listener to source angle change when there is @@ -109,8 +109,7 @@ ALfloat CalcHrtfDelta(ALfloat oldGain, ALfloat newGain, const ALfloat olddir[3], // Use the largest of the two changes for the delta factor, and apply a // significance shaping function to it. - delta = __max(gainChange, angleChange) * 2.0f; - return __min(delta, 1.0f); + return clampF(angleChange*2.0f, gainChange*2.0f, 1.0f); } // Calculates static HRIR coefficients and delays for the given polar @@ -224,8 +223,7 @@ ALuint GetMovingHrtfCoeffs(ALfloat elevation, ALfloat azimuth, ALfloat gain, ALf ridx[3] = evOffset[evidx[1]] + ((azCount[evidx[1]]-azidx[1]) % azCount[evidx[1]]); // Calculate the stepping parameters. - delta = floor(delta*(Hrtf.sampleRate*0.015f) + 0.5); - delta = __max(delta, 1.0f); + delta = maxF(floor(delta*(Hrtf.sampleRate*0.015f) + 0.5), 1.0f); step = 1.0f / delta; // Calculate the normalized and attenuated target HRIR coefficients using |