From 0fe38c053d8dd827e774fbe0aef121e7aa0a0f28 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Sun, 25 Apr 2021 11:36:37 -0700 Subject: Move some functions to core And clean up more includes --- alc/effects/reverb.cpp | 83 ++++++++++++++++++++++++++++++-------------------- 1 file changed, 50 insertions(+), 33 deletions(-) (limited to 'alc/effects/reverb.cpp') diff --git a/alc/effects/reverb.cpp b/alc/effects/reverb.cpp index 2af7472d..ccb4f544 100644 --- a/alc/effects/reverb.cpp +++ b/alc/effects/reverb.cpp @@ -20,23 +20,34 @@ #include "config.h" -#include -#include -#include - -#include -#include #include +#include +#include #include +#include +#include +#include -#include "alcmain.h" #include "alcontext.h" +#include "almalloc.h" #include "alnumeric.h" +#include "alspan.h" +#include "alu.h" #include "core/ambidefs.h" +#include "core/bufferline.h" +#include "core/devformat.h" +#include "core/device.h" #include "core/filters/biquad.h" +#include "core/filters/splitter.h" +#include "core/mixer.h" +#include "core/mixer/defs.h" +#include "effects/base.h" #include "effectslot.h" -#include "vector.h" +#include "intrusive_ptr.h" +#include "math_defs.h" +#include "opthelpers.h" #include "vecmat.h" +#include "vector.h" /* This is a user config option for modifying the overall output of the reverb * effect. @@ -45,6 +56,11 @@ float ReverbBoost = 1.0f; namespace { +using uint = unsigned int; + +constexpr float MaxModulationTime{4.0f}; +constexpr float DefaultModulationTime{0.25f}; + #define MOD_FRACBITS 24 #define MOD_FRACONE (1<= AL_EAXREVERB_DEFAULT_MODULATION_TIME) + if(modTime >= DefaultModulationTime) { /* To cancel the effects of a long period modulation on the late * reverberation, the amount of pitch should be varied (decreased) * according to the modulation time. The natural form is varying * inversely, in fact resulting in an invariant. */ - Depth[1] = MODULATION_DEPTH_COEFF / 4.0f * AL_EAXREVERB_DEFAULT_MODULATION_TIME * - modDepth * frequency; + Depth[1] = MODULATION_DEPTH_COEFF / 4.0f * DefaultModulationTime * modDepth * frequency; } else Depth[1] = MODULATION_DEPTH_COEFF / 4.0f * modTime * modDepth * frequency; @@ -835,7 +851,8 @@ void LateReverb::updateLines(const float density_mult, const float diffusion, /* Scaling factor to convert the normalized reference frequencies from * representing 0...freq to 0...max_reference. */ - const float norm_weight_factor{frequency / AL_EAXREVERB_MAX_HFREFERENCE}; + constexpr float MaxHFReference{20000.0f}; + const float norm_weight_factor{frequency / MaxHFReference}; const float late_allpass_avg{ std::accumulate(LATE_ALLPASS_LENGTHS.begin(), LATE_ALLPASS_LENGTHS.end(), 0.0f) / @@ -1024,10 +1041,10 @@ void ReverbState::update(const ContextBase *Context, const EffectSlot *Slot, props->Reverb.DecayTime); /* Calculate the LF/HF decay times. */ - const float lfDecayTime{clampf(props->Reverb.DecayTime * props->Reverb.DecayLFRatio, - AL_EAXREVERB_MIN_DECAY_TIME, AL_EAXREVERB_MAX_DECAY_TIME)}; - const float hfDecayTime{clampf(props->Reverb.DecayTime * hfRatio, - AL_EAXREVERB_MIN_DECAY_TIME, AL_EAXREVERB_MAX_DECAY_TIME)}; + constexpr float MinDecayTime{0.1f}, MaxDecayTime{20.0f}; + const float lfDecayTime{clampf(props->Reverb.DecayTime*props->Reverb.DecayLFRatio, + MinDecayTime, MaxDecayTime)}; + const float hfDecayTime{clampf(props->Reverb.DecayTime*hfRatio, MinDecayTime, MaxDecayTime)}; /* Update the modulator rate and depth. */ mLate.Mod.updateModulator(props->Reverb.ModulationTime, props->Reverb.ModulationDepth, -- cgit v1.2.3