Remove the now-unused Source parameter from the DryMix methods
[openal-soft.git] / Alc / mixer_c.c
blob39bf260c445dc521e91390ddb0dece307c86f12c
1 #include "config.h"
3 #include <assert.h>
5 #include "alMain.h"
6 #include "alu.h"
7 #include "alSource.h"
8 #include "alAuxEffectSlot.h"
11 static __inline ALfloat point32(const ALfloat *vals, ALuint frac)
12 { return vals[0]; (void)frac; }
13 static __inline ALfloat lerp32(const ALfloat *vals, ALuint frac)
14 { return lerp(vals[0], vals[1], frac * (1.0f/FRACTIONONE)); }
15 static __inline ALfloat cubic32(const ALfloat *vals, ALuint frac)
16 { return cubic(vals[-1], vals[0], vals[1], vals[2], frac * (1.0f/FRACTIONONE)); }
18 void Resample_copy32_C(const ALfloat *data, ALuint frac,
19 ALuint increment, ALfloat *RESTRICT OutBuffer, ALuint BufferSize)
21 (void)frac;
22 assert(increment==FRACTIONONE);
23 memcpy(OutBuffer, data, (BufferSize+1)*sizeof(ALfloat));
26 #define DECL_TEMPLATE(Sampler) \
27 void Resample_##Sampler##_C(const ALfloat *data, ALuint frac, \
28 ALuint increment, ALfloat *RESTRICT OutBuffer, ALuint BufferSize) \
29 { \
30 ALuint pos = 0; \
31 ALuint i; \
33 for(i = 0;i < BufferSize+1;i++) \
34 { \
35 OutBuffer[i] = Sampler(data + pos, frac); \
37 frac += increment; \
38 pos += frac>>FRACTIONBITS; \
39 frac &= FRACTIONMASK; \
40 } \
43 DECL_TEMPLATE(point32)
44 DECL_TEMPLATE(lerp32)
45 DECL_TEMPLATE(cubic32)
47 #undef DECL_TEMPLATE
50 static __inline void ApplyCoeffsStep(ALuint Offset, ALfloat (*RESTRICT Values)[2],
51 const ALuint IrSize,
52 ALfloat (*RESTRICT Coeffs)[2],
53 ALfloat (*RESTRICT CoeffStep)[2],
54 ALfloat left, ALfloat right)
56 ALuint c;
57 for(c = 0;c < IrSize;c++)
59 const ALuint off = (Offset+c)&HRIR_MASK;
60 Values[off][0] += Coeffs[c][0] * left;
61 Values[off][1] += Coeffs[c][1] * right;
62 Coeffs[c][0] += CoeffStep[c][0];
63 Coeffs[c][1] += CoeffStep[c][1];
67 static __inline void ApplyCoeffs(ALuint Offset, ALfloat (*RESTRICT Values)[2],
68 const ALuint IrSize,
69 ALfloat (*RESTRICT Coeffs)[2],
70 ALfloat left, ALfloat right)
72 ALuint c;
73 for(c = 0;c < IrSize;c++)
75 const ALuint off = (Offset+c)&HRIR_MASK;
76 Values[off][0] += Coeffs[c][0] * left;
77 Values[off][1] += Coeffs[c][1] * right;
81 #define SUFFIX C
82 #include "mixer_inc.c"
83 #undef SUFFIX
86 void MixDirect_C(ALCdevice *Device, DirectParams *params,
87 const ALfloat *RESTRICT data, ALuint srcchan,
88 ALuint OutPos, ALuint SamplesToDo, ALuint BufferSize)
90 ALfloat (*RESTRICT DryBuffer)[BUFFERSIZE] = Device->DryBuffer;
91 ALfloat *RESTRICT ClickRemoval = Device->ClickRemoval;
92 ALfloat *RESTRICT PendingClicks = Device->PendingClicks;
93 ALfloat DrySend;
94 ALuint pos;
95 ALuint c;
97 for(c = 0;c < MaxChannels;c++)
99 DrySend = params->Gains[srcchan][c];
100 if(DrySend < 0.00001f)
101 continue;
103 if(OutPos == 0)
104 ClickRemoval[c] -= data[0]*DrySend;
105 for(pos = 0;pos < BufferSize;pos++)
106 DryBuffer[c][OutPos+pos] += data[pos]*DrySend;
107 if(OutPos+pos == SamplesToDo)
108 PendingClicks[c] += data[pos]*DrySend;
113 void MixSend_C(SendParams *params, const ALfloat *RESTRICT data,
114 ALuint OutPos, ALuint SamplesToDo, ALuint BufferSize)
116 ALeffectslot *Slot = params->Slot;
117 ALfloat (*RESTRICT WetBuffer)[BUFFERSIZE] = Slot->WetBuffer;
118 ALfloat *RESTRICT WetClickRemoval = Slot->ClickRemoval;
119 ALfloat *RESTRICT WetPendingClicks = Slot->PendingClicks;
120 ALfloat WetSend = params->Gain;
121 ALuint pos;
123 if(WetSend < 0.00001f)
124 return;
126 if(OutPos == 0)
127 WetClickRemoval[0] -= data[0] * WetSend;
128 for(pos = 0;pos < BufferSize;pos++)
129 WetBuffer[0][OutPos+pos] += data[pos] * WetSend;
130 if(OutPos+pos == SamplesToDo)
131 WetPendingClicks[0] += data[pos] * WetSend;