aboutsummaryrefslogtreecommitdiffstats
path: root/Alc/ALc.c
diff options
context:
space:
mode:
authorChris Robinson <chris.kcat@gmail.com>2018-09-25 10:04:14 -0700
committerChris Robinson <chris.kcat@gmail.com>2018-09-25 10:04:14 -0700
commitc69338bc0dc338db7077a2c6759222ca4703f4eb (patch)
treef5836d8947bf0725e65f372e2d7b5d25815536eb /Alc/ALc.c
parent39c3314d0064f89147f21291ed1068cf83b18977 (diff)
Update the output limiter/compressor
This provides better characteristics for an amplitude limiter. In particular, it utilizes the peak amplitude instead of the RMS, and the used parameters basically guarantee no output samples exceed the given threshold... almost, due to floating-point errors as the threshold is converted from dB to log-e for the envelope, then is negated and converted to linear amplitude to apply to the signal. It's quite possible for some rounding errors to creep in and not perfectly saturate the result.
Diffstat (limited to 'Alc/ALc.c')
-rw-r--r--Alc/ALc.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/Alc/ALc.c b/Alc/ALc.c
index 9a1051c9..ecacf8c5 100644
--- a/Alc/ALc.c
+++ b/Alc/ALc.c
@@ -1706,8 +1706,9 @@ static void alcSetError(ALCdevice *device, ALCenum errorCode)
struct Compressor *CreateDeviceLimiter(const ALCdevice *device)
{
- return CompressorInit(0.0f, 0.0f, AL_FALSE, AL_TRUE, 0.0f, 0.0f, 0.5f, 2.0f,
- 0.0f, -3.0f, 3.0f, device->Frequency);
+ return CompressorInit(device->RealOut.NumChannels, device->Frequency,
+ AL_TRUE, AL_TRUE, AL_TRUE, AL_TRUE, AL_TRUE, 0.001f, 0.002f,
+ 0.0f, 0.0f, -0.0003f, INFINITY, 0.0f, 0.020f, 0.200f);
}
/* UpdateClockBase
@@ -2231,7 +2232,8 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const ALCint *attrList)
*/
if(gainLimiter != ALC_FALSE)
{
- if(!device->Limiter || device->Frequency != GetCompressorSampleRate(device->Limiter))
+ if(!device->Limiter || device->Frequency != GetCompressorSampleRate(device->Limiter) ||
+ device->RealOut.NumChannels != GetCompressorChannelCount(device->Limiter))
{
al_free(device->Limiter);
device->Limiter = CreateDeviceLimiter(device);