Workaround a GCC 5 issue
[openal-soft.git] / alc / effects / reverb.cpp
blob502a4cf251b6f78b013ce96432a5ad6edefe4e07
1 /**
2 * Ambisonic reverb engine for the OpenAL cross platform audio library
3 * Copyright (C) 2008-2017 by Chris Robinson and Christopher Fitzgerald.
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
14 * You should have received a copy of the GNU Library General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 * Or go to http://www.gnu.org/copyleft/lgpl.html
21 #include "config.h"
23 #include <cstdio>
24 #include <cstdlib>
25 #include <cmath>
27 #include <array>
28 #include <numeric>
29 #include <algorithm>
30 #include <functional>
32 #include "al/auxeffectslot.h"
33 #include "al/listener.h"
34 #include "alcmain.h"
35 #include "alcontext.h"
36 #include "alu.h"
37 #include "bformatdec.h"
38 #include "filters/biquad.h"
39 #include "vector.h"
40 #include "vecmat.h"
42 /* This is a user config option for modifying the overall output of the reverb
43 * effect.
45 float ReverbBoost = 1.0f;
47 namespace {
49 #define MOD_FRACBITS 24
50 #define MOD_FRACONE (1<<MOD_FRACBITS)
51 #define MOD_FRACMASK (MOD_FRACONE-1)
54 using namespace std::placeholders;
56 /* Max samples per process iteration. Used to limit the size needed for
57 * temporary buffers. Must be a multiple of 4 for SIMD alignment.
59 constexpr size_t MAX_UPDATE_SAMPLES{256};
61 /* The number of spatialized lines or channels to process. Four channels allows
62 * for a 3D A-Format response. NOTE: This can't be changed without taking care
63 * of the conversion matrices, and a few places where the length arrays are
64 * assumed to have 4 elements.
66 constexpr size_t NUM_LINES{4u};
69 /* This coefficient is used to define the maximum frequency range controlled by
70 * the modulation depth. The current value of 0.05 will allow it to swing from
71 * 0.95x to 1.05x. This value must be below 1. At 1 it will cause the sampler
72 * to stall on the downswing, and above 1 it will cause it to sample backwards.
73 * The value 0.05 seems be nearest to Creative hardware behavior.
75 constexpr float MODULATION_DEPTH_COEFF{0.05f};
78 /* The B-Format to A-Format conversion matrix. The arrangement of rows is
79 * deliberately chosen to align the resulting lines to their spatial opposites
80 * (0:above front left <-> 3:above back right, 1:below front right <-> 2:below
81 * back left). It's not quite opposite, since the A-Format results in a
82 * tetrahedron, but it's close enough. Should the model be extended to 8-lines
83 * in the future, true opposites can be used.
85 alignas(16) constexpr float B2A[NUM_LINES][NUM_LINES]{
86 { 0.288675134595f, 0.288675134595f, 0.288675134595f, 0.288675134595f },
87 { 0.288675134595f, -0.288675134595f, -0.288675134595f, 0.288675134595f },
88 { 0.288675134595f, 0.288675134595f, -0.288675134595f, -0.288675134595f },
89 { 0.288675134595f, -0.288675134595f, 0.288675134595f, -0.288675134595f }
92 /* Converts A-Format to B-Format. */
93 alignas(16) constexpr float A2B[NUM_LINES][NUM_LINES]{
94 { 0.866025403785f, 0.866025403785f, 0.866025403785f, 0.866025403785f },
95 { 0.866025403785f, -0.866025403785f, 0.866025403785f, -0.866025403785f },
96 { 0.866025403785f, -0.866025403785f, -0.866025403785f, 0.866025403785f },
97 { 0.866025403785f, 0.866025403785f, -0.866025403785f, -0.866025403785f }
101 /* The all-pass and delay lines have a variable length dependent on the
102 * effect's density parameter, which helps alter the perceived environment
103 * size. The size-to-density conversion is a cubed scale:
105 * density = min(1.0, pow(size, 3.0) / DENSITY_SCALE);
107 * The line lengths scale linearly with room size, so the inverse density
108 * conversion is needed, taking the cube root of the re-scaled density to
109 * calculate the line length multiplier:
111 * length_mult = max(5.0, cbrt(density*DENSITY_SCALE));
113 * The density scale below will result in a max line multiplier of 50, for an
114 * effective size range of 5m to 50m.
116 constexpr float DENSITY_SCALE{125000.0f};
118 /* All delay line lengths are specified in seconds.
120 * To approximate early reflections, we break them up into primary (those
121 * arriving from the same direction as the source) and secondary (those
122 * arriving from the opposite direction).
124 * The early taps decorrelate the 4-channel signal to approximate an average
125 * room response for the primary reflections after the initial early delay.
127 * Given an average room dimension (d_a) and the speed of sound (c) we can
128 * calculate the average reflection delay (r_a) regardless of listener and
129 * source positions as:
131 * r_a = d_a / c
132 * c = 343.3
134 * This can extended to finding the average difference (r_d) between the
135 * maximum (r_1) and minimum (r_0) reflection delays:
137 * r_0 = 2 / 3 r_a
138 * = r_a - r_d / 2
139 * = r_d
140 * r_1 = 4 / 3 r_a
141 * = r_a + r_d / 2
142 * = 2 r_d
143 * r_d = 2 / 3 r_a
144 * = r_1 - r_0
146 * As can be determined by integrating the 1D model with a source (s) and
147 * listener (l) positioned across the dimension of length (d_a):
149 * r_d = int_(l=0)^d_a (int_(s=0)^d_a |2 d_a - 2 (l + s)| ds) dl / c
151 * The initial taps (T_(i=0)^N) are then specified by taking a power series
152 * that ranges between r_0 and half of r_1 less r_0:
154 * R_i = 2^(i / (2 N - 1)) r_d
155 * = r_0 + (2^(i / (2 N - 1)) - 1) r_d
156 * = r_0 + T_i
157 * T_i = R_i - r_0
158 * = (2^(i / (2 N - 1)) - 1) r_d
160 * Assuming an average of 1m, we get the following taps:
162 constexpr std::array<float,NUM_LINES> EARLY_TAP_LENGTHS{{
163 0.0000000e+0f, 2.0213520e-4f, 4.2531060e-4f, 6.7171600e-4f
166 /* The early all-pass filter lengths are based on the early tap lengths:
168 * A_i = R_i / a
170 * Where a is the approximate maximum all-pass cycle limit (20).
172 constexpr std::array<float,NUM_LINES> EARLY_ALLPASS_LENGTHS{{
173 9.7096800e-5f, 1.0720356e-4f, 1.1836234e-4f, 1.3068260e-4f
176 /* The early delay lines are used to transform the primary reflections into
177 * the secondary reflections. The A-format is arranged in such a way that
178 * the channels/lines are spatially opposite:
180 * C_i is opposite C_(N-i-1)
182 * The delays of the two opposing reflections (R_i and O_i) from a source
183 * anywhere along a particular dimension always sum to twice its full delay:
185 * 2 r_a = R_i + O_i
187 * With that in mind we can determine the delay between the two reflections
188 * and thus specify our early line lengths (L_(i=0)^N) using:
190 * O_i = 2 r_a - R_(N-i-1)
191 * L_i = O_i - R_(N-i-1)
192 * = 2 (r_a - R_(N-i-1))
193 * = 2 (r_a - T_(N-i-1) - r_0)
194 * = 2 r_a (1 - (2 / 3) 2^((N - i - 1) / (2 N - 1)))
196 * Using an average dimension of 1m, we get:
198 constexpr std::array<float,NUM_LINES> EARLY_LINE_LENGTHS{{
199 5.9850400e-4f, 1.0913150e-3f, 1.5376658e-3f, 1.9419362e-3f
202 /* The late all-pass filter lengths are based on the late line lengths:
204 * A_i = (5 / 3) L_i / r_1
206 constexpr std::array<float,NUM_LINES> LATE_ALLPASS_LENGTHS{{
207 1.6182800e-4f, 2.0389060e-4f, 2.8159360e-4f, 3.2365600e-4f
210 /* The late lines are used to approximate the decaying cycle of recursive
211 * late reflections.
213 * Splitting the lines in half, we start with the shortest reflection paths
214 * (L_(i=0)^(N/2)):
216 * L_i = 2^(i / (N - 1)) r_d
218 * Then for the opposite (longest) reflection paths (L_(i=N/2)^N):
220 * L_i = 2 r_a - L_(i-N/2)
221 * = 2 r_a - 2^((i - N / 2) / (N - 1)) r_d
223 * For our 1m average room, we get:
225 constexpr std::array<float,NUM_LINES> LATE_LINE_LENGTHS{{
226 1.9419362e-3f, 2.4466860e-3f, 3.3791220e-3f, 3.8838720e-3f
230 using ReverbUpdateLine = std::array<float,MAX_UPDATE_SAMPLES>;
232 struct DelayLineI {
233 /* The delay lines use interleaved samples, with the lengths being powers
234 * of 2 to allow the use of bit-masking instead of a modulus for wrapping.
236 size_t Mask{0u};
237 union {
238 uintptr_t LineOffset{0u};
239 std::array<float,NUM_LINES> *Line;
242 /* Given the allocated sample buffer, this function updates each delay line
243 * offset.
245 void realizeLineOffset(std::array<float,NUM_LINES> *sampleBuffer) noexcept
246 { Line = sampleBuffer + LineOffset; }
248 /* Calculate the length of a delay line and store its mask and offset. */
249 ALuint calcLineLength(const float length, const uintptr_t offset, const float frequency,
250 const ALuint extra)
252 /* All line lengths are powers of 2, calculated from their lengths in
253 * seconds, rounded up.
255 ALuint samples{float2uint(std::ceil(length*frequency))};
256 samples = NextPowerOf2(samples + extra);
258 /* All lines share a single sample buffer. */
259 Mask = samples - 1;
260 LineOffset = offset;
262 /* Return the sample count for accumulation. */
263 return samples;
266 void write(size_t offset, const size_t c, const float *RESTRICT in, const size_t count) const noexcept
268 ASSUME(count > 0);
269 for(size_t i{0u};i < count;)
271 offset &= Mask;
272 size_t td{minz(Mask+1 - offset, count - i)};
273 do {
274 Line[offset++][c] = in[i++];
275 } while(--td);
280 struct VecAllpass {
281 DelayLineI Delay;
282 float Coeff{0.0f};
283 size_t Offset[NUM_LINES][2]{};
285 void processFaded(const al::span<ReverbUpdateLine,NUM_LINES> samples, size_t offset,
286 const float xCoeff, const float yCoeff, float fadeCount, const float fadeStep,
287 const size_t todo);
288 void processUnfaded(const al::span<ReverbUpdateLine,NUM_LINES> samples, size_t offset,
289 const float xCoeff, const float yCoeff, const size_t todo);
292 struct T60Filter {
293 /* Two filters are used to adjust the signal. One to control the low
294 * frequencies, and one to control the high frequencies.
296 float MidGain[2]{0.0f, 0.0f};
297 BiquadFilter HFFilter, LFFilter;
299 void calcCoeffs(const float length, const float lfDecayTime, const float mfDecayTime,
300 const float hfDecayTime, const float lf0norm, const float hf0norm);
302 /* Applies the two T60 damping filter sections. */
303 void process(const al::span<float> samples)
304 { DualBiquad{HFFilter, LFFilter}.process(samples, samples.data()); }
307 struct EarlyReflections {
308 /* A Gerzon vector all-pass filter is used to simulate initial diffusion.
309 * The spread from this filter also helps smooth out the reverb tail.
311 VecAllpass VecAp;
313 /* An echo line is used to complete the second half of the early
314 * reflections.
316 DelayLineI Delay;
317 size_t Offset[NUM_LINES][2]{};
318 float Coeff[NUM_LINES][2]{};
320 /* The gain for each output channel based on 3D panning. */
321 float CurrentGain[NUM_LINES][MAX_OUTPUT_CHANNELS]{};
322 float PanGain[NUM_LINES][MAX_OUTPUT_CHANNELS]{};
324 void updateLines(const float density_mult, const float diffusion, const float decayTime,
325 const float frequency);
329 struct Modulation {
330 /* The vibrato time is tracked with an index over a (MOD_FRACONE)
331 * normalized range.
333 ALuint Index, Step;
335 /* The depth of frequency change, in samples. */
336 float Depth[2];
338 float ModDelays[MAX_UPDATE_SAMPLES];
340 void updateModulator(float modTime, float modDepth, float frequency);
342 void calcDelays(size_t todo);
343 void calcFadedDelays(size_t todo, float fadeCount, float fadeStep);
346 struct LateReverb {
347 /* A recursive delay line is used fill in the reverb tail. */
348 DelayLineI Delay;
349 size_t Offset[NUM_LINES][2]{};
351 /* Attenuation to compensate for the modal density and decay rate of the
352 * late lines.
354 float DensityGain[2]{0.0f, 0.0f};
356 /* T60 decay filters are used to simulate absorption. */
357 T60Filter T60[NUM_LINES];
359 Modulation Mod;
361 /* A Gerzon vector all-pass filter is used to simulate diffusion. */
362 VecAllpass VecAp;
364 /* The gain for each output channel based on 3D panning. */
365 float CurrentGain[NUM_LINES][MAX_OUTPUT_CHANNELS]{};
366 float PanGain[NUM_LINES][MAX_OUTPUT_CHANNELS]{};
368 void updateLines(const float density_mult, const float diffusion, const float lfDecayTime,
369 const float mfDecayTime, const float hfDecayTime, const float lf0norm,
370 const float hf0norm, const float frequency);
373 struct ReverbState final : public EffectState {
374 /* All delay lines are allocated as a single buffer to reduce memory
375 * fragmentation and management code.
377 al::vector<std::array<float,NUM_LINES>,16> mSampleBuffer;
379 struct {
380 /* Calculated parameters which indicate if cross-fading is needed after
381 * an update.
383 float Density{AL_EAXREVERB_DEFAULT_DENSITY};
384 float Diffusion{AL_EAXREVERB_DEFAULT_DIFFUSION};
385 float DecayTime{AL_EAXREVERB_DEFAULT_DECAY_TIME};
386 float HFDecayTime{AL_EAXREVERB_DEFAULT_DECAY_HFRATIO * AL_EAXREVERB_DEFAULT_DECAY_TIME};
387 float LFDecayTime{AL_EAXREVERB_DEFAULT_DECAY_LFRATIO * AL_EAXREVERB_DEFAULT_DECAY_TIME};
388 float ModulationTime{AL_EAXREVERB_DEFAULT_MODULATION_TIME};
389 float ModulationDepth{AL_EAXREVERB_DEFAULT_MODULATION_DEPTH};
390 float HFReference{AL_EAXREVERB_DEFAULT_HFREFERENCE};
391 float LFReference{AL_EAXREVERB_DEFAULT_LFREFERENCE};
392 } mParams;
394 /* Master effect filters */
395 struct {
396 BiquadFilter Lp;
397 BiquadFilter Hp;
398 } mFilter[NUM_LINES];
400 /* Core delay line (early reflections and late reverb tap from this). */
401 DelayLineI mDelay;
403 /* Tap points for early reflection delay. */
404 size_t mEarlyDelayTap[NUM_LINES][2]{};
405 float mEarlyDelayCoeff[NUM_LINES][2]{};
407 /* Tap points for late reverb feed and delay. */
408 size_t mLateFeedTap{};
409 size_t mLateDelayTap[NUM_LINES][2]{};
411 /* Coefficients for the all-pass and line scattering matrices. */
412 float mMixX{0.0f};
413 float mMixY{0.0f};
415 EarlyReflections mEarly;
417 LateReverb mLate;
419 bool mDoFading{};
421 /* Maximum number of samples to process at once. */
422 size_t mMaxUpdate[2]{MAX_UPDATE_SAMPLES, MAX_UPDATE_SAMPLES};
424 /* The current write offset for all delay lines. */
425 size_t mOffset{};
427 /* Temporary storage used when processing. */
428 union {
429 alignas(16) FloatBufferLine mTempLine{};
430 alignas(16) std::array<ReverbUpdateLine,NUM_LINES> mTempSamples;
432 alignas(16) std::array<ReverbUpdateLine,NUM_LINES> mEarlySamples{};
433 alignas(16) std::array<ReverbUpdateLine,NUM_LINES> mLateSamples{};
435 using MixOutT = void (ReverbState::*)(const al::span<FloatBufferLine> samplesOut,
436 const size_t counter, const size_t offset, const size_t todo);
438 MixOutT mMixOut{&ReverbState::MixOutPlain};
439 std::array<float,MAX_AMBI_ORDER+1> mOrderScales{};
440 std::array<std::array<BandSplitter,NUM_LINES>,2> mAmbiSplitter;
443 static void DoMixRow(const al::span<float> OutBuffer, const al::span<const float> Gains,
444 const float *InSamples, const size_t InStride)
446 std::fill(OutBuffer.begin(), OutBuffer.end(), 0.0f);
447 for(const float gain : Gains)
449 const float *RESTRICT input{al::assume_aligned<16>(InSamples)};
450 InSamples += InStride;
452 if(!(std::fabs(gain) > GAIN_SILENCE_THRESHOLD))
453 continue;
455 for(float &sample : OutBuffer)
457 sample += *input * gain;
458 ++input;
464 void MixOutPlain(const al::span<FloatBufferLine> samplesOut, const size_t counter,
465 const size_t offset, const size_t todo)
467 ASSUME(todo > 0);
469 /* Convert back to B-Format, and mix the results to output. */
470 const al::span<float> tmpspan{al::assume_aligned<16>(mTempLine.data()), todo};
471 for(size_t c{0u};c < NUM_LINES;c++)
473 DoMixRow(tmpspan, A2B[c], mEarlySamples[0].data(), mEarlySamples[0].size());
474 MixSamples(tmpspan, samplesOut, mEarly.CurrentGain[c], mEarly.PanGain[c], counter,
475 offset);
477 for(size_t c{0u};c < NUM_LINES;c++)
479 DoMixRow(tmpspan, A2B[c], mLateSamples[0].data(), mLateSamples[0].size());
480 MixSamples(tmpspan, samplesOut, mLate.CurrentGain[c], mLate.PanGain[c], counter,
481 offset);
485 void MixOutAmbiUp(const al::span<FloatBufferLine> samplesOut, const size_t counter,
486 const size_t offset, const size_t todo)
488 ASSUME(todo > 0);
490 const al::span<float> tmpspan{al::assume_aligned<16>(mTempLine.data()), todo};
491 for(size_t c{0u};c < NUM_LINES;c++)
493 DoMixRow(tmpspan, A2B[c], mEarlySamples[0].data(), mEarlySamples[0].size());
495 /* Apply scaling to the B-Format's HF response to "upsample" it to
496 * higher-order output.
498 const float hfscale{(c==0) ? mOrderScales[0] : mOrderScales[1]};
499 mAmbiSplitter[0][c].processHfScale(tmpspan, hfscale);
501 MixSamples(tmpspan, samplesOut, mEarly.CurrentGain[c], mEarly.PanGain[c], counter,
502 offset);
504 for(size_t c{0u};c < NUM_LINES;c++)
506 DoMixRow(tmpspan, A2B[c], mLateSamples[0].data(), mLateSamples[0].size());
508 const float hfscale{(c==0) ? mOrderScales[0] : mOrderScales[1]};
509 mAmbiSplitter[1][c].processHfScale(tmpspan, hfscale);
511 MixSamples(tmpspan, samplesOut, mLate.CurrentGain[c], mLate.PanGain[c], counter,
512 offset);
516 void allocLines(const float frequency);
518 void updateDelayLine(const float earlyDelay, const float lateDelay, const float density_mult,
519 const float decayTime, const float frequency);
520 void update3DPanning(const float *ReflectionsPan, const float *LateReverbPan,
521 const float earlyGain, const float lateGain, const EffectTarget &target);
523 void earlyUnfaded(const size_t offset, const size_t todo);
524 void earlyFaded(const size_t offset, const size_t todo, const float fade,
525 const float fadeStep);
527 void lateUnfaded(const size_t offset, const size_t todo);
528 void lateFaded(const size_t offset, const size_t todo, const float fade,
529 const float fadeStep);
531 void deviceUpdate(const ALCdevice *device) override;
532 void update(const ALCcontext *context, const ALeffectslot *slot, const EffectProps *props, const EffectTarget target) override;
533 void process(const size_t samplesToDo, const al::span<const FloatBufferLine> samplesIn, const al::span<FloatBufferLine> samplesOut) override;
535 DEF_NEWDEL(ReverbState)
538 /**************************************
539 * Device Update *
540 **************************************/
542 inline float CalcDelayLengthMult(float density)
543 { return maxf(5.0f, std::cbrt(density*DENSITY_SCALE)); }
545 /* Calculates the delay line metrics and allocates the shared sample buffer
546 * for all lines given the sample rate (frequency).
548 void ReverbState::allocLines(const float frequency)
550 /* All delay line lengths are calculated to accomodate the full range of
551 * lengths given their respective paramters.
553 size_t totalSamples{0u};
555 /* Multiplier for the maximum density value, i.e. density=1, which is
556 * actually the least density...
558 const float multiplier{CalcDelayLengthMult(AL_EAXREVERB_MAX_DENSITY)};
560 /* The main delay length includes the maximum early reflection delay, the
561 * largest early tap width, the maximum late reverb delay, and the
562 * largest late tap width. Finally, it must also be extended by the
563 * update size (BUFFERSIZE) for block processing.
565 float length{AL_EAXREVERB_MAX_REFLECTIONS_DELAY + EARLY_TAP_LENGTHS.back()*multiplier +
566 AL_EAXREVERB_MAX_LATE_REVERB_DELAY +
567 (LATE_LINE_LENGTHS.back() - LATE_LINE_LENGTHS.front())/float{NUM_LINES}*multiplier};
568 totalSamples += mDelay.calcLineLength(length, totalSamples, frequency, BUFFERSIZE);
570 /* The early vector all-pass line. */
571 length = EARLY_ALLPASS_LENGTHS.back() * multiplier;
572 totalSamples += mEarly.VecAp.Delay.calcLineLength(length, totalSamples, frequency, 0);
574 /* The early reflection line. */
575 length = EARLY_LINE_LENGTHS.back() * multiplier;
576 totalSamples += mEarly.Delay.calcLineLength(length, totalSamples, frequency, 0);
578 /* The late vector all-pass line. */
579 length = LATE_ALLPASS_LENGTHS.back() * multiplier;
580 totalSamples += mLate.VecAp.Delay.calcLineLength(length, totalSamples, frequency, 0);
582 /* The modulator's line length is calculated from the maximum modulation
583 * time and depth coefficient, and halfed for the low-to-high frequency
584 * swing.
586 constexpr float max_mod_delay{AL_EAXREVERB_MAX_MODULATION_TIME*MODULATION_DEPTH_COEFF / 2.0f};
588 /* The late delay lines are calculated from the largest maximum density
589 * line length, and the maximum modulation delay. An additional sample is
590 * added to keep it stable when there is no modulation.
592 length = LATE_LINE_LENGTHS.back()*multiplier + max_mod_delay;
593 totalSamples += mLate.Delay.calcLineLength(length, totalSamples, frequency, 1);
595 if(totalSamples != mSampleBuffer.size())
596 decltype(mSampleBuffer)(totalSamples).swap(mSampleBuffer);
598 /* Clear the sample buffer. */
599 std::fill(mSampleBuffer.begin(), mSampleBuffer.end(), decltype(mSampleBuffer)::value_type{});
601 /* Update all delays to reflect the new sample buffer. */
602 mDelay.realizeLineOffset(mSampleBuffer.data());
603 mEarly.VecAp.Delay.realizeLineOffset(mSampleBuffer.data());
604 mEarly.Delay.realizeLineOffset(mSampleBuffer.data());
605 mLate.VecAp.Delay.realizeLineOffset(mSampleBuffer.data());
606 mLate.Delay.realizeLineOffset(mSampleBuffer.data());
609 void ReverbState::deviceUpdate(const ALCdevice *device)
611 const auto frequency = static_cast<float>(device->Frequency);
613 /* Allocate the delay lines. */
614 allocLines(frequency);
616 const float multiplier{CalcDelayLengthMult(AL_EAXREVERB_MAX_DENSITY)};
618 /* The late feed taps are set a fixed position past the latest delay tap. */
619 mLateFeedTap = float2uint(
620 (AL_EAXREVERB_MAX_REFLECTIONS_DELAY + EARLY_TAP_LENGTHS.back()*multiplier) * frequency);
622 /* Clear filters and gain coefficients since the delay lines were all just
623 * cleared (if not reallocated).
625 for(auto &filter : mFilter)
627 filter.Lp.clear();
628 filter.Hp.clear();
631 for(auto &coeff : mEarlyDelayCoeff)
632 std::fill(std::begin(coeff), std::end(coeff), 0.0f);
633 for(auto &coeff : mEarly.Coeff)
634 std::fill(std::begin(coeff), std::end(coeff), 0.0f);
636 mLate.DensityGain[0] = 0.0f;
637 mLate.DensityGain[1] = 0.0f;
638 for(auto &t60 : mLate.T60)
640 t60.MidGain[0] = 0.0f;
641 t60.MidGain[1] = 0.0f;
642 t60.HFFilter.clear();
643 t60.LFFilter.clear();
646 mLate.Mod.Index = 0;
647 mLate.Mod.Step = 1;
648 std::fill(std::begin(mLate.Mod.Depth), std::end(mLate.Mod.Depth), 0.0f);
650 for(auto &gains : mEarly.CurrentGain)
651 std::fill(std::begin(gains), std::end(gains), 0.0f);
652 for(auto &gains : mEarly.PanGain)
653 std::fill(std::begin(gains), std::end(gains), 0.0f);
654 for(auto &gains : mLate.CurrentGain)
655 std::fill(std::begin(gains), std::end(gains), 0.0f);
656 for(auto &gains : mLate.PanGain)
657 std::fill(std::begin(gains), std::end(gains), 0.0f);
659 /* Reset fading and offset base. */
660 mDoFading = true;
661 std::fill(std::begin(mMaxUpdate), std::end(mMaxUpdate), MAX_UPDATE_SAMPLES);
662 mOffset = 0;
664 if(device->mAmbiOrder > 1)
666 mMixOut = &ReverbState::MixOutAmbiUp;
667 mOrderScales = BFormatDec::GetHFOrderScales(1, device->mAmbiOrder);
669 else
671 mMixOut = &ReverbState::MixOutPlain;
672 mOrderScales.fill(1.0f);
674 mAmbiSplitter[0][0].init(400.0f / frequency);
675 std::fill(mAmbiSplitter[0].begin()+1, mAmbiSplitter[0].end(), mAmbiSplitter[0][0]);
676 std::fill(mAmbiSplitter[1].begin(), mAmbiSplitter[1].end(), mAmbiSplitter[0][0]);
679 /**************************************
680 * Effect Update *
681 **************************************/
683 /* Calculate a decay coefficient given the length of each cycle and the time
684 * until the decay reaches -60 dB.
686 inline float CalcDecayCoeff(const float length, const float decayTime)
687 { return std::pow(REVERB_DECAY_GAIN, length/decayTime); }
689 /* Calculate a decay length from a coefficient and the time until the decay
690 * reaches -60 dB.
692 inline float CalcDecayLength(const float coeff, const float decayTime)
694 constexpr float log10_decaygain{-3.0f/*std::log10(REVERB_DECAY_GAIN)=std::log10(0.001f)*/};
695 return std::log10(coeff) * decayTime / log10_decaygain;
698 /* Calculate an attenuation to be applied to the input of any echo models to
699 * compensate for modal density and decay time.
701 inline float CalcDensityGain(const float a)
703 /* The energy of a signal can be obtained by finding the area under the
704 * squared signal. This takes the form of Sum(x_n^2), where x is the
705 * amplitude for the sample n.
707 * Decaying feedback matches exponential decay of the form Sum(a^n),
708 * where a is the attenuation coefficient, and n is the sample. The area
709 * under this decay curve can be calculated as: 1 / (1 - a).
711 * Modifying the above equation to find the area under the squared curve
712 * (for energy) yields: 1 / (1 - a^2). Input attenuation can then be
713 * calculated by inverting the square root of this approximation,
714 * yielding: 1 / sqrt(1 / (1 - a^2)), simplified to: sqrt(1 - a^2).
716 return std::sqrt(1.0f - a*a);
719 /* Calculate the scattering matrix coefficients given a diffusion factor. */
720 inline void CalcMatrixCoeffs(const float diffusion, float *x, float *y)
722 /* The matrix is of order 4, so n is sqrt(4 - 1). */
723 constexpr float n{1.73205080756887719318f/*std::sqrt(3.0f)*/};
724 const float t{diffusion * std::atan(n)};
726 /* Calculate the first mixing matrix coefficient. */
727 *x = std::cos(t);
728 /* Calculate the second mixing matrix coefficient. */
729 *y = std::sin(t) / n;
732 /* Calculate the limited HF ratio for use with the late reverb low-pass
733 * filters.
735 float CalcLimitedHfRatio(const float hfRatio, const float airAbsorptionGainHF,
736 const float decayTime)
738 /* Find the attenuation due to air absorption in dB (converting delay
739 * time to meters using the speed of sound). Then reversing the decay
740 * equation, solve for HF ratio. The delay length is cancelled out of
741 * the equation, so it can be calculated once for all lines.
743 float limitRatio{1.0f / SPEEDOFSOUNDMETRESPERSEC /
744 CalcDecayLength(airAbsorptionGainHF, decayTime)};
746 /* Using the limit calculated above, apply the upper bound to the HF ratio. */
747 return minf(limitRatio, hfRatio);
751 /* Calculates the 3-band T60 damping coefficients for a particular delay line
752 * of specified length, using a combination of two shelf filter sections given
753 * decay times for each band split at two reference frequencies.
755 void T60Filter::calcCoeffs(const float length, const float lfDecayTime,
756 const float mfDecayTime, const float hfDecayTime, const float lf0norm,
757 const float hf0norm)
759 const float mfGain{CalcDecayCoeff(length, mfDecayTime)};
760 const float lfGain{CalcDecayCoeff(length, lfDecayTime) / mfGain};
761 const float hfGain{CalcDecayCoeff(length, hfDecayTime) / mfGain};
763 MidGain[1] = mfGain;
764 LFFilter.setParamsFromSlope(BiquadType::LowShelf, lf0norm, lfGain, 1.0f);
765 HFFilter.setParamsFromSlope(BiquadType::HighShelf, hf0norm, hfGain, 1.0f);
768 /* Update the early reflection line lengths and gain coefficients. */
769 void EarlyReflections::updateLines(const float density_mult, const float diffusion,
770 const float decayTime, const float frequency)
772 constexpr float sqrt1_2{0.70710678118654752440f/*1.0f/std::sqrt(2.0f)*/};
774 /* Calculate the all-pass feed-back/forward coefficient. */
775 VecAp.Coeff = diffusion*diffusion * sqrt1_2;
777 for(size_t i{0u};i < NUM_LINES;i++)
779 /* Calculate the delay length of each all-pass line. */
780 float length{EARLY_ALLPASS_LENGTHS[i] * density_mult};
781 VecAp.Offset[i][1] = float2uint(length * frequency);
783 /* Calculate the delay length of each delay line. */
784 length = EARLY_LINE_LENGTHS[i] * density_mult;
785 Offset[i][1] = float2uint(length * frequency);
787 /* Calculate the gain (coefficient) for each line. */
788 Coeff[i][1] = CalcDecayCoeff(length, decayTime);
792 /* Update the EAX modulation step and depth. Keep in mind that this kind of
793 * vibrato is additive and not multiplicative as one may expect. The downswing
794 * will sound stronger than the upswing.
796 void Modulation::updateModulator(float modTime, float modDepth, float frequency)
798 /* Modulation is calculated in two parts.
800 * The modulation time effects the sinus rate, altering the speed of
801 * frequency changes. An index is incremented for each sample with an
802 * appropriate step size to generate an LFO, which will vary the feedback
803 * delay over time.
805 Step = maxu(fastf2u(MOD_FRACONE / (frequency * modTime)), 1);
807 /* The modulation depth effects the amount of frequency change over the
808 * range of the sinus. It needs to be scaled by the modulation time so that
809 * a given depth produces a consistent change in frequency over all ranges
810 * of time. Since the depth is applied to a sinus value, it needs to be
811 * halved once for the sinus range and again for the sinus swing in time
812 * (half of it is spent decreasing the frequency, half is spent increasing
813 * it).
815 if(modTime >= AL_EAXREVERB_DEFAULT_MODULATION_TIME)
817 /* To cancel the effects of a long period modulation on the late
818 * reverberation, the amount of pitch should be varied (decreased)
819 * according to the modulation time. The natural form is varying
820 * inversely, in fact resulting in an invariant.
822 Depth[1] = MODULATION_DEPTH_COEFF / 4.0f * AL_EAXREVERB_DEFAULT_MODULATION_TIME *
823 modDepth * frequency;
825 else
826 Depth[1] = MODULATION_DEPTH_COEFF / 4.0f * modTime * modDepth * frequency;
829 /* Update the late reverb line lengths and T60 coefficients. */
830 void LateReverb::updateLines(const float density_mult, const float diffusion,
831 const float lfDecayTime, const float mfDecayTime, const float hfDecayTime,
832 const float lf0norm, const float hf0norm, const float frequency)
834 /* Scaling factor to convert the normalized reference frequencies from
835 * representing 0...freq to 0...max_reference.
837 const float norm_weight_factor{frequency / AL_EAXREVERB_MAX_HFREFERENCE};
839 const float late_allpass_avg{
840 std::accumulate(LATE_ALLPASS_LENGTHS.begin(), LATE_ALLPASS_LENGTHS.end(), 0.0f) /
841 float{NUM_LINES}};
843 /* To compensate for changes in modal density and decay time of the late
844 * reverb signal, the input is attenuated based on the maximal energy of
845 * the outgoing signal. This approximation is used to keep the apparent
846 * energy of the signal equal for all ranges of density and decay time.
848 * The average length of the delay lines is used to calculate the
849 * attenuation coefficient.
851 float length{std::accumulate(LATE_LINE_LENGTHS.begin(), LATE_LINE_LENGTHS.end(), 0.0f) /
852 float{NUM_LINES} + late_allpass_avg};
853 length *= density_mult;
854 /* The density gain calculation uses an average decay time weighted by
855 * approximate bandwidth. This attempts to compensate for losses of energy
856 * that reduce decay time due to scattering into highly attenuated bands.
858 const float decayTimeWeighted{
859 lf0norm*norm_weight_factor*lfDecayTime +
860 (hf0norm - lf0norm)*norm_weight_factor*mfDecayTime +
861 (1.0f - hf0norm*norm_weight_factor)*hfDecayTime};
862 DensityGain[1] = CalcDensityGain(CalcDecayCoeff(length, decayTimeWeighted));
864 /* Calculate the all-pass feed-back/forward coefficient. */
865 constexpr float sqrt1_2{0.70710678118654752440f/*1.0f/std::sqrt(2.0f)*/};
866 VecAp.Coeff = diffusion*diffusion * sqrt1_2;
868 for(size_t i{0u};i < NUM_LINES;i++)
870 /* Calculate the delay length of each all-pass line. */
871 length = LATE_ALLPASS_LENGTHS[i] * density_mult;
872 VecAp.Offset[i][1] = float2uint(length * frequency);
874 /* Calculate the delay length of each feedback delay line. */
875 length = LATE_LINE_LENGTHS[i] * density_mult;
876 Offset[i][1] = float2uint(length*frequency + 0.5f);
878 /* Approximate the absorption that the vector all-pass would exhibit
879 * given the current diffusion so we don't have to process a full T60
880 * filter for each of its four lines. Also include the average
881 * modulation delay (depth is half the max delay in samples).
883 length += lerp(LATE_ALLPASS_LENGTHS[i], late_allpass_avg, diffusion)*density_mult +
884 Mod.Depth[1]/frequency;
886 /* Calculate the T60 damping coefficients for each line. */
887 T60[i].calcCoeffs(length, lfDecayTime, mfDecayTime, hfDecayTime, lf0norm, hf0norm);
892 /* Update the offsets for the main effect delay line. */
893 void ReverbState::updateDelayLine(const float earlyDelay, const float lateDelay,
894 const float density_mult, const float decayTime, const float frequency)
896 /* Early reflection taps are decorrelated by means of an average room
897 * reflection approximation described above the definition of the taps.
898 * This approximation is linear and so the above density multiplier can
899 * be applied to adjust the width of the taps. A single-band decay
900 * coefficient is applied to simulate initial attenuation and absorption.
902 * Late reverb taps are based on the late line lengths to allow a zero-
903 * delay path and offsets that would continue the propagation naturally
904 * into the late lines.
906 for(size_t i{0u};i < NUM_LINES;i++)
908 float length{EARLY_TAP_LENGTHS[i]*density_mult};
909 mEarlyDelayTap[i][1] = float2uint((earlyDelay+length) * frequency);
910 mEarlyDelayCoeff[i][1] = CalcDecayCoeff(length, decayTime);
912 length = (LATE_LINE_LENGTHS[i] - LATE_LINE_LENGTHS.front())/float{NUM_LINES}*density_mult +
913 lateDelay;
914 mLateDelayTap[i][1] = mLateFeedTap + float2uint(length * frequency);
918 /* Creates a transform matrix given a reverb vector. The vector pans the reverb
919 * reflections toward the given direction, using its magnitude (up to 1) as a
920 * focal strength. This function results in a B-Format transformation matrix
921 * that spatially focuses the signal in the desired direction.
923 alu::Matrix GetTransformFromVector(const float *vec)
925 constexpr float sqrt3{1.73205080756887719318f};
927 /* Normalize the panning vector according to the N3D scale, which has an
928 * extra sqrt(3) term on the directional components. Converting from OpenAL
929 * to B-Format also requires negating X (ACN 1) and Z (ACN 3). Note however
930 * that the reverb panning vectors use left-handed coordinates, unlike the
931 * rest of OpenAL which use right-handed. This is fixed by negating Z,
932 * which cancels out with the B-Format Z negation.
934 float norm[3];
935 float mag{std::sqrt(vec[0]*vec[0] + vec[1]*vec[1] + vec[2]*vec[2])};
936 if(mag > 1.0f)
938 norm[0] = vec[0] / mag * -sqrt3;
939 norm[1] = vec[1] / mag * sqrt3;
940 norm[2] = vec[2] / mag * sqrt3;
941 mag = 1.0f;
943 else
945 /* If the magnitude is less than or equal to 1, just apply the sqrt(3)
946 * term. There's no need to renormalize the magnitude since it would
947 * just be reapplied in the matrix.
949 norm[0] = vec[0] * -sqrt3;
950 norm[1] = vec[1] * sqrt3;
951 norm[2] = vec[2] * sqrt3;
954 return alu::Matrix{
955 1.0f, 0.0f, 0.0f, 0.0f,
956 norm[0], 1.0f-mag, 0.0f, 0.0f,
957 norm[1], 0.0f, 1.0f-mag, 0.0f,
958 norm[2], 0.0f, 0.0f, 1.0f-mag
962 /* Update the early and late 3D panning gains. */
963 void ReverbState::update3DPanning(const float *ReflectionsPan, const float *LateReverbPan,
964 const float earlyGain, const float lateGain, const EffectTarget &target)
966 /* Create matrices that transform a B-Format signal according to the
967 * panning vectors.
969 const alu::Matrix earlymat{GetTransformFromVector(ReflectionsPan)};
970 const alu::Matrix latemat{GetTransformFromVector(LateReverbPan)};
972 mOutTarget = target.Main->Buffer;
973 for(size_t i{0u};i < NUM_LINES;i++)
975 const float coeffs[MAX_AMBI_CHANNELS]{earlymat[0][i], earlymat[1][i], earlymat[2][i],
976 earlymat[3][i]};
977 ComputePanGains(target.Main, coeffs, earlyGain, mEarly.PanGain[i]);
979 for(size_t i{0u};i < NUM_LINES;i++)
981 const float coeffs[MAX_AMBI_CHANNELS]{latemat[0][i], latemat[1][i], latemat[2][i],
982 latemat[3][i]};
983 ComputePanGains(target.Main, coeffs, lateGain, mLate.PanGain[i]);
987 void ReverbState::update(const ALCcontext *Context, const ALeffectslot *Slot, const EffectProps *props, const EffectTarget target)
989 const ALCdevice *Device{Context->mDevice.get()};
990 const auto frequency = static_cast<float>(Device->Frequency);
992 /* Calculate the master filters */
993 float hf0norm{minf(props->Reverb.HFReference/frequency, 0.49f)};
994 mFilter[0].Lp.setParamsFromSlope(BiquadType::HighShelf, hf0norm, props->Reverb.GainHF, 1.0f);
995 float lf0norm{minf(props->Reverb.LFReference/frequency, 0.49f)};
996 mFilter[0].Hp.setParamsFromSlope(BiquadType::LowShelf, lf0norm, props->Reverb.GainLF, 1.0f);
997 for(size_t i{1u};i < NUM_LINES;i++)
999 mFilter[i].Lp.copyParamsFrom(mFilter[0].Lp);
1000 mFilter[i].Hp.copyParamsFrom(mFilter[0].Hp);
1003 /* The density-based room size (delay length) multiplier. */
1004 const float density_mult{CalcDelayLengthMult(props->Reverb.Density)};
1006 /* Update the main effect delay and associated taps. */
1007 updateDelayLine(props->Reverb.ReflectionsDelay, props->Reverb.LateReverbDelay,
1008 density_mult, props->Reverb.DecayTime, frequency);
1010 /* Update the early lines. */
1011 mEarly.updateLines(density_mult, props->Reverb.Diffusion, props->Reverb.DecayTime, frequency);
1013 /* Get the mixing matrix coefficients. */
1014 CalcMatrixCoeffs(props->Reverb.Diffusion, &mMixX, &mMixY);
1016 /* If the HF limit parameter is flagged, calculate an appropriate limit
1017 * based on the air absorption parameter.
1019 float hfRatio{props->Reverb.DecayHFRatio};
1020 if(props->Reverb.DecayHFLimit && props->Reverb.AirAbsorptionGainHF < 1.0f)
1021 hfRatio = CalcLimitedHfRatio(hfRatio, props->Reverb.AirAbsorptionGainHF,
1022 props->Reverb.DecayTime);
1024 /* Calculate the LF/HF decay times. */
1025 const float lfDecayTime{clampf(props->Reverb.DecayTime * props->Reverb.DecayLFRatio,
1026 AL_EAXREVERB_MIN_DECAY_TIME, AL_EAXREVERB_MAX_DECAY_TIME)};
1027 const float hfDecayTime{clampf(props->Reverb.DecayTime * hfRatio,
1028 AL_EAXREVERB_MIN_DECAY_TIME, AL_EAXREVERB_MAX_DECAY_TIME)};
1030 /* Update the modulator rate and depth. */
1031 mLate.Mod.updateModulator(props->Reverb.ModulationTime, props->Reverb.ModulationDepth,
1032 frequency);
1034 /* Update the late lines. */
1035 mLate.updateLines(density_mult, props->Reverb.Diffusion, lfDecayTime,
1036 props->Reverb.DecayTime, hfDecayTime, lf0norm, hf0norm, frequency);
1038 /* Update early and late 3D panning. */
1039 const float gain{props->Reverb.Gain * Slot->Params.Gain * ReverbBoost};
1040 update3DPanning(props->Reverb.ReflectionsPan, props->Reverb.LateReverbPan,
1041 props->Reverb.ReflectionsGain*gain, props->Reverb.LateReverbGain*gain, target);
1043 /* Calculate the max update size from the smallest relevant delay. */
1044 mMaxUpdate[1] = minz(MAX_UPDATE_SAMPLES, minz(mEarly.Offset[0][1], mLate.Offset[0][1]));
1046 /* Determine if delay-line cross-fading is required. Density is essentially
1047 * a master control for the feedback delays, so changes the offsets of many
1048 * delay lines.
1050 mDoFading |= (mParams.Density != props->Reverb.Density ||
1051 /* Diffusion and decay times influences the decay rate (gain) of the
1052 * late reverb T60 filter.
1054 mParams.Diffusion != props->Reverb.Diffusion ||
1055 mParams.DecayTime != props->Reverb.DecayTime ||
1056 mParams.HFDecayTime != hfDecayTime ||
1057 mParams.LFDecayTime != lfDecayTime ||
1058 /* Modulation time and depth both require fading the modulation delay. */
1059 mParams.ModulationTime != props->Reverb.ModulationTime ||
1060 mParams.ModulationDepth != props->Reverb.ModulationDepth ||
1061 /* HF/LF References control the weighting used to calculate the density
1062 * gain.
1064 mParams.HFReference != props->Reverb.HFReference ||
1065 mParams.LFReference != props->Reverb.LFReference);
1066 if(mDoFading)
1068 mParams.Density = props->Reverb.Density;
1069 mParams.Diffusion = props->Reverb.Diffusion;
1070 mParams.DecayTime = props->Reverb.DecayTime;
1071 mParams.HFDecayTime = hfDecayTime;
1072 mParams.LFDecayTime = lfDecayTime;
1073 mParams.ModulationTime = props->Reverb.ModulationTime;
1074 mParams.ModulationDepth = props->Reverb.ModulationDepth;
1075 mParams.HFReference = props->Reverb.HFReference;
1076 mParams.LFReference = props->Reverb.LFReference;
1081 /**************************************
1082 * Effect Processing *
1083 **************************************/
1085 /* Applies a scattering matrix to the 4-line (vector) input. This is used
1086 * for both the below vector all-pass model and to perform modal feed-back
1087 * delay network (FDN) mixing.
1089 * The matrix is derived from a skew-symmetric matrix to form a 4D rotation
1090 * matrix with a single unitary rotational parameter:
1092 * [ d, a, b, c ] 1 = a^2 + b^2 + c^2 + d^2
1093 * [ -a, d, c, -b ]
1094 * [ -b, -c, d, a ]
1095 * [ -c, b, -a, d ]
1097 * The rotation is constructed from the effect's diffusion parameter,
1098 * yielding:
1100 * 1 = x^2 + 3 y^2
1102 * Where a, b, and c are the coefficient y with differing signs, and d is the
1103 * coefficient x. The final matrix is thus:
1105 * [ x, y, -y, y ] n = sqrt(matrix_order - 1)
1106 * [ -y, x, y, y ] t = diffusion_parameter * atan(n)
1107 * [ y, -y, x, y ] x = cos(t)
1108 * [ -y, -y, -y, x ] y = sin(t) / n
1110 * Any square orthogonal matrix with an order that is a power of two will
1111 * work (where ^T is transpose, ^-1 is inverse):
1113 * M^T = M^-1
1115 * Using that knowledge, finding an appropriate matrix can be accomplished
1116 * naively by searching all combinations of:
1118 * M = D + S - S^T
1120 * Where D is a diagonal matrix (of x), and S is a triangular matrix (of y)
1121 * whose combination of signs are being iterated.
1123 inline auto VectorPartialScatter(const std::array<float,NUM_LINES> &RESTRICT in,
1124 const float xCoeff, const float yCoeff) -> std::array<float,NUM_LINES>
1126 return std::array<float,NUM_LINES>{{
1127 xCoeff*in[0] + yCoeff*( in[1] + -in[2] + in[3]),
1128 xCoeff*in[1] + yCoeff*(-in[0] + in[2] + in[3]),
1129 xCoeff*in[2] + yCoeff*( in[0] + -in[1] + in[3]),
1130 xCoeff*in[3] + yCoeff*(-in[0] + -in[1] + -in[2] )
1134 /* Utilizes the above, but reverses the input channels. */
1135 void VectorScatterRevDelayIn(const DelayLineI delay, size_t offset, const float xCoeff,
1136 const float yCoeff, const al::span<const ReverbUpdateLine,NUM_LINES> in, const size_t count)
1138 ASSUME(count > 0);
1140 for(size_t i{0u};i < count;)
1142 offset &= delay.Mask;
1143 size_t td{minz(delay.Mask+1 - offset, count-i)};
1144 do {
1145 std::array<float,NUM_LINES> f;
1146 for(size_t j{0u};j < NUM_LINES;j++)
1147 f[NUM_LINES-1-j] = in[j][i];
1148 ++i;
1150 delay.Line[offset++] = VectorPartialScatter(f, xCoeff, yCoeff);
1151 } while(--td);
1155 /* This applies a Gerzon multiple-in/multiple-out (MIMO) vector all-pass
1156 * filter to the 4-line input.
1158 * It works by vectorizing a regular all-pass filter and replacing the delay
1159 * element with a scattering matrix (like the one above) and a diagonal
1160 * matrix of delay elements.
1162 * Two static specializations are used for transitional (cross-faded) delay
1163 * line processing and non-transitional processing.
1165 void VecAllpass::processUnfaded(const al::span<ReverbUpdateLine,NUM_LINES> samples, size_t offset,
1166 const float xCoeff, const float yCoeff, const size_t todo)
1168 const DelayLineI delay{Delay};
1169 const float feedCoeff{Coeff};
1171 ASSUME(todo > 0);
1173 size_t vap_offset[NUM_LINES];
1174 for(size_t j{0u};j < NUM_LINES;j++)
1175 vap_offset[j] = offset - Offset[j][0];
1176 for(size_t i{0u};i < todo;)
1178 for(size_t j{0u};j < NUM_LINES;j++)
1179 vap_offset[j] &= delay.Mask;
1180 offset &= delay.Mask;
1182 size_t maxoff{offset};
1183 for(size_t j{0u};j < NUM_LINES;j++)
1184 maxoff = maxz(maxoff, vap_offset[j]);
1185 size_t td{minz(delay.Mask+1 - maxoff, todo - i)};
1187 do {
1188 std::array<float,NUM_LINES> f;
1189 for(size_t j{0u};j < NUM_LINES;j++)
1191 const float input{samples[j][i]};
1192 const float out{delay.Line[vap_offset[j]++][j] - feedCoeff*input};
1193 f[j] = input + feedCoeff*out;
1195 samples[j][i] = out;
1197 ++i;
1199 delay.Line[offset++] = VectorPartialScatter(f, xCoeff, yCoeff);
1200 } while(--td);
1203 void VecAllpass::processFaded(const al::span<ReverbUpdateLine,NUM_LINES> samples, size_t offset,
1204 const float xCoeff, const float yCoeff, float fadeCount, const float fadeStep,
1205 const size_t todo)
1207 const DelayLineI delay{Delay};
1208 const float feedCoeff{Coeff};
1210 ASSUME(todo > 0);
1212 size_t vap_offset[NUM_LINES][2];
1213 for(size_t j{0u};j < NUM_LINES;j++)
1215 vap_offset[j][0] = offset - Offset[j][0];
1216 vap_offset[j][1] = offset - Offset[j][1];
1218 for(size_t i{0u};i < todo;)
1220 for(size_t j{0u};j < NUM_LINES;j++)
1222 vap_offset[j][0] &= delay.Mask;
1223 vap_offset[j][1] &= delay.Mask;
1225 offset &= delay.Mask;
1227 size_t maxoff{offset};
1228 for(size_t j{0u};j < NUM_LINES;j++)
1229 maxoff = maxz(maxoff, maxz(vap_offset[j][0], vap_offset[j][1]));
1230 size_t td{minz(delay.Mask+1 - maxoff, todo - i)};
1232 do {
1233 fadeCount += 1.0f;
1234 const float fade{fadeCount * fadeStep};
1236 std::array<float,NUM_LINES> f;
1237 for(size_t j{0u};j < NUM_LINES;j++)
1238 f[j] = delay.Line[vap_offset[j][0]++][j]*(1.0f-fade) +
1239 delay.Line[vap_offset[j][1]++][j]*fade;
1241 for(size_t j{0u};j < NUM_LINES;j++)
1243 const float input{samples[j][i]};
1244 const float out{f[j] - feedCoeff*input};
1245 f[j] = input + feedCoeff*out;
1247 samples[j][i] = out;
1249 ++i;
1251 delay.Line[offset++] = VectorPartialScatter(f, xCoeff, yCoeff);
1252 } while(--td);
1256 /* This generates early reflections.
1258 * This is done by obtaining the primary reflections (those arriving from the
1259 * same direction as the source) from the main delay line. These are
1260 * attenuated and all-pass filtered (based on the diffusion parameter).
1262 * The early lines are then fed in reverse (according to the approximately
1263 * opposite spatial location of the A-Format lines) to create the secondary
1264 * reflections (those arriving from the opposite direction as the source).
1266 * The early response is then completed by combining the primary reflections
1267 * with the delayed and attenuated output from the early lines.
1269 * Finally, the early response is reversed, scattered (based on diffusion),
1270 * and fed into the late reverb section of the main delay line.
1272 * Two static specializations are used for transitional (cross-faded) delay
1273 * line processing and non-transitional processing.
1275 void ReverbState::earlyUnfaded(const size_t offset, const size_t todo)
1277 const DelayLineI early_delay{mEarly.Delay};
1278 const DelayLineI main_delay{mDelay};
1279 const float mixX{mMixX};
1280 const float mixY{mMixY};
1282 ASSUME(todo > 0);
1284 /* First, load decorrelated samples from the main delay line as the primary
1285 * reflections.
1287 for(size_t j{0u};j < NUM_LINES;j++)
1289 size_t early_delay_tap{offset - mEarlyDelayTap[j][0]};
1290 const float coeff{mEarlyDelayCoeff[j][0]};
1291 for(size_t i{0u};i < todo;)
1293 early_delay_tap &= main_delay.Mask;
1294 size_t td{minz(main_delay.Mask+1 - early_delay_tap, todo - i)};
1295 do {
1296 mTempSamples[j][i++] = main_delay.Line[early_delay_tap++][j] * coeff;
1297 } while(--td);
1301 /* Apply a vector all-pass, to help color the initial reflections based on
1302 * the diffusion strength.
1304 mEarly.VecAp.processUnfaded(mTempSamples, offset, mixX, mixY, todo);
1306 /* Apply a delay and bounce to generate secondary reflections, combine with
1307 * the primary reflections and write out the result for mixing.
1309 for(size_t j{0u};j < NUM_LINES;j++)
1311 size_t feedb_tap{offset - mEarly.Offset[j][0]};
1312 const float feedb_coeff{mEarly.Coeff[j][0]};
1313 float *out{mEarlySamples[j].data()};
1315 for(size_t i{0u};i < todo;)
1317 feedb_tap &= early_delay.Mask;
1318 size_t td{minz(early_delay.Mask+1 - feedb_tap, todo - i)};
1319 do {
1320 out[i] = mTempSamples[j][i] + early_delay.Line[feedb_tap++][j]*feedb_coeff;
1321 ++i;
1322 } while(--td);
1325 for(size_t j{0u};j < NUM_LINES;j++)
1326 early_delay.write(offset, NUM_LINES-1-j, mTempSamples[j].data(), todo);
1328 /* Also write the result back to the main delay line for the late reverb
1329 * stage to pick up at the appropriate time, appplying a scatter and
1330 * bounce to improve the initial diffusion in the late reverb.
1332 const size_t late_feed_tap{offset - mLateFeedTap};
1333 VectorScatterRevDelayIn(main_delay, late_feed_tap, mixX, mixY, mEarlySamples, todo);
1335 void ReverbState::earlyFaded(const size_t offset, const size_t todo, const float fade,
1336 const float fadeStep)
1338 const DelayLineI early_delay{mEarly.Delay};
1339 const DelayLineI main_delay{mDelay};
1340 const float mixX{mMixX};
1341 const float mixY{mMixY};
1343 ASSUME(todo > 0);
1345 for(size_t j{0u};j < NUM_LINES;j++)
1347 size_t early_delay_tap0{offset - mEarlyDelayTap[j][0]};
1348 size_t early_delay_tap1{offset - mEarlyDelayTap[j][1]};
1349 const float oldCoeff{mEarlyDelayCoeff[j][0]};
1350 const float oldCoeffStep{-oldCoeff * fadeStep};
1351 const float newCoeffStep{mEarlyDelayCoeff[j][1] * fadeStep};
1352 float fadeCount{fade};
1354 for(size_t i{0u};i < todo;)
1356 early_delay_tap0 &= main_delay.Mask;
1357 early_delay_tap1 &= main_delay.Mask;
1358 size_t td{minz(main_delay.Mask+1 - maxz(early_delay_tap0, early_delay_tap1), todo-i)};
1359 do {
1360 fadeCount += 1.0f;
1361 const float fade0{oldCoeff + oldCoeffStep*fadeCount};
1362 const float fade1{newCoeffStep*fadeCount};
1363 mTempSamples[j][i++] =
1364 main_delay.Line[early_delay_tap0++][j]*fade0 +
1365 main_delay.Line[early_delay_tap1++][j]*fade1;
1366 } while(--td);
1370 mEarly.VecAp.processFaded(mTempSamples, offset, mixX, mixY, fade, fadeStep, todo);
1372 for(size_t j{0u};j < NUM_LINES;j++)
1374 size_t feedb_tap0{offset - mEarly.Offset[j][0]};
1375 size_t feedb_tap1{offset - mEarly.Offset[j][1]};
1376 const float feedb_oldCoeff{mEarly.Coeff[j][0]};
1377 const float feedb_oldCoeffStep{-feedb_oldCoeff * fadeStep};
1378 const float feedb_newCoeffStep{mEarly.Coeff[j][1] * fadeStep};
1379 float *out{mEarlySamples[j].data()};
1380 float fadeCount{fade};
1382 for(size_t i{0u};i < todo;)
1384 feedb_tap0 &= early_delay.Mask;
1385 feedb_tap1 &= early_delay.Mask;
1386 size_t td{minz(early_delay.Mask+1 - maxz(feedb_tap0, feedb_tap1), todo - i)};
1388 do {
1389 fadeCount += 1.0f;
1390 const float fade0{feedb_oldCoeff + feedb_oldCoeffStep*fadeCount};
1391 const float fade1{feedb_newCoeffStep*fadeCount};
1392 out[i] = mTempSamples[j][i] +
1393 early_delay.Line[feedb_tap0++][j]*fade0 +
1394 early_delay.Line[feedb_tap1++][j]*fade1;
1395 ++i;
1396 } while(--td);
1399 for(size_t j{0u};j < NUM_LINES;j++)
1400 early_delay.write(offset, NUM_LINES-1-j, mTempSamples[j].data(), todo);
1402 const size_t late_feed_tap{offset - mLateFeedTap};
1403 VectorScatterRevDelayIn(main_delay, late_feed_tap, mixX, mixY, mEarlySamples, todo);
1407 void Modulation::calcDelays(size_t todo)
1409 constexpr float inv_scale{MOD_FRACONE / al::MathDefs<float>::Tau()};
1410 ALuint idx{Index};
1411 const ALuint step{Step};
1412 const float depth{Depth[0]};
1413 for(size_t i{0};i < todo;++i)
1415 idx += step;
1416 const float lfo{std::sin(static_cast<float>(idx&MOD_FRACMASK) / inv_scale)};
1417 ModDelays[i] = (lfo+1.0f) * depth;
1419 Index = idx;
1422 void Modulation::calcFadedDelays(size_t todo, float fadeCount, float fadeStep)
1424 constexpr float inv_scale{MOD_FRACONE / al::MathDefs<float>::Tau()};
1425 ALuint idx{Index};
1426 const ALuint step{Step};
1427 const float depth{Depth[0]};
1428 const float depthStep{(Depth[1]-depth) * fadeStep};
1429 for(size_t i{0};i < todo;++i)
1431 fadeCount += 1.0f;
1432 idx += step;
1433 const float lfo{std::sin(static_cast<float>(idx&MOD_FRACMASK) / inv_scale)};
1434 ModDelays[i] = (lfo+1.0f) * (depth + depthStep*fadeCount);
1436 Index = idx;
1440 /* This generates the reverb tail using a modified feed-back delay network
1441 * (FDN).
1443 * Results from the early reflections are mixed with the output from the
1444 * modulated late delay lines.
1446 * The late response is then completed by T60 and all-pass filtering the mix.
1448 * Finally, the lines are reversed (so they feed their opposite directions)
1449 * and scattered with the FDN matrix before re-feeding the delay lines.
1451 * Two variations are made, one for for transitional (cross-faded) delay line
1452 * processing and one for non-transitional processing.
1454 void ReverbState::lateUnfaded(const size_t offset, const size_t todo)
1456 const DelayLineI late_delay{mLate.Delay};
1457 const DelayLineI main_delay{mDelay};
1458 const float mixX{mMixX};
1459 const float mixY{mMixY};
1461 ASSUME(todo > 0);
1463 /* First, calculate the modulated delays for the late feedback. */
1464 mLate.Mod.calcDelays(todo);
1466 /* Next, load decorrelated samples from the main and feedback delay lines.
1467 * Filter the signal to apply its frequency-dependent decay.
1469 for(size_t j{0u};j < NUM_LINES;j++)
1471 size_t late_delay_tap{offset - mLateDelayTap[j][0]};
1472 size_t late_feedb_tap{offset - mLate.Offset[j][0]};
1473 const float midGain{mLate.T60[j].MidGain[0]};
1474 const float densityGain{mLate.DensityGain[0] * midGain};
1476 for(size_t i{0u};i < todo;)
1478 late_delay_tap &= main_delay.Mask;
1479 size_t td{minz(todo - i, main_delay.Mask+1 - late_delay_tap)};
1480 do {
1481 /* Calculate the read offset and fraction between it and the
1482 * next sample.
1484 const float fdelay{mLate.Mod.ModDelays[i]};
1485 const size_t delay{float2uint(fdelay)};
1486 const float frac{fdelay - static_cast<float>(delay)};
1488 /* Feed the delay line with the late feedback sample, and get
1489 * the two samples crossed by the delayed offset.
1491 const float out0{late_delay.Line[(late_feedb_tap-delay) & late_delay.Mask][j]};
1492 const float out1{late_delay.Line[(late_feedb_tap-delay-1) & late_delay.Mask][j]};
1493 ++late_feedb_tap;
1495 /* The output is obtained by linearly interpolating the two
1496 * samples that were acquired above, and combined with the main
1497 * delay tap.
1499 mTempSamples[j][i] = lerp(out0, out1, frac)*midGain +
1500 main_delay.Line[late_delay_tap++][j]*densityGain;
1501 ++i;
1502 } while(--td);
1504 mLate.T60[j].process({mTempSamples[j].data(), todo});
1507 /* Apply a vector all-pass to improve micro-surface diffusion, and write
1508 * out the results for mixing.
1510 mLate.VecAp.processUnfaded(mTempSamples, offset, mixX, mixY, todo);
1511 for(size_t j{0u};j < NUM_LINES;j++)
1512 std::copy_n(mTempSamples[j].begin(), todo, mLateSamples[j].begin());
1514 /* Finally, scatter and bounce the results to refeed the feedback buffer. */
1515 VectorScatterRevDelayIn(late_delay, offset, mixX, mixY, mTempSamples, todo);
1517 void ReverbState::lateFaded(const size_t offset, const size_t todo, const float fade,
1518 const float fadeStep)
1520 const DelayLineI late_delay{mLate.Delay};
1521 const DelayLineI main_delay{mDelay};
1522 const float mixX{mMixX};
1523 const float mixY{mMixY};
1525 ASSUME(todo > 0);
1527 mLate.Mod.calcFadedDelays(todo, fade, fadeStep);
1529 for(size_t j{0u};j < NUM_LINES;j++)
1531 const float oldMidGain{mLate.T60[j].MidGain[0]};
1532 const float midGain{mLate.T60[j].MidGain[1]};
1533 const float oldMidStep{-oldMidGain * fadeStep};
1534 const float midStep{midGain * fadeStep};
1535 const float oldDensityGain{mLate.DensityGain[0] * oldMidGain};
1536 const float densityGain{mLate.DensityGain[1] * midGain};
1537 const float oldDensityStep{-oldDensityGain * fadeStep};
1538 const float densityStep{densityGain * fadeStep};
1539 size_t late_delay_tap0{offset - mLateDelayTap[j][0]};
1540 size_t late_delay_tap1{offset - mLateDelayTap[j][1]};
1541 size_t late_feedb_tap0{offset - mLate.Offset[j][0]};
1542 size_t late_feedb_tap1{offset - mLate.Offset[j][1]};
1543 float fadeCount{fade};
1545 for(size_t i{0u};i < todo;)
1547 late_delay_tap0 &= main_delay.Mask;
1548 late_delay_tap1 &= main_delay.Mask;
1549 size_t td{minz(todo - i, main_delay.Mask+1 - maxz(late_delay_tap0, late_delay_tap1))};
1550 do {
1551 fadeCount += 1.0f;
1553 const float fdelay{mLate.Mod.ModDelays[i]};
1554 const size_t delay{float2uint(fdelay)};
1555 const float frac{fdelay - static_cast<float>(delay)};
1557 const float out00{late_delay.Line[(late_feedb_tap0-delay) & late_delay.Mask][j]};
1558 const float out01{late_delay.Line[(late_feedb_tap0-delay-1) & late_delay.Mask][j]};
1559 ++late_feedb_tap0;
1560 const float out10{late_delay.Line[(late_feedb_tap1-delay) & late_delay.Mask][j]};
1561 const float out11{late_delay.Line[(late_feedb_tap1-delay-1) & late_delay.Mask][j]};
1562 ++late_feedb_tap1;
1564 const float fade0{oldDensityGain + oldDensityStep*fadeCount};
1565 const float fade1{densityStep*fadeCount};
1566 const float gfade0{oldMidGain + oldMidStep*fadeCount};
1567 const float gfade1{midStep*fadeCount};
1568 mTempSamples[j][i] = lerp(out00, out01, frac)*gfade0 +
1569 lerp(out10, out11, frac)*gfade1 +
1570 main_delay.Line[late_delay_tap0++][j]*fade0 +
1571 main_delay.Line[late_delay_tap1++][j]*fade1;
1572 ++i;
1573 } while(--td);
1575 mLate.T60[j].process({mTempSamples[j].data(), todo});
1578 mLate.VecAp.processFaded(mTempSamples, offset, mixX, mixY, fade, fadeStep, todo);
1579 for(size_t j{0u};j < NUM_LINES;j++)
1580 std::copy_n(mTempSamples[j].begin(), todo, mLateSamples[j].begin());
1582 VectorScatterRevDelayIn(late_delay, offset, mixX, mixY, mTempSamples, todo);
1585 void ReverbState::process(const size_t samplesToDo, const al::span<const FloatBufferLine> samplesIn, const al::span<FloatBufferLine> samplesOut)
1587 size_t offset{mOffset};
1589 ASSUME(samplesToDo > 0);
1591 /* Convert B-Format to A-Format for processing. */
1592 const size_t numInput{minz(samplesIn.size(), NUM_LINES)};
1593 const al::span<float> tmpspan{al::assume_aligned<16>(mTempLine.data()), samplesToDo};
1594 for(size_t c{0u};c < NUM_LINES;c++)
1596 std::fill(tmpspan.begin(), tmpspan.end(), 0.0f);
1597 for(size_t i{0};i < numInput;++i)
1599 const float gain{B2A[c][i]};
1600 const float *RESTRICT input{al::assume_aligned<16>(samplesIn[i].data())};
1602 for(float &sample : tmpspan)
1604 sample += *input * gain;
1605 ++input;
1609 /* Band-pass the incoming samples and feed the initial delay line. */
1610 DualBiquad{mFilter[c].Lp, mFilter[c].Hp}.process(tmpspan, tmpspan.data());
1611 mDelay.write(offset, c, tmpspan.cbegin(), samplesToDo);
1614 /* Process reverb for these samples. */
1615 if LIKELY(!mDoFading)
1617 for(size_t base{0};base < samplesToDo;)
1619 /* Calculate the number of samples we can do this iteration. */
1620 size_t todo{minz(samplesToDo - base, mMaxUpdate[0])};
1621 /* Some mixers require maintaining a 4-sample alignment, so ensure
1622 * that if it's not the last iteration.
1624 if(base+todo < samplesToDo) todo &= ~size_t{3};
1625 ASSUME(todo > 0);
1627 /* Generate non-faded early reflections and late reverb. */
1628 earlyUnfaded(offset, todo);
1629 lateUnfaded(offset, todo);
1631 /* Finally, mix early reflections and late reverb. */
1632 (this->*mMixOut)(samplesOut, samplesToDo-base, base, todo);
1634 offset += todo;
1635 base += todo;
1638 else
1640 const float fadeStep{1.0f / static_cast<float>(samplesToDo)};
1641 for(size_t base{0};base < samplesToDo;)
1643 size_t todo{minz(samplesToDo - base, minz(mMaxUpdate[0], mMaxUpdate[1]))};
1644 if(base+todo < samplesToDo) todo &= ~size_t{3};
1645 ASSUME(todo > 0);
1647 /* Generate cross-faded early reflections and late reverb. */
1648 auto fadeCount = static_cast<float>(base);
1649 earlyFaded(offset, todo, fadeCount, fadeStep);
1650 lateFaded(offset, todo, fadeCount, fadeStep);
1652 (this->*mMixOut)(samplesOut, samplesToDo-base, base, todo);
1654 offset += todo;
1655 base += todo;
1658 /* Update the cross-fading delay line taps. */
1659 for(size_t c{0u};c < NUM_LINES;c++)
1661 mEarlyDelayTap[c][0] = mEarlyDelayTap[c][1];
1662 mEarlyDelayCoeff[c][0] = mEarlyDelayCoeff[c][1];
1663 mLateDelayTap[c][0] = mLateDelayTap[c][1];
1664 mEarly.VecAp.Offset[c][0] = mEarly.VecAp.Offset[c][1];
1665 mEarly.Offset[c][0] = mEarly.Offset[c][1];
1666 mEarly.Coeff[c][0] = mEarly.Coeff[c][1];
1667 mLate.Offset[c][0] = mLate.Offset[c][1];
1668 mLate.T60[c].MidGain[0] = mLate.T60[c].MidGain[1];
1669 mLate.VecAp.Offset[c][0] = mLate.VecAp.Offset[c][1];
1671 mLate.DensityGain[0] = mLate.DensityGain[1];
1672 mLate.Mod.Depth[0] = mLate.Mod.Depth[1];
1673 mMaxUpdate[0] = mMaxUpdate[1];
1674 mDoFading = false;
1676 mOffset = offset;
1680 void EAXReverb_setParami(EffectProps *props, ALenum param, int val)
1682 switch(param)
1684 case AL_EAXREVERB_DECAY_HFLIMIT:
1685 if(!(val >= AL_EAXREVERB_MIN_DECAY_HFLIMIT && val <= AL_EAXREVERB_MAX_DECAY_HFLIMIT))
1686 throw effect_exception{AL_INVALID_VALUE, "EAX Reverb decay hflimit out of range"};
1687 props->Reverb.DecayHFLimit = val != AL_FALSE;
1688 break;
1690 default:
1691 throw effect_exception{AL_INVALID_ENUM, "Invalid EAX reverb integer property 0x%04x",
1692 param};
1695 void EAXReverb_setParamiv(EffectProps *props, ALenum param, const int *vals)
1696 { EAXReverb_setParami(props, param, vals[0]); }
1697 void EAXReverb_setParamf(EffectProps *props, ALenum param, float val)
1699 switch(param)
1701 case AL_EAXREVERB_DENSITY:
1702 if(!(val >= AL_EAXREVERB_MIN_DENSITY && val <= AL_EAXREVERB_MAX_DENSITY))
1703 throw effect_exception{AL_INVALID_VALUE, "EAX Reverb density out of range"};
1704 props->Reverb.Density = val;
1705 break;
1707 case AL_EAXREVERB_DIFFUSION:
1708 if(!(val >= AL_EAXREVERB_MIN_DIFFUSION && val <= AL_EAXREVERB_MAX_DIFFUSION))
1709 throw effect_exception{AL_INVALID_VALUE, "EAX Reverb diffusion out of range"};
1710 props->Reverb.Diffusion = val;
1711 break;
1713 case AL_EAXREVERB_GAIN:
1714 if(!(val >= AL_EAXREVERB_MIN_GAIN && val <= AL_EAXREVERB_MAX_GAIN))
1715 throw effect_exception{AL_INVALID_VALUE, "EAX Reverb gain out of range"};
1716 props->Reverb.Gain = val;
1717 break;
1719 case AL_EAXREVERB_GAINHF:
1720 if(!(val >= AL_EAXREVERB_MIN_GAINHF && val <= AL_EAXREVERB_MAX_GAINHF))
1721 throw effect_exception{AL_INVALID_VALUE, "EAX Reverb gainhf out of range"};
1722 props->Reverb.GainHF = val;
1723 break;
1725 case AL_EAXREVERB_GAINLF:
1726 if(!(val >= AL_EAXREVERB_MIN_GAINLF && val <= AL_EAXREVERB_MAX_GAINLF))
1727 throw effect_exception{AL_INVALID_VALUE, "EAX Reverb gainlf out of range"};
1728 props->Reverb.GainLF = val;
1729 break;
1731 case AL_EAXREVERB_DECAY_TIME:
1732 if(!(val >= AL_EAXREVERB_MIN_DECAY_TIME && val <= AL_EAXREVERB_MAX_DECAY_TIME))
1733 throw effect_exception{AL_INVALID_VALUE, "EAX Reverb decay time out of range"};
1734 props->Reverb.DecayTime = val;
1735 break;
1737 case AL_EAXREVERB_DECAY_HFRATIO:
1738 if(!(val >= AL_EAXREVERB_MIN_DECAY_HFRATIO && val <= AL_EAXREVERB_MAX_DECAY_HFRATIO))
1739 throw effect_exception{AL_INVALID_VALUE, "EAX Reverb decay hfratio out of range"};
1740 props->Reverb.DecayHFRatio = val;
1741 break;
1743 case AL_EAXREVERB_DECAY_LFRATIO:
1744 if(!(val >= AL_EAXREVERB_MIN_DECAY_LFRATIO && val <= AL_EAXREVERB_MAX_DECAY_LFRATIO))
1745 throw effect_exception{AL_INVALID_VALUE, "EAX Reverb decay lfratio out of range"};
1746 props->Reverb.DecayLFRatio = val;
1747 break;
1749 case AL_EAXREVERB_REFLECTIONS_GAIN:
1750 if(!(val >= AL_EAXREVERB_MIN_REFLECTIONS_GAIN && val <= AL_EAXREVERB_MAX_REFLECTIONS_GAIN))
1751 throw effect_exception{AL_INVALID_VALUE, "EAX Reverb reflections gain out of range"};
1752 props->Reverb.ReflectionsGain = val;
1753 break;
1755 case AL_EAXREVERB_REFLECTIONS_DELAY:
1756 if(!(val >= AL_EAXREVERB_MIN_REFLECTIONS_DELAY && val <= AL_EAXREVERB_MAX_REFLECTIONS_DELAY))
1757 throw effect_exception{AL_INVALID_VALUE, "EAX Reverb reflections delay out of range"};
1758 props->Reverb.ReflectionsDelay = val;
1759 break;
1761 case AL_EAXREVERB_LATE_REVERB_GAIN:
1762 if(!(val >= AL_EAXREVERB_MIN_LATE_REVERB_GAIN && val <= AL_EAXREVERB_MAX_LATE_REVERB_GAIN))
1763 throw effect_exception{AL_INVALID_VALUE, "EAX Reverb late reverb gain out of range"};
1764 props->Reverb.LateReverbGain = val;
1765 break;
1767 case AL_EAXREVERB_LATE_REVERB_DELAY:
1768 if(!(val >= AL_EAXREVERB_MIN_LATE_REVERB_DELAY && val <= AL_EAXREVERB_MAX_LATE_REVERB_DELAY))
1769 throw effect_exception{AL_INVALID_VALUE, "EAX Reverb late reverb delay out of range"};
1770 props->Reverb.LateReverbDelay = val;
1771 break;
1773 case AL_EAXREVERB_AIR_ABSORPTION_GAINHF:
1774 if(!(val >= AL_EAXREVERB_MIN_AIR_ABSORPTION_GAINHF && val <= AL_EAXREVERB_MAX_AIR_ABSORPTION_GAINHF))
1775 throw effect_exception{AL_INVALID_VALUE, "EAX Reverb air absorption gainhf out of range"};
1776 props->Reverb.AirAbsorptionGainHF = val;
1777 break;
1779 case AL_EAXREVERB_ECHO_TIME:
1780 if(!(val >= AL_EAXREVERB_MIN_ECHO_TIME && val <= AL_EAXREVERB_MAX_ECHO_TIME))
1781 throw effect_exception{AL_INVALID_VALUE, "EAX Reverb echo time out of range"};
1782 props->Reverb.EchoTime = val;
1783 break;
1785 case AL_EAXREVERB_ECHO_DEPTH:
1786 if(!(val >= AL_EAXREVERB_MIN_ECHO_DEPTH && val <= AL_EAXREVERB_MAX_ECHO_DEPTH))
1787 throw effect_exception{AL_INVALID_VALUE, "EAX Reverb echo depth out of range"};
1788 props->Reverb.EchoDepth = val;
1789 break;
1791 case AL_EAXREVERB_MODULATION_TIME:
1792 if(!(val >= AL_EAXREVERB_MIN_MODULATION_TIME && val <= AL_EAXREVERB_MAX_MODULATION_TIME))
1793 throw effect_exception{AL_INVALID_VALUE, "EAX Reverb modulation time out of range"};
1794 props->Reverb.ModulationTime = val;
1795 break;
1797 case AL_EAXREVERB_MODULATION_DEPTH:
1798 if(!(val >= AL_EAXREVERB_MIN_MODULATION_DEPTH && val <= AL_EAXREVERB_MAX_MODULATION_DEPTH))
1799 throw effect_exception{AL_INVALID_VALUE, "EAX Reverb modulation depth out of range"};
1800 props->Reverb.ModulationDepth = val;
1801 break;
1803 case AL_EAXREVERB_HFREFERENCE:
1804 if(!(val >= AL_EAXREVERB_MIN_HFREFERENCE && val <= AL_EAXREVERB_MAX_HFREFERENCE))
1805 throw effect_exception{AL_INVALID_VALUE, "EAX Reverb hfreference out of range"};
1806 props->Reverb.HFReference = val;
1807 break;
1809 case AL_EAXREVERB_LFREFERENCE:
1810 if(!(val >= AL_EAXREVERB_MIN_LFREFERENCE && val <= AL_EAXREVERB_MAX_LFREFERENCE))
1811 throw effect_exception{AL_INVALID_VALUE, "EAX Reverb lfreference out of range"};
1812 props->Reverb.LFReference = val;
1813 break;
1815 case AL_EAXREVERB_ROOM_ROLLOFF_FACTOR:
1816 if(!(val >= AL_EAXREVERB_MIN_ROOM_ROLLOFF_FACTOR && val <= AL_EAXREVERB_MAX_ROOM_ROLLOFF_FACTOR))
1817 throw effect_exception{AL_INVALID_VALUE, "EAX Reverb room rolloff factor out of range"};
1818 props->Reverb.RoomRolloffFactor = val;
1819 break;
1821 default:
1822 throw effect_exception{AL_INVALID_ENUM, "Invalid EAX reverb float property 0x%04x", param};
1825 void EAXReverb_setParamfv(EffectProps *props, ALenum param, const float *vals)
1827 switch(param)
1829 case AL_EAXREVERB_REFLECTIONS_PAN:
1830 if(!(std::isfinite(vals[0]) && std::isfinite(vals[1]) && std::isfinite(vals[2])))
1831 throw effect_exception{AL_INVALID_VALUE, "EAX Reverb reflections pan out of range"};
1832 props->Reverb.ReflectionsPan[0] = vals[0];
1833 props->Reverb.ReflectionsPan[1] = vals[1];
1834 props->Reverb.ReflectionsPan[2] = vals[2];
1835 break;
1836 case AL_EAXREVERB_LATE_REVERB_PAN:
1837 if(!(std::isfinite(vals[0]) && std::isfinite(vals[1]) && std::isfinite(vals[2])))
1838 throw effect_exception{AL_INVALID_VALUE, "EAX Reverb late reverb pan out of range"};
1839 props->Reverb.LateReverbPan[0] = vals[0];
1840 props->Reverb.LateReverbPan[1] = vals[1];
1841 props->Reverb.LateReverbPan[2] = vals[2];
1842 break;
1844 default:
1845 EAXReverb_setParamf(props, param, vals[0]);
1846 break;
1850 void EAXReverb_getParami(const EffectProps *props, ALenum param, int *val)
1852 switch(param)
1854 case AL_EAXREVERB_DECAY_HFLIMIT:
1855 *val = props->Reverb.DecayHFLimit;
1856 break;
1858 default:
1859 throw effect_exception{AL_INVALID_ENUM, "Invalid EAX reverb integer property 0x%04x",
1860 param};
1863 void EAXReverb_getParamiv(const EffectProps *props, ALenum param, int *vals)
1864 { EAXReverb_getParami(props, param, vals); }
1865 void EAXReverb_getParamf(const EffectProps *props, ALenum param, float *val)
1867 switch(param)
1869 case AL_EAXREVERB_DENSITY:
1870 *val = props->Reverb.Density;
1871 break;
1873 case AL_EAXREVERB_DIFFUSION:
1874 *val = props->Reverb.Diffusion;
1875 break;
1877 case AL_EAXREVERB_GAIN:
1878 *val = props->Reverb.Gain;
1879 break;
1881 case AL_EAXREVERB_GAINHF:
1882 *val = props->Reverb.GainHF;
1883 break;
1885 case AL_EAXREVERB_GAINLF:
1886 *val = props->Reverb.GainLF;
1887 break;
1889 case AL_EAXREVERB_DECAY_TIME:
1890 *val = props->Reverb.DecayTime;
1891 break;
1893 case AL_EAXREVERB_DECAY_HFRATIO:
1894 *val = props->Reverb.DecayHFRatio;
1895 break;
1897 case AL_EAXREVERB_DECAY_LFRATIO:
1898 *val = props->Reverb.DecayLFRatio;
1899 break;
1901 case AL_EAXREVERB_REFLECTIONS_GAIN:
1902 *val = props->Reverb.ReflectionsGain;
1903 break;
1905 case AL_EAXREVERB_REFLECTIONS_DELAY:
1906 *val = props->Reverb.ReflectionsDelay;
1907 break;
1909 case AL_EAXREVERB_LATE_REVERB_GAIN:
1910 *val = props->Reverb.LateReverbGain;
1911 break;
1913 case AL_EAXREVERB_LATE_REVERB_DELAY:
1914 *val = props->Reverb.LateReverbDelay;
1915 break;
1917 case AL_EAXREVERB_AIR_ABSORPTION_GAINHF:
1918 *val = props->Reverb.AirAbsorptionGainHF;
1919 break;
1921 case AL_EAXREVERB_ECHO_TIME:
1922 *val = props->Reverb.EchoTime;
1923 break;
1925 case AL_EAXREVERB_ECHO_DEPTH:
1926 *val = props->Reverb.EchoDepth;
1927 break;
1929 case AL_EAXREVERB_MODULATION_TIME:
1930 *val = props->Reverb.ModulationTime;
1931 break;
1933 case AL_EAXREVERB_MODULATION_DEPTH:
1934 *val = props->Reverb.ModulationDepth;
1935 break;
1937 case AL_EAXREVERB_HFREFERENCE:
1938 *val = props->Reverb.HFReference;
1939 break;
1941 case AL_EAXREVERB_LFREFERENCE:
1942 *val = props->Reverb.LFReference;
1943 break;
1945 case AL_EAXREVERB_ROOM_ROLLOFF_FACTOR:
1946 *val = props->Reverb.RoomRolloffFactor;
1947 break;
1949 default:
1950 throw effect_exception{AL_INVALID_ENUM, "Invalid EAX reverb float property 0x%04x", param};
1953 void EAXReverb_getParamfv(const EffectProps *props, ALenum param, float *vals)
1955 switch(param)
1957 case AL_EAXREVERB_REFLECTIONS_PAN:
1958 vals[0] = props->Reverb.ReflectionsPan[0];
1959 vals[1] = props->Reverb.ReflectionsPan[1];
1960 vals[2] = props->Reverb.ReflectionsPan[2];
1961 break;
1962 case AL_EAXREVERB_LATE_REVERB_PAN:
1963 vals[0] = props->Reverb.LateReverbPan[0];
1964 vals[1] = props->Reverb.LateReverbPan[1];
1965 vals[2] = props->Reverb.LateReverbPan[2];
1966 break;
1968 default:
1969 EAXReverb_getParamf(props, param, vals);
1970 break;
1974 DEFINE_ALEFFECT_VTABLE(EAXReverb);
1977 struct ReverbStateFactory final : public EffectStateFactory {
1978 EffectState *create() override { return new ReverbState{}; }
1979 EffectProps getDefaultProps() const noexcept override;
1980 const EffectVtable *getEffectVtable() const noexcept override { return &EAXReverb_vtable; }
1983 EffectProps ReverbStateFactory::getDefaultProps() const noexcept
1985 EffectProps props{};
1986 props.Reverb.Density = AL_EAXREVERB_DEFAULT_DENSITY;
1987 props.Reverb.Diffusion = AL_EAXREVERB_DEFAULT_DIFFUSION;
1988 props.Reverb.Gain = AL_EAXREVERB_DEFAULT_GAIN;
1989 props.Reverb.GainHF = AL_EAXREVERB_DEFAULT_GAINHF;
1990 props.Reverb.GainLF = AL_EAXREVERB_DEFAULT_GAINLF;
1991 props.Reverb.DecayTime = AL_EAXREVERB_DEFAULT_DECAY_TIME;
1992 props.Reverb.DecayHFRatio = AL_EAXREVERB_DEFAULT_DECAY_HFRATIO;
1993 props.Reverb.DecayLFRatio = AL_EAXREVERB_DEFAULT_DECAY_LFRATIO;
1994 props.Reverb.ReflectionsGain = AL_EAXREVERB_DEFAULT_REFLECTIONS_GAIN;
1995 props.Reverb.ReflectionsDelay = AL_EAXREVERB_DEFAULT_REFLECTIONS_DELAY;
1996 props.Reverb.ReflectionsPan[0] = AL_EAXREVERB_DEFAULT_REFLECTIONS_PAN_XYZ;
1997 props.Reverb.ReflectionsPan[1] = AL_EAXREVERB_DEFAULT_REFLECTIONS_PAN_XYZ;
1998 props.Reverb.ReflectionsPan[2] = AL_EAXREVERB_DEFAULT_REFLECTIONS_PAN_XYZ;
1999 props.Reverb.LateReverbGain = AL_EAXREVERB_DEFAULT_LATE_REVERB_GAIN;
2000 props.Reverb.LateReverbDelay = AL_EAXREVERB_DEFAULT_LATE_REVERB_DELAY;
2001 props.Reverb.LateReverbPan[0] = AL_EAXREVERB_DEFAULT_LATE_REVERB_PAN_XYZ;
2002 props.Reverb.LateReverbPan[1] = AL_EAXREVERB_DEFAULT_LATE_REVERB_PAN_XYZ;
2003 props.Reverb.LateReverbPan[2] = AL_EAXREVERB_DEFAULT_LATE_REVERB_PAN_XYZ;
2004 props.Reverb.EchoTime = AL_EAXREVERB_DEFAULT_ECHO_TIME;
2005 props.Reverb.EchoDepth = AL_EAXREVERB_DEFAULT_ECHO_DEPTH;
2006 props.Reverb.ModulationTime = AL_EAXREVERB_DEFAULT_MODULATION_TIME;
2007 props.Reverb.ModulationDepth = AL_EAXREVERB_DEFAULT_MODULATION_DEPTH;
2008 props.Reverb.AirAbsorptionGainHF = AL_EAXREVERB_DEFAULT_AIR_ABSORPTION_GAINHF;
2009 props.Reverb.HFReference = AL_EAXREVERB_DEFAULT_HFREFERENCE;
2010 props.Reverb.LFReference = AL_EAXREVERB_DEFAULT_LFREFERENCE;
2011 props.Reverb.RoomRolloffFactor = AL_EAXREVERB_DEFAULT_ROOM_ROLLOFF_FACTOR;
2012 props.Reverb.DecayHFLimit = AL_EAXREVERB_DEFAULT_DECAY_HFLIMIT;
2013 return props;
2017 void StdReverb_setParami(EffectProps *props, ALenum param, int val)
2019 switch(param)
2021 case AL_REVERB_DECAY_HFLIMIT:
2022 if(!(val >= AL_REVERB_MIN_DECAY_HFLIMIT && val <= AL_REVERB_MAX_DECAY_HFLIMIT))
2023 throw effect_exception{AL_INVALID_VALUE, "Reverb decay hflimit out of range"};
2024 props->Reverb.DecayHFLimit = val != AL_FALSE;
2025 break;
2027 default:
2028 throw effect_exception{AL_INVALID_ENUM, "Invalid reverb integer property 0x%04x", param};
2031 void StdReverb_setParamiv(EffectProps *props, ALenum param, const int *vals)
2032 { StdReverb_setParami(props, param, vals[0]); }
2033 void StdReverb_setParamf(EffectProps *props, ALenum param, float val)
2035 switch(param)
2037 case AL_REVERB_DENSITY:
2038 if(!(val >= AL_REVERB_MIN_DENSITY && val <= AL_REVERB_MAX_DENSITY))
2039 throw effect_exception{AL_INVALID_VALUE, "Reverb density out of range"};
2040 props->Reverb.Density = val;
2041 break;
2043 case AL_REVERB_DIFFUSION:
2044 if(!(val >= AL_REVERB_MIN_DIFFUSION && val <= AL_REVERB_MAX_DIFFUSION))
2045 throw effect_exception{AL_INVALID_VALUE, "Reverb diffusion out of range"};
2046 props->Reverb.Diffusion = val;
2047 break;
2049 case AL_REVERB_GAIN:
2050 if(!(val >= AL_REVERB_MIN_GAIN && val <= AL_REVERB_MAX_GAIN))
2051 throw effect_exception{AL_INVALID_VALUE, "Reverb gain out of range"};
2052 props->Reverb.Gain = val;
2053 break;
2055 case AL_REVERB_GAINHF:
2056 if(!(val >= AL_REVERB_MIN_GAINHF && val <= AL_REVERB_MAX_GAINHF))
2057 throw effect_exception{AL_INVALID_VALUE, "Reverb gainhf out of range"};
2058 props->Reverb.GainHF = val;
2059 break;
2061 case AL_REVERB_DECAY_TIME:
2062 if(!(val >= AL_REVERB_MIN_DECAY_TIME && val <= AL_REVERB_MAX_DECAY_TIME))
2063 throw effect_exception{AL_INVALID_VALUE, "Reverb decay time out of range"};
2064 props->Reverb.DecayTime = val;
2065 break;
2067 case AL_REVERB_DECAY_HFRATIO:
2068 if(!(val >= AL_REVERB_MIN_DECAY_HFRATIO && val <= AL_REVERB_MAX_DECAY_HFRATIO))
2069 throw effect_exception{AL_INVALID_VALUE, "Reverb decay hfratio out of range"};
2070 props->Reverb.DecayHFRatio = val;
2071 break;
2073 case AL_REVERB_REFLECTIONS_GAIN:
2074 if(!(val >= AL_REVERB_MIN_REFLECTIONS_GAIN && val <= AL_REVERB_MAX_REFLECTIONS_GAIN))
2075 throw effect_exception{AL_INVALID_VALUE, "Reverb reflections gain out of range"};
2076 props->Reverb.ReflectionsGain = val;
2077 break;
2079 case AL_REVERB_REFLECTIONS_DELAY:
2080 if(!(val >= AL_REVERB_MIN_REFLECTIONS_DELAY && val <= AL_REVERB_MAX_REFLECTIONS_DELAY))
2081 throw effect_exception{AL_INVALID_VALUE, "Reverb reflections delay out of range"};
2082 props->Reverb.ReflectionsDelay = val;
2083 break;
2085 case AL_REVERB_LATE_REVERB_GAIN:
2086 if(!(val >= AL_REVERB_MIN_LATE_REVERB_GAIN && val <= AL_REVERB_MAX_LATE_REVERB_GAIN))
2087 throw effect_exception{AL_INVALID_VALUE, "Reverb late reverb gain out of range"};
2088 props->Reverb.LateReverbGain = val;
2089 break;
2091 case AL_REVERB_LATE_REVERB_DELAY:
2092 if(!(val >= AL_REVERB_MIN_LATE_REVERB_DELAY && val <= AL_REVERB_MAX_LATE_REVERB_DELAY))
2093 throw effect_exception{AL_INVALID_VALUE, "Reverb late reverb delay out of range"};
2094 props->Reverb.LateReverbDelay = val;
2095 break;
2097 case AL_REVERB_AIR_ABSORPTION_GAINHF:
2098 if(!(val >= AL_REVERB_MIN_AIR_ABSORPTION_GAINHF && val <= AL_REVERB_MAX_AIR_ABSORPTION_GAINHF))
2099 throw effect_exception{AL_INVALID_VALUE, "Reverb air absorption gainhf out of range"};
2100 props->Reverb.AirAbsorptionGainHF = val;
2101 break;
2103 case AL_REVERB_ROOM_ROLLOFF_FACTOR:
2104 if(!(val >= AL_REVERB_MIN_ROOM_ROLLOFF_FACTOR && val <= AL_REVERB_MAX_ROOM_ROLLOFF_FACTOR))
2105 throw effect_exception{AL_INVALID_VALUE, "Reverb room rolloff factor out of range"};
2106 props->Reverb.RoomRolloffFactor = val;
2107 break;
2109 default:
2110 throw effect_exception{AL_INVALID_ENUM, "Invalid reverb float property 0x%04x", param};
2113 void StdReverb_setParamfv(EffectProps *props, ALenum param, const float *vals)
2114 { StdReverb_setParamf(props, param, vals[0]); }
2116 void StdReverb_getParami(const EffectProps *props, ALenum param, int *val)
2118 switch(param)
2120 case AL_REVERB_DECAY_HFLIMIT:
2121 *val = props->Reverb.DecayHFLimit;
2122 break;
2124 default:
2125 throw effect_exception{AL_INVALID_ENUM, "Invalid reverb integer property 0x%04x", param};
2128 void StdReverb_getParamiv(const EffectProps *props, ALenum param, int *vals)
2129 { StdReverb_getParami(props, param, vals); }
2130 void StdReverb_getParamf(const EffectProps *props, ALenum param, float *val)
2132 switch(param)
2134 case AL_REVERB_DENSITY:
2135 *val = props->Reverb.Density;
2136 break;
2138 case AL_REVERB_DIFFUSION:
2139 *val = props->Reverb.Diffusion;
2140 break;
2142 case AL_REVERB_GAIN:
2143 *val = props->Reverb.Gain;
2144 break;
2146 case AL_REVERB_GAINHF:
2147 *val = props->Reverb.GainHF;
2148 break;
2150 case AL_REVERB_DECAY_TIME:
2151 *val = props->Reverb.DecayTime;
2152 break;
2154 case AL_REVERB_DECAY_HFRATIO:
2155 *val = props->Reverb.DecayHFRatio;
2156 break;
2158 case AL_REVERB_REFLECTIONS_GAIN:
2159 *val = props->Reverb.ReflectionsGain;
2160 break;
2162 case AL_REVERB_REFLECTIONS_DELAY:
2163 *val = props->Reverb.ReflectionsDelay;
2164 break;
2166 case AL_REVERB_LATE_REVERB_GAIN:
2167 *val = props->Reverb.LateReverbGain;
2168 break;
2170 case AL_REVERB_LATE_REVERB_DELAY:
2171 *val = props->Reverb.LateReverbDelay;
2172 break;
2174 case AL_REVERB_AIR_ABSORPTION_GAINHF:
2175 *val = props->Reverb.AirAbsorptionGainHF;
2176 break;
2178 case AL_REVERB_ROOM_ROLLOFF_FACTOR:
2179 *val = props->Reverb.RoomRolloffFactor;
2180 break;
2182 default:
2183 throw effect_exception{AL_INVALID_ENUM, "Invalid reverb float property 0x%04x", param};
2186 void StdReverb_getParamfv(const EffectProps *props, ALenum param, float *vals)
2187 { StdReverb_getParamf(props, param, vals); }
2189 DEFINE_ALEFFECT_VTABLE(StdReverb);
2192 struct StdReverbStateFactory final : public EffectStateFactory {
2193 EffectState *create() override { return new ReverbState{}; }
2194 EffectProps getDefaultProps() const noexcept override;
2195 const EffectVtable *getEffectVtable() const noexcept override { return &StdReverb_vtable; }
2198 EffectProps StdReverbStateFactory::getDefaultProps() const noexcept
2200 EffectProps props{};
2201 props.Reverb.Density = AL_REVERB_DEFAULT_DENSITY;
2202 props.Reverb.Diffusion = AL_REVERB_DEFAULT_DIFFUSION;
2203 props.Reverb.Gain = AL_REVERB_DEFAULT_GAIN;
2204 props.Reverb.GainHF = AL_REVERB_DEFAULT_GAINHF;
2205 props.Reverb.GainLF = 1.0f;
2206 props.Reverb.DecayTime = AL_REVERB_DEFAULT_DECAY_TIME;
2207 props.Reverb.DecayHFRatio = AL_REVERB_DEFAULT_DECAY_HFRATIO;
2208 props.Reverb.DecayLFRatio = 1.0f;
2209 props.Reverb.ReflectionsGain = AL_REVERB_DEFAULT_REFLECTIONS_GAIN;
2210 props.Reverb.ReflectionsDelay = AL_REVERB_DEFAULT_REFLECTIONS_DELAY;
2211 props.Reverb.ReflectionsPan[0] = 0.0f;
2212 props.Reverb.ReflectionsPan[1] = 0.0f;
2213 props.Reverb.ReflectionsPan[2] = 0.0f;
2214 props.Reverb.LateReverbGain = AL_REVERB_DEFAULT_LATE_REVERB_GAIN;
2215 props.Reverb.LateReverbDelay = AL_REVERB_DEFAULT_LATE_REVERB_DELAY;
2216 props.Reverb.LateReverbPan[0] = 0.0f;
2217 props.Reverb.LateReverbPan[1] = 0.0f;
2218 props.Reverb.LateReverbPan[2] = 0.0f;
2219 props.Reverb.EchoTime = 0.25f;
2220 props.Reverb.EchoDepth = 0.0f;
2221 props.Reverb.ModulationTime = 0.25f;
2222 props.Reverb.ModulationDepth = 0.0f;
2223 props.Reverb.AirAbsorptionGainHF = AL_REVERB_DEFAULT_AIR_ABSORPTION_GAINHF;
2224 props.Reverb.HFReference = 5000.0f;
2225 props.Reverb.LFReference = 250.0f;
2226 props.Reverb.RoomRolloffFactor = AL_REVERB_DEFAULT_ROOM_ROLLOFF_FACTOR;
2227 props.Reverb.DecayHFLimit = AL_REVERB_DEFAULT_DECAY_HFLIMIT;
2228 return props;
2231 } // namespace
2233 EffectStateFactory *ReverbStateFactory_getFactory()
2235 static ReverbStateFactory ReverbFactory{};
2236 return &ReverbFactory;
2239 EffectStateFactory *StdReverbStateFactory_getFactory()
2241 static StdReverbStateFactory ReverbFactory{};
2242 return &ReverbFactory;