diff options
author | Chris Robinson <[email protected]> | 2020-12-06 08:49:20 -0800 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2020-12-06 08:49:20 -0800 |
commit | bd08b9a5b52f4f6f056d428399f92df92f82c00a (patch) | |
tree | 4699459f1054cca978e8f563ffdb742b2e378232 /alc/effects | |
parent | 4ee95dc296e0aea86d4cd091d6b9c47912760da1 (diff) |
Use constexpr variables instead of macros
Diffstat (limited to 'alc/effects')
-rw-r--r-- | alc/effects/autowah.cpp | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/alc/effects/autowah.cpp b/alc/effects/autowah.cpp index 4e089a80..a64a93db 100644 --- a/alc/effects/autowah.cpp +++ b/alc/effects/autowah.cpp @@ -25,18 +25,18 @@ #include <algorithm> -#include "al/auxeffectslot.h" #include "alcmain.h" #include "alcontext.h" -#include "alu.h" #include "core/filters/biquad.h" +#include "effectslot.h" #include "vecmat.h" namespace { -#define MIN_FREQ 20.0f -#define MAX_FREQ 2500.0f -#define Q_FACTOR 5.0f +constexpr float GainScale{31621.0f}; +constexpr float MinFreq{20.0f}; +constexpr float MaxFreq{2500.0f}; +constexpr float QFactor{5.0f}; struct AutowahState final : public EffectState { /* Effect parameters */ @@ -116,9 +116,9 @@ void AutowahState::update(const ALCcontext *context, const EffectSlot *slot, mReleaseRate = std::exp(-1.0f / (ReleaseTime*frequency)); /* 0-20dB Resonance Peak gain */ mResonanceGain = std::sqrt(std::log10(props->Autowah.Resonance)*10.0f / 3.0f); - mPeakGain = 1.0f - std::log10(props->Autowah.PeakGain/AL_AUTOWAH_MAX_PEAK_GAIN); - mFreqMinNorm = MIN_FREQ / frequency; - mBandwidthNorm = (MAX_FREQ-MIN_FREQ) / frequency; + mPeakGain = 1.0f - std::log10(props->Autowah.PeakGain / GainScale); + mFreqMinNorm = MinFreq / frequency; + mBandwidthNorm = (MaxFreq-MinFreq) / frequency; mOutTarget = target.Main->Buffer; auto set_gains = [slot,target](auto &chan, al::span<const float,MaxAmbiChannels> coeffs) @@ -151,7 +151,7 @@ void AutowahState::process(const size_t samplesToDo, /* Calculate the cos and alpha components for this sample's filter. */ w0 = minf((bandwidth*env_delay + freq_min), 0.46f) * al::MathDefs<float>::Tau(); mEnv[i].cos_w0 = std::cos(w0); - mEnv[i].alpha = std::sin(w0)/(2.0f * Q_FACTOR); + mEnv[i].alpha = std::sin(w0)/(2.0f * QFactor); } mEnvDelay = env_delay; |