204 0.0015f, 0.0045f, 0.0135f, 0.0405f
210 0.0151f, 0.0167f, 0.0183f, 0.0200f,
216 0.0211f, 0.0311f, 0.0461f, 0.0680f
227 return Delay->Line[offset&Delay->Mask];
232 Delay->Line[offset&Delay->Mask] =
in;
238 return coeff * Delay->Line[offset&Delay->Mask];
247 feed = feedCoeff *
in;
248 DelayLineIn(Delay, inOffset, (feedCoeff * (out - feed)) + in);
253 return (coeff * out) - feed;
267 sinus = 1.0f - cosf(
F_PI*2.0
f * State->Mod.Index / State->Mod.Range);
272 State->Mod.Filter =
lerp(State->Mod.Filter, State->Mod.Depth,
276 frac = (1.0f + (State->Mod.Filter * sinus));
282 out0 =
DelayLineOut(&State->Mod.Delay, State->Offset - offset);
283 out1 =
DelayLineOut(&State->Mod.Delay, State->Offset - offset - 1);
287 State->Mod.Index = (State->Mod.Index + 1) % State->Mod.Range;
291 return lerp(out0, out1, frac);
298 State->Offset - State->Early.Offset[index],
299 State->Early.Coeff[index]);
325 v = (d[0] + d[1] + d[2] + d[3]) * 0.5f;
336 DelayLineIn(&State->Early.Delay[0], State->Offset, f[0]);
337 DelayLineIn(&State->Early.Delay[1], State->Offset, f[1]);
338 DelayLineIn(&State->Early.Delay[2], State->Offset, f[2]);
339 DelayLineIn(&State->Early.Delay[3], State->Offset, f[3]);
342 out[0] = State->Early.Gain * f[0];
343 out[1] = State->Early.Gain * f[1];
344 out[2] = State->Early.Gain * f[2];
345 out[3] = State->Early.Gain * f[3];
352 State->Offset - State->Late.ApOffset[index],
353 State->Offset, in, State->Late.ApFeedCoeff,
354 State->Late.ApCoeff[index]);
361 State->Offset - State->Late.Offset[index],
362 State->Late.Coeff[index]);
368 in =
lerp(in, State->Late.LpSample[index], State->Late.LpCoeff[index]);
369 State->Late.LpSample[
index] =
in;
425 f[0] = d[0] + (State->Late.MixCoeff * ( d[1] + -d[2] + d[3]));
426 f[1] = d[1] + (State->Late.MixCoeff * (-d[0] + d[2] + d[3]));
427 f[2] = d[2] + (State->Late.MixCoeff * ( d[0] + -d[1] + d[3]));
428 f[3] = d[3] + (State->Late.MixCoeff * (-d[0] + -d[1] + -d[2] ));
432 out[0] = State->Late.Gain * f[0];
433 out[1] = State->Late.Gain * f[1];
434 out[2] = State->Late.Gain * f[2];
435 out[3] = State->Late.Gain * f[3];
438 DelayLineIn(&State->Late.Delay[0], State->Offset, f[0]);
439 DelayLineIn(&State->Late.Delay[1], State->Offset, f[1]);
440 DelayLineIn(&State->Late.Delay[2], State->Offset, f[2]);
441 DelayLineIn(&State->Late.Delay[3], State->Offset, f[3]);
452 State->Offset - State->Echo.Offset,
456 out = State->Echo.MixCoeff[0] * feed;
457 late[0] = (State->Echo.MixCoeff[1] * late[0]) + out;
458 late[1] = (State->Echo.MixCoeff[1] * late[1]) + out;
459 late[2] = (State->Echo.MixCoeff[1] * late[2]) + out;
460 late[3] = (State->Echo.MixCoeff[1] * late[3]) + out;
464 feed += State->Echo.DensityGain *
in;
465 feed =
lerp(feed, State->Echo.LpSample, State->Echo.LpCoeff);
466 State->Echo.LpSample = feed;
470 State->Offset - State->Echo.ApOffset,
471 State->Offset, feed, State->Echo.ApFeedCoeff,
472 State->Echo.ApCoeff);
475 DelayLineIn(&State->Echo.Delay, State->Offset, feed);
482 ALfloat feed, late[4], taps[4];
491 in =
DelayLineOut(&State->Delay, State->Offset - State->DelayTap[0]);
496 in =
DelayLineOut(&State->Delay, State->Offset - State->DelayTap[1]);
497 feed = in * State->Late.DensityGain;
498 DelayLineIn(&State->Decorrelator, State->Offset, feed);
502 taps[1] =
DelayLineOut(&State->Decorrelator, State->Offset - State->DecoTap[0]);
503 taps[2] =
DelayLineOut(&State->Decorrelator, State->Offset - State->DecoTap[1]);
504 taps[3] =
DelayLineOut(&State->Decorrelator, State->Offset - State->DecoTap[2]);
533 in =
DelayLineOut(&State->Delay, State->Offset - State->DelayTap[0]);
538 in =
DelayLineOut(&State->Delay, State->Offset - State->DelayTap[1]);
539 feed = in * State->Late.DensityGain;
540 DelayLineIn(&State->Decorrelator, State->Offset, feed);
544 taps[1] =
DelayLineOut(&State->Decorrelator, State->Offset - State->DecoTap[0]);
545 taps[2] =
DelayLineOut(&State->Decorrelator, State->Offset - State->DecoTap[1]);
546 taps[3] =
DelayLineOut(&State->Decorrelator, State->Offset - State->DecoTap[2]);
561 ALfloat (*RESTRICT out)[4] = State->ReverbSamples;
565 for(index = 0;index < SamplesToDo;index++)
566 VerbPass(State, SamplesIn[index], out[index]);
573 for(index = 0;index < SamplesToDo;index++)
574 SamplesOut[c][index] += gain * out[index][c&3];
584 ALfloat (*RESTRICT early)[4] = State->EarlySamples;
585 ALfloat (*RESTRICT late)[4] = State->ReverbSamples;
589 for(index = 0;index < SamplesToDo;index++)
590 EAXVerbPass(State, SamplesIn[index], early[index], late[index]);
594 ALfloat earlyGain = State->Early.PanGain[
c];
595 ALfloat lateGain = State->Late.PanGain[
c];
597 if(earlyGain > 0.00001
f)
599 for(index = 0;index < SamplesToDo;index++)
600 SamplesOut[c][index] += earlyGain*early[index][c&3];
602 if(lateGain > 0.00001
f)
604 for(index = 0;index < SamplesToDo;index++)
605 SamplesOut[c][index] += lateGain*late[index][c&3];
615 Delay->Line = &sampleBuffer[(
ALintptrEXT)Delay->Line];
627 Delay->Mask = samples - 1;
628 Delay->Line = (
ALfloat*)offset;
665 for(index = 0;index < 4;index++)
667 frequency, &State->Early.Delay[index]);
674 &State->Decorrelator);
677 for(index = 0;index < 4;index++)
679 frequency, &State->Late.ApDelay[index]);
682 for(index = 0;index < 4;index++)
686 &State->Late.Delay[index]);
691 frequency, &State->Echo.ApDelay);
693 frequency, &State->Echo.Delay);
695 if(totalSamples != State->TotalSamples)
697 TRACE(
"New reverb buffer length: %u samples (%f sec)\n", totalSamples, totalSamples/(
float)frequency);
698 newBuffer =
realloc(State->SampleBuffer,
sizeof(
ALfloat) * totalSamples);
699 if(newBuffer ==
NULL)
701 State->SampleBuffer = newBuffer;
702 State->TotalSamples = totalSamples;
708 for(index = 0;index < 4;index++)
719 for(index = 0;index < State->TotalSamples;index++)
720 State->SampleBuffer[index] = 0.0f;
765 return powf(0.001
f, length/decayTime);
772 return log10f(coeff) * decayTime / log10f(0.001
f);
779 return cosf(
F_PI*2.0
f * hfRef / frequency);
799 return sqrtf(1.0
f - (a * a));
809 t = diffusion * atanf(n);
833 return clampf(limitRatio, 0.1
f, hfRatio);
857 coeff =
minf(coeff, 0.98
f);
878 State->Mod.Index = (
ALuint)(State->Mod.Index * (ALuint64)range /
880 State->Mod.Range =
range;
898 State->DelayTap[0] =
fastf2u(earlyDelay * frequency);
899 State->DelayTap[1] =
fastf2u((earlyDelay + lateDelay) * frequency);
909 State->Early.Gain = 0.5f * reverbGain * earlyGain;
914 for(index = 0;index < 4;index++)
932 for(index = 0;index < 3;index++)
951 State->Late.Gain = reverbGain * lateGain * xMix;
968 State->Late.ApFeedCoeff = 0.5f * powf(diffusion, 2.0
f);
970 for(index = 0;index < 4;index++)
981 State->Late.Offset[
index] =
fastf2u(length * frequency);
987 State->Late.LpCoeff[
index] =
989 State->Late.Coeff[index], cw);
993 State->Late.Coeff[
index] *= xMix;
1002 State->Echo.Offset =
fastf2u(echoTime * frequency);
1012 State->Echo.ApFeedCoeff = 0.5f * powf(diffusion, 2.0
f);
1019 State->Echo.Coeff, cw);
1026 State->Echo.MixCoeff[0] = reverbGain * lateGain * echoDepth;
1027 State->Echo.MixCoeff[1] = 1.0f - (echoDepth * 0.5f * (1.0f - diffusion));
1033 ALfloat earlyPan[3] = { ReflectionsPan[0], ReflectionsPan[1],
1034 ReflectionsPan[2] };
1035 ALfloat latePan[3] = { LateReverbPan[0], LateReverbPan[1],
1048 length = earlyPan[0]*earlyPan[0] + earlyPan[1]*earlyPan[1] + earlyPan[2]*earlyPan[2];
1051 length = 1.0f / sqrtf(length);
1056 length = latePan[0]*latePan[0] + latePan[1]*latePan[1] + latePan[2]*latePan[2];
1059 length = 1.0f / sqrtf(length);
1065 dirGain = sqrtf(earlyPan[0]*earlyPan[0] + earlyPan[2]*earlyPan[2]);
1067 State->Early.PanGain[index] = 0.0f;
1069 lerp(ambientGain, 1.0
f, dirGain) * Gain, State->Early.PanGain);
1071 dirGain = sqrtf(latePan[0]*latePan[0] + latePan[2]*latePan[2]);
1073 State->Late.PanGain[index] = 0.0f;
1075 lerp(ambientGain, 1.0
f, dirGain) * Gain, State->Late.PanGain);
1128 State->Late.MixCoeff = y /
x;
1150 hfRatio, cw, frequency, State);
1164 State->Gain[index] = 0.0f;
1168 State->Gain[chan] = gain;
1180 free(State->SampleBuffer);
1181 State->SampleBuffer =
NULL;
1202 State->TotalSamples = 0;
1203 State->SampleBuffer =
NULL;
1205 State->LpFilter.coeff = 0.0f;
1206 State->LpFilter.history[0] = 0.0f;
1207 State->LpFilter.history[1] = 0.0f;
1209 State->Mod.Delay.Mask = 0;
1210 State->Mod.Delay.Line =
NULL;
1211 State->Mod.Index = 0;
1212 State->Mod.Range = 1;
1213 State->Mod.Depth = 0.0f;
1214 State->Mod.Coeff = 0.0f;
1215 State->Mod.Filter = 0.0f;
1217 State->Delay.Mask = 0;
1218 State->Delay.Line =
NULL;
1219 State->DelayTap[0] = 0;
1220 State->DelayTap[1] = 0;
1222 State->Early.Gain = 0.0f;
1223 for(index = 0;index < 4;index++)
1225 State->Early.Coeff[
index] = 0.0f;
1226 State->Early.Delay[
index].Mask = 0;
1228 State->Early.Offset[
index] = 0;
1231 State->Decorrelator.Mask = 0;
1232 State->Decorrelator.Line =
NULL;
1233 State->DecoTap[0] = 0;
1234 State->DecoTap[1] = 0;
1235 State->DecoTap[2] = 0;
1237 State->Late.Gain = 0.0f;
1238 State->Late.DensityGain = 0.0f;
1239 State->Late.ApFeedCoeff = 0.0f;
1240 State->Late.MixCoeff = 0.0f;
1241 for(index = 0;index < 4;index++)
1243 State->Late.ApCoeff[
index] = 0.0f;
1244 State->Late.ApDelay[
index].Mask = 0;
1246 State->Late.ApOffset[
index] = 0;
1248 State->Late.Coeff[
index] = 0.0f;
1249 State->Late.Delay[
index].Mask = 0;
1251 State->Late.Offset[
index] = 0;
1253 State->Late.LpCoeff[
index] = 0.0f;
1254 State->Late.LpSample[
index] = 0.0f;
1259 State->Early.PanGain[
index] = 0.0f;
1260 State->Late.PanGain[
index] = 0.0f;
1263 State->Echo.DensityGain = 0.0f;
1264 State->Echo.Delay.Mask = 0;
1265 State->Echo.Delay.Line =
NULL;
1266 State->Echo.ApDelay.Mask = 0;
1267 State->Echo.ApDelay.Line =
NULL;
1268 State->Echo.Coeff = 0.0f;
1269 State->Echo.ApFeedCoeff = 0.0f;
1270 State->Echo.ApCoeff = 0.0f;
1271 State->Echo.Offset = 0;
1272 State->Echo.ApOffset = 0;
1273 State->Echo.LpCoeff = 0.0f;
1274 State->Echo.LpSample = 0.0f;
1275 State->Echo.MixCoeff[0] = 0.0f;
1276 State->Echo.MixCoeff[1] = 0.0f;
1280 State->Gain = State->Late.PanGain;
1282 return &State->state;
static __inline ALfloat CalcDecayCoeff(ALfloat length, ALfloat decayTime)
static ALboolean AllocLines(ALuint frequency, ALverbState *State)
static __inline ALfloat DelayLineOut(DelayLine *Delay, ALuint offset)
#define AL_EAXREVERB_MAX_REFLECTIONS_DELAY
static ALvoid UpdateModulator(ALfloat modTime, ALfloat modDepth, ALuint frequency, ALverbState *State)
struct ALeffect::@52 Reverb
static ALvoid UpdateEchoLine(ALfloat reverbGain, ALfloat lateGain, ALfloat echoTime, ALfloat decayTime, ALfloat diffusion, ALfloat echoDepth, ALfloat hfRatio, ALfloat cw, ALuint frequency, ALverbState *State)
static __inline ALvoid DelayLineIn(DelayLine *Delay, ALuint offset, ALfloat in)
static ALvoid Update3DPanning(const ALCdevice *Device, const ALfloat *ReflectionsPan, const ALfloat *LateReverbPan, ALfloat Gain, ALverbState *State)
#define SPEEDOFSOUNDMETRESPERSEC
static __inline ALfloat lerp(ALfloat val1, ALfloat val2, ALfloat mu)
static ALuint CalcLineLength(ALfloat length, ALintptrEXT offset, ALuint frequency, DelayLine *Delay)
ALfloat lpCoeffCalc(ALfloat g, ALfloat cw)
static const ALfloat MODULATION_DEPTH_COEFF
static ALvoid EAXVerbProcess(ALeffectState *effect, ALuint SamplesToDo, const ALfloat *RESTRICT SamplesIn, ALfloat(*RESTRICT SamplesOut)[BUFFERSIZE])
static ALboolean ReverbDeviceUpdate(ALeffectState *effect, ALCdevice *Device)
static __inline ALvoid VerbPass(ALverbState *State, ALfloat in, ALfloat *RESTRICT out)
#define AL_EAXREVERB_MAX_LATE_REVERB_DELAY
static __inline ALfloat LateAllPassInOut(ALverbState *State, ALuint index, ALfloat in)
static __inline ALfloat EAXModulation(ALverbState *State, ALfloat in)
GLboolean GLboolean GLboolean GLboolean a
ALfloat ReflectionsPan[3]
static ALvoid ReverbDestroy(ALeffectState *effect)
return Display return Display Bool Bool int d
static __inline ALfloat clampf(ALfloat val, ALfloat min, ALfloat max)
static __inline ALfloat CalcI3DL2HFreq(ALfloat hfRef, ALuint frequency)
static const ALfloat LATE_LINE_LENGTH[4]
static __inline ALvoid LateReverb(ALverbState *State, const ALfloat *RESTRICT in, ALfloat *RESTRICT out)
static ALvoid UpdateEarlyLines(ALfloat reverbGain, ALfloat earlyGain, ALfloat lateDelay, ALverbState *State)
static __inline ALfloat CalcDensityGain(ALfloat a)
static __inline ALfloat lpFilter2P(FILTER *iir, ALuint offset, ALfloat input)
#define AL_EAXREVERB_MAX_MODULATION_TIME
ALfloat AirAbsorptionGainHF
static const ALfloat DECO_FRACTION
static ALvoid UpdateDelayLine(ALfloat earlyDelay, ALfloat lateDelay, ALuint frequency, ALverbState *State)
enum Channel Speaker2Chan[MaxChannels]
static __inline ALvoid EarlyReflection(ALverbState *State, ALfloat in, ALfloat *RESTRICT out)
static ALfloat CalcLimitedHfRatio(ALfloat hfRatio, ALfloat airAbsorptionGainHF, ALfloat decayTime)
static ALvoid VerbProcess(ALeffectState *effect, ALuint SamplesToDo, const ALfloat *RESTRICT SamplesIn, ALfloat(*RESTRICT SamplesOut)[BUFFERSIZE])
static __inline ALuint fastf2u(ALfloat f)
#define AL_EAXREVERB_MAX_ECHO_TIME
ALvoid ComputeAngleGains(const ALCdevice *device, ALfloat angle, ALfloat hwidth, ALfloat ingain, ALfloat *gains)
static __inline ALvoid EAXVerbPass(ALverbState *State, ALfloat in, ALfloat *RESTRICT early, ALfloat *RESTRICT late)
ALeffectState * ReverbCreate(void)
static const ALfloat MODULATION_FILTER_COEFF
static __inline ALfloat EarlyDelayLineOut(ALverbState *State, ALuint index)
EGLSurface EGLint EGLint y
static __inline ALvoid CalcMatrixCoeffs(ALfloat diffusion, ALfloat *x, ALfloat *y)
static __inline ALfloat CalcDecayLength(ALfloat coeff, ALfloat decayTime)
static ALvoid ReverbUpdate(ALeffectState *effect, ALCdevice *Device, const ALeffectslot *Slot)
ALboolean EmulateEAXReverb
static const ALfloat ALLPASS_LINE_LENGTH[4]
static __inline ALfloat LateLowPassInOut(ALverbState *State, ALuint index, ALfloat in)
static const ALfloat LATE_LINE_MULTIPLIER
static const ALfloat DECO_MULTIPLIER
static __inline ALvoid RealizeLineOffset(ALfloat *sampleBuffer, DelayLine *Delay)
static const ALfloat MODULATION_FILTER_CONST
static size_t NextPowerOf2(size_t value)
static const ALfloat EARLY_LINE_LENGTH[4]
static __inline ALfloat AllpassInOut(DelayLine *Delay, ALuint outOffset, ALuint inOffset, ALfloat in, ALfloat feedCoeff, ALfloat coeff)
static __inline ALfloat minf(ALfloat a, ALfloat b)
static ALvoid UpdateDecorrelator(ALfloat density, ALuint frequency, ALverbState *State)
static const ALfloat ECHO_ALLPASS_LENGTH
static __inline ALfloat CalcDampingCoeff(ALfloat hfRatio, ALfloat length, ALfloat decayTime, ALfloat decayCoeff, ALfloat cw)
struct DelayLine DelayLine
#define AL_EFFECT_EAXREVERB
static __inline ALfloat AttenuatedDelayLineOut(DelayLine *Delay, ALuint offset, ALfloat coeff)
struct ALverbState ALverbState
static __inline ALuint maxu(ALuint a, ALuint b)
static __inline ALfloat LateDelayLineOut(ALverbState *State, ALuint index)
static __inline ALvoid EAXEcho(ALverbState *State, ALfloat in, ALfloat *RESTRICT late)
static ALvoid UpdateLateLines(ALfloat reverbGain, ALfloat lateGain, ALfloat xMix, ALfloat density, ALfloat decayTime, ALfloat diffusion, ALfloat hfRatio, ALfloat cw, ALuint frequency, ALverbState *State)