aboutsummaryrefslogtreecommitdiffstats
path: root/Alc
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2010-08-14 21:30:14 -0700
committerChris Robinson <[email protected]>2010-08-14 21:30:14 -0700
commitb65bc4523653017dfc7b910ebafcb213714fcb0c (patch)
treeb2c00466b501ba4bfb8039139b4eec2d7cea802d /Alc
parent94b7e5a227b03fb4c77064a09da834a63286c4e8 (diff)
Add a corrective, click-remval sample value offset
This will hopefully be more effective and rebust at removing clicks and pops, particularly from starts and stops in the middle of a sound. Based on an idea by Ben Davis.
Diffstat (limited to 'Alc')
-rw-r--r--Alc/ALc.c3
-rw-r--r--Alc/mixer.c11
2 files changed, 14 insertions, 0 deletions
diff --git a/Alc/ALc.c b/Alc/ALc.c
index 72106824..7e94895b 100644
--- a/Alc/ALc.c
+++ b/Alc/ALc.c
@@ -901,6 +901,9 @@ static ALCboolean UpdateDeviceParams(ALCdevice *device, const ALCint *attrList)
device->SamplesPlayed += oldRate-1;
device->SamplesPlayed /= oldRate;
+ for(i = 0;i < OUTPUTCHANNELS;i++)
+ device->ClickRemoval[i] = 0.0f;
+
for(i = 0;i < device->NumContexts;i++)
{
ALCcontext *context = device->Contexts[i];
diff --git a/Alc/mixer.c b/Alc/mixer.c
index 64b4a13a..08b501c4 100644
--- a/Alc/mixer.c
+++ b/Alc/mixer.c
@@ -534,6 +534,7 @@ ALvoid aluMixData(ALCdevice *device, ALvoid *buffer, ALsizei size)
{
float (*DryBuffer)[OUTPUTCHANNELS];
ALfloat (*Matrix)[OUTPUTCHANNELS];
+ ALfloat *ClickRemoval;
const ALuint *ChanMap;
ALuint SamplesToDo;
ALeffectslot *ALEffectSlot;
@@ -597,6 +598,16 @@ ALvoid aluMixData(ALCdevice *device, ALvoid *buffer, ALsizei size)
ProcessContext(NULL);
//Post processing loop
+ ClickRemoval = device->ClickRemoval;
+ for(i = 0;i < SamplesToDo;i++)
+ {
+ for(c = 0;c < OUTPUTCHANNELS;c++)
+ {
+ ClickRemoval[c] -= ClickRemoval[c] / 256.0f;
+ DryBuffer[i][c] += ClickRemoval[c];
+ }
+ }
+
ChanMap = device->DevChannels;
Matrix = device->ChannelMatrix;
switch(device->Format)