From 81d401eab55792ece0c664db96f0390d9d0cbded Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Sat, 30 Jul 2011 05:43:47 -0700 Subject: Use specialized click removal loops for mono and stereo output --- Alc/ALu.c | 44 +++++++++++++++++++++++++++++++++++++------- 1 file changed, 37 insertions(+), 7 deletions(-) diff --git a/Alc/ALu.c b/Alc/ALu.c index ecf2c687..1ba71129 100644 --- a/Alc/ALu.c +++ b/Alc/ALu.c @@ -1057,18 +1057,48 @@ ALvoid aluMixData(ALCdevice *device, ALvoid *buffer, ALsizei size) UnlockDevice(device); //Post processing loop - for(i = 0;i < SamplesToDo;i++) + if(device->FmtChans == DevFmtMono) { - for(c = 0;c < MAXCHANNELS;c++) + for(i = 0;i < SamplesToDo;i++) { - device->DryBuffer[i][c] += device->ClickRemoval[c]; - device->ClickRemoval[c] -= device->ClickRemoval[c] / 256.0f; + device->DryBuffer[i][FRONT_CENTER] += device->ClickRemoval[FRONT_CENTER]; + device->ClickRemoval[FRONT_CENTER] -= device->ClickRemoval[FRONT_CENTER] / 256.0f; } + device->ClickRemoval[FRONT_CENTER] += device->PendingClicks[FRONT_CENTER]; + device->PendingClicks[FRONT_CENTER] = 0.0f; } - for(i = 0;i < MAXCHANNELS;i++) + else if(device->FmtChans == DevFmtStereo) { - device->ClickRemoval[i] += device->PendingClicks[i]; - device->PendingClicks[i] = 0.0f; + /* Assumes the first two channels are FRONT_LEFT and FRONT_RIGHT */ + for(i = 0;i < SamplesToDo;i++) + { + for(c = 0;c < 2;c++) + { + device->DryBuffer[i][c] += device->ClickRemoval[c]; + device->ClickRemoval[c] -= device->ClickRemoval[c] / 256.0f; + } + } + for(c = 0;c < 2;c++) + { + device->ClickRemoval[c] += device->PendingClicks[c]; + device->PendingClicks[c] = 0.0f; + } + } + else + { + for(i = 0;i < SamplesToDo;i++) + { + for(c = 0;c < MAXCHANNELS;c++) + { + device->DryBuffer[i][c] += device->ClickRemoval[c]; + device->ClickRemoval[c] -= device->ClickRemoval[c] / 256.0f; + } + } + for(c = 0;c < MAXCHANNELS;c++) + { + device->ClickRemoval[c] += device->PendingClicks[c]; + device->PendingClicks[c] = 0.0f; + } } switch(device->FmtType) -- cgit v1.2.3