aboutsummaryrefslogtreecommitdiffstats
path: root/Alc/ALc.c
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2017-05-27 03:36:34 -0700
committerChris Robinson <[email protected]>2017-05-27 03:36:34 -0700
commitc4ef7399f84f4085ceb77f9897f9c9502d2cfd0d (patch)
tree5cd6863602b9c569c8aeb99a08fcfd00cb4f864c /Alc/ALc.c
parent653f0a1405b5dbceab6c2d8adc8fa246bdb5f607 (diff)
Add a new compressor/limiter
This is just for the output limiter right now, but in the future can be used for the compressor EFX effect. The parameters are also hardcoded, but can be made configurable after 1.18.
Diffstat (limited to 'Alc/ALc.c')
-rw-r--r--Alc/ALc.c21
1 files changed, 17 insertions, 4 deletions
diff --git a/Alc/ALc.c b/Alc/ALc.c
index 0e821b35..dcda29c3 100644
--- a/Alc/ALc.c
+++ b/Alc/ALc.c
@@ -1738,6 +1738,12 @@ 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, -0.5f, 3.0f, device->Frequency);
+}
+
/* UpdateClockBase
*
* Updates the device's base clock time with however many samples have been
@@ -2224,8 +2230,11 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const ALCint *attrList)
*/
if(gainLimiter != ALC_FALSE)
{
- if(!device->Limiter)
- device->Limiter = alloc_limiter();
+ if(!device->Limiter || device->Frequency != GetCompressorSampleRate(device->Limiter))
+ {
+ al_free(device->Limiter);
+ device->Limiter = CreateDeviceLimiter(device);
+ }
}
else
{
@@ -3845,7 +3854,7 @@ ALC_API ALCdevice* ALC_APIENTRY alcOpenDevice(const ALCchar *deviceName)
device->FOAOut.NumChannels = 0;
device->RealOut.Buffer = NULL;
device->RealOut.NumChannels = 0;
- device->Limiter = alloc_limiter();
+ device->Limiter = NULL;
device->AvgSpeakerDist = 0.0f;
ATOMIC_INIT(&device->ContextList, NULL);
@@ -4021,6 +4030,8 @@ ALC_API ALCdevice* ALC_APIENTRY alcOpenDevice(const ALCchar *deviceName)
alstr_get_cstr(device->DeviceName), NULL, "dither", 1
);
+ device->Limiter = CreateDeviceLimiter(device);
+
if(DefaultEffect.type != AL_EFFECT_NULL)
{
device->DefaultSlot = (ALeffectslot*)device->_slot_mem;
@@ -4378,7 +4389,7 @@ ALC_API ALCdevice* ALC_APIENTRY alcLoopbackOpenDeviceSOFT(const ALCchar *deviceN
device->FOAOut.NumChannels = 0;
device->RealOut.Buffer = NULL;
device->RealOut.NumChannels = 0;
- device->Limiter = alloc_limiter();
+ device->Limiter = NULL;
device->AvgSpeakerDist = 0.0f;
ATOMIC_INIT(&device->ContextList, NULL);
@@ -4441,6 +4452,8 @@ ALC_API ALCdevice* ALC_APIENTRY alcLoopbackOpenDeviceSOFT(const ALCchar *deviceN
device->DitherEnabled = GetConfigValueBool(NULL, NULL, "dither", 1);
+ device->Limiter = CreateDeviceLimiter(device);
+
{
ALCdevice *head = ATOMIC_LOAD_SEQ(&DeviceList);
do {