aboutsummaryrefslogtreecommitdiffstats
path: root/Alc/mixvoice.cpp
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2018-12-01 23:25:34 -0800
committerChris Robinson <[email protected]>2018-12-01 23:25:34 -0800
commit607fb3e632ecc218a5739709805bc4d83760a1c9 (patch)
tree903e9c26e378a9c99689ed303ed8284206272740 /Alc/mixvoice.cpp
parente1af866a3df96b5af3173c5ce85ebba25841dc4d (diff)
Use a lambda to apply the NFC mixes
Diffstat (limited to 'Alc/mixvoice.cpp')
-rw-r--r--Alc/mixvoice.cpp37
1 files changed, 18 insertions, 19 deletions
diff --git a/Alc/mixvoice.cpp b/Alc/mixvoice.cpp
index b873a744..02e31266 100644
--- a/Alc/mixvoice.cpp
+++ b/Alc/mixvoice.cpp
@@ -537,30 +537,29 @@ ALboolean MixSource(ALvoice *voice, ALuint SourceID, ALCcontext *Context, ALsize
);
else
{
- ALfloat *nfcsamples = Device->TempBuffer[NFC_DATA_BUF];
- ALsizei chanoffset = 0;
-
MixSamples(samples,
voice->Direct.ChannelsPerOrder[0], voice->Direct.Buffer,
parms->Gains.Current, parms->Gains.Target, Counter, OutPos,
DstBufferSize
);
- chanoffset += voice->Direct.ChannelsPerOrder[0];
-#define APPLY_NFC_MIX(order) \
- if(voice->Direct.ChannelsPerOrder[order] > 0) \
- { \
- NfcFilterProcess##order(&parms->NFCtrlFilter, nfcsamples, samples, \
- DstBufferSize); \
- MixSamples(nfcsamples, voice->Direct.ChannelsPerOrder[order], \
- voice->Direct.Buffer+chanoffset, parms->Gains.Current+chanoffset, \
- parms->Gains.Target+chanoffset, Counter, OutPos, DstBufferSize \
- ); \
- chanoffset += voice->Direct.ChannelsPerOrder[order]; \
- }
- APPLY_NFC_MIX(1)
- APPLY_NFC_MIX(2)
- APPLY_NFC_MIX(3)
-#undef APPLY_NFC_MIX
+
+ ALfloat *nfcsamples{Device->TempBuffer[NFC_DATA_BUF]};
+ ALsizei chanoffset{voice->Direct.ChannelsPerOrder[0]};
+ using FilterProc = void(NfcFilter*,ALfloat*,const ALfloat*,ALsizei);
+ auto apply_nfc = [voice,parms,samples,DstBufferSize,Counter,OutPos,&chanoffset,nfcsamples](FilterProc &process, ALsizei order) -> void
+ {
+ if(voice->Direct.ChannelsPerOrder[order] < 1)
+ return;
+ process(&parms->NFCtrlFilter, nfcsamples, samples, DstBufferSize);
+ MixSamples(nfcsamples, voice->Direct.ChannelsPerOrder[order],
+ voice->Direct.Buffer+chanoffset, parms->Gains.Current+chanoffset,
+ parms->Gains.Target+chanoffset, Counter, OutPos, DstBufferSize
+ );
+ chanoffset += voice->Direct.ChannelsPerOrder[order];
+ };
+ apply_nfc(NfcFilterProcess1, 1);
+ apply_nfc(NfcFilterProcess2, 2);
+ apply_nfc(NfcFilterProcess3, 3);
}
}
else