aboutsummaryrefslogtreecommitdiffstats
path: root/alc/effects
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2023-12-24 02:48:20 -0800
committerChris Robinson <[email protected]>2023-12-24 02:48:20 -0800
commitdae225e88dbf795e776a2c9f2dbe5bb07c2228b9 (patch)
tree8a2e79a24fef5a99b3d0f883ab03cc070a2b584a /alc/effects
parent29a1001a22891294ab63102e8868bdea52eb7b93 (diff)
Rework effect property handling
To nake EffectProps a variant instead of a union, and avoid manual vtables.
Diffstat (limited to 'alc/effects')
-rw-r--r--alc/effects/autowah.cpp11
-rw-r--r--alc/effects/chorus.cpp15
-rw-r--r--alc/effects/compressor.cpp2
-rw-r--r--alc/effects/convolution.cpp9
-rw-r--r--alc/effects/dedicated.cpp4
-rw-r--r--alc/effects/distortion.cpp13
-rw-r--r--alc/effects/echo.cpp13
-rw-r--r--alc/effects/equalizer.cpp23
-rw-r--r--alc/effects/fshifter.cpp9
-rw-r--r--alc/effects/modulator.cpp15
-rw-r--r--alc/effects/pshifter.cpp5
-rw-r--r--alc/effects/reverb.cpp87
-rw-r--r--alc/effects/vmorpher.cpp21
13 files changed, 114 insertions, 113 deletions
diff --git a/alc/effects/autowah.cpp b/alc/effects/autowah.cpp
index e9e14e35..424230e8 100644
--- a/alc/effects/autowah.cpp
+++ b/alc/effects/autowah.cpp
@@ -118,18 +118,19 @@ void AutowahState::deviceUpdate(const DeviceBase*, const BufferStorage*)
}
void AutowahState::update(const ContextBase *context, const EffectSlot *slot,
- const EffectProps *props, const EffectTarget target)
+ const EffectProps *props_, const EffectTarget target)
{
+ auto &props = std::get<AutowahProps>(*props_);
const DeviceBase *device{context->mDevice};
const auto frequency = static_cast<float>(device->Frequency);
- const float ReleaseTime{clampf(props->Autowah.ReleaseTime, 0.001f, 1.0f)};
+ const float ReleaseTime{clampf(props.ReleaseTime, 0.001f, 1.0f)};
- mAttackRate = std::exp(-1.0f / (props->Autowah.AttackTime*frequency));
+ mAttackRate = std::exp(-1.0f / (props.AttackTime*frequency));
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 / GainScale);
+ mResonanceGain = std::sqrt(std::log10(props.Resonance)*10.0f / 3.0f);
+ mPeakGain = 1.0f - std::log10(props.PeakGain / GainScale);
mFreqMinNorm = MinFreq / frequency;
mBandwidthNorm = (MaxFreq-MinFreq) / frequency;
diff --git a/alc/effects/chorus.cpp b/alc/effects/chorus.cpp
index 52aaa9a6..bc6ddaf0 100644
--- a/alc/effects/chorus.cpp
+++ b/alc/effects/chorus.cpp
@@ -93,11 +93,12 @@ struct ChorusState : public EffectState {
void deviceUpdate(const DeviceBase *device, const BufferStorage*) override
{ deviceUpdate(device, ChorusMaxDelay); }
- void update(const ContextBase *context, const EffectSlot *slot, const EffectProps *props,
+ void update(const ContextBase *context, const EffectSlot *slot, const EffectProps *props_,
const EffectTarget target) override
{
- update(context, slot, props->Chorus.Waveform, props->Chorus.Delay, props->Chorus.Depth,
- props->Chorus.Feedback, props->Chorus.Rate, props->Chorus.Phase, target);
+ auto &props = std::get<ChorusProps>(*props_);
+ update(context, slot, props.Waveform, props.Delay, props.Depth, props.Feedback, props.Rate,
+ props.Phase, target);
}
void process(const size_t samplesToDo, const al::span<const FloatBufferLine> samplesIn,
const al::span<FloatBufferLine> samplesOut) final;
@@ -106,12 +107,12 @@ struct ChorusState : public EffectState {
struct FlangerState final : public ChorusState {
void deviceUpdate(const DeviceBase *device, const BufferStorage*) final
{ ChorusState::deviceUpdate(device, FlangerMaxDelay); }
- void update(const ContextBase *context, const EffectSlot *slot, const EffectProps *props,
+ void update(const ContextBase *context, const EffectSlot *slot, const EffectProps *props_,
const EffectTarget target) final
{
- ChorusState::update(context, slot, props->Flanger.Waveform, props->Flanger.Delay,
- props->Flanger.Depth, props->Flanger.Feedback, props->Flanger.Rate,
- props->Flanger.Phase, target);
+ auto &props = std::get<FlangerProps>(*props_);
+ ChorusState::update(context, slot, props.Waveform, props.Delay, props.Depth,
+ props.Feedback, props.Rate, props.Phase, target);
}
};
diff --git a/alc/effects/compressor.cpp b/alc/effects/compressor.cpp
index eb8605ce..717b6dd2 100644
--- a/alc/effects/compressor.cpp
+++ b/alc/effects/compressor.cpp
@@ -102,7 +102,7 @@ void CompressorState::deviceUpdate(const DeviceBase *device, const BufferStorage
void CompressorState::update(const ContextBase*, const EffectSlot *slot,
const EffectProps *props, const EffectTarget target)
{
- mEnabled = props->Compressor.OnOff;
+ mEnabled = std::get<CompressorProps>(*props).OnOff;
mOutTarget = target.Main->Buffer;
auto set_channel = [this](size_t idx, uint outchan, float outgain)
diff --git a/alc/effects/convolution.cpp b/alc/effects/convolution.cpp
index f497ebce..3f3e157c 100644
--- a/alc/effects/convolution.cpp
+++ b/alc/effects/convolution.cpp
@@ -401,7 +401,7 @@ void ConvolutionState::deviceUpdate(const DeviceBase *device, const BufferStorag
void ConvolutionState::update(const ContextBase *context, const EffectSlot *slot,
- const EffectProps *props, const EffectTarget target)
+ const EffectProps *props_, const EffectTarget target)
{
/* TODO: LFE is not mixed to output. This will require each buffer channel
* to have its own output target since the main mixing buffer won't have an
@@ -455,6 +455,7 @@ void ConvolutionState::update(const ContextBase *context, const EffectSlot *slot
if(mNumConvolveSegs < 1) UNLIKELY
return;
+ auto &props = std::get<ConvolutionProps>(*props_);
mMix = &ConvolutionState::NormalMix;
for(auto &chan : mChans)
@@ -488,11 +489,9 @@ void ConvolutionState::update(const ContextBase *context, const EffectSlot *slot
}
mOutTarget = target.Main->Buffer;
- alu::Vector N{props->Convolution.OrientAt[0], props->Convolution.OrientAt[1],
- props->Convolution.OrientAt[2], 0.0f};
+ alu::Vector N{props.OrientAt[0], props.OrientAt[1], props.OrientAt[2], 0.0f};
N.normalize();
- alu::Vector V{props->Convolution.OrientUp[0], props->Convolution.OrientUp[1],
- props->Convolution.OrientUp[2], 0.0f};
+ alu::Vector V{props.OrientUp[0], props.OrientUp[1], props.OrientUp[2], 0.0f};
V.normalize();
/* Build and normalize right-vector */
alu::Vector U{N.cross_product(V)};
diff --git a/alc/effects/dedicated.cpp b/alc/effects/dedicated.cpp
index 1629aaea..23ac4d1a 100644
--- a/alc/effects/dedicated.cpp
+++ b/alc/effects/dedicated.cpp
@@ -73,7 +73,7 @@ void DedicatedState::update(const ContextBase*, const EffectSlot *slot,
{
std::fill(mTargetGains.begin(), mTargetGains.end(), 0.0f);
- const float Gain{slot->Gain * props->DedicatedDialog.Gain};
+ const float Gain{slot->Gain * std::get<DedicatedDialogProps>(*props).Gain};
/* Dialog goes to the front-center speaker if it exists, otherwise it plays
* from the front-center location.
@@ -99,7 +99,7 @@ void DedicatedLfeState::update(const ContextBase*, const EffectSlot *slot,
{
std::fill(mTargetGains.begin(), mTargetGains.end(), 0.0f);
- const float Gain{slot->Gain * props->DedicatedLfe.Gain};
+ const float Gain{slot->Gain * std::get<DedicatedLfeProps>(*props).Gain};
const size_t idx{target.RealOut ? target.RealOut->ChannelIndex[LFE] : InvalidChannelIndex};
if(idx != InvalidChannelIndex)
diff --git a/alc/effects/distortion.cpp b/alc/effects/distortion.cpp
index 5e8253e8..d0946971 100644
--- a/alc/effects/distortion.cpp
+++ b/alc/effects/distortion.cpp
@@ -70,16 +70,17 @@ void DistortionState::deviceUpdate(const DeviceBase*, const BufferStorage*)
}
void DistortionState::update(const ContextBase *context, const EffectSlot *slot,
- const EffectProps *props, const EffectTarget target)
+ const EffectProps *props_, const EffectTarget target)
{
+ auto &props = std::get<DistortionProps>(*props_);
const DeviceBase *device{context->mDevice};
/* Store waveshaper edge settings. */
- const float edge{minf(std::sin(al::numbers::pi_v<float>*0.5f * props->Distortion.Edge),
+ const float edge{minf(std::sin(al::numbers::pi_v<float>*0.5f * props.Edge),
0.99f)};
mEdgeCoeff = 2.0f * edge / (1.0f-edge);
- float cutoff{props->Distortion.LowpassCutoff};
+ float cutoff{props.LowpassCutoff};
/* Bandwidth value is constant in octaves. */
float bandwidth{(cutoff / 2.0f) / (cutoff * 0.67f)};
/* Divide normalized frequency by the amount of oversampling done during
@@ -88,15 +89,15 @@ void DistortionState::update(const ContextBase *context, const EffectSlot *slot,
auto frequency = static_cast<float>(device->Frequency);
mLowpass.setParamsFromBandwidth(BiquadType::LowPass, cutoff/frequency/4.0f, 1.0f, bandwidth);
- cutoff = props->Distortion.EQCenter;
+ cutoff = props.EQCenter;
/* Convert bandwidth in Hz to octaves. */
- bandwidth = props->Distortion.EQBandwidth / (cutoff * 0.67f);
+ bandwidth = props.EQBandwidth / (cutoff * 0.67f);
mBandpass.setParamsFromBandwidth(BiquadType::BandPass, cutoff/frequency/4.0f, 1.0f, bandwidth);
static constexpr auto coeffs = CalcDirectionCoeffs(std::array{0.0f, 0.0f, -1.0f});
mOutTarget = target.Main->Buffer;
- ComputePanGains(target.Main, coeffs, slot->Gain*props->Distortion.Gain, mGain);
+ ComputePanGains(target.Main, coeffs, slot->Gain*props.Gain, mGain);
}
void DistortionState::process(const size_t samplesToDo, const al::span<const FloatBufferLine> samplesIn, const al::span<FloatBufferLine> samplesOut)
diff --git a/alc/effects/echo.cpp b/alc/effects/echo.cpp
index 2f3343e8..a5bfa6a5 100644
--- a/alc/effects/echo.cpp
+++ b/alc/effects/echo.cpp
@@ -95,21 +95,22 @@ void EchoState::deviceUpdate(const DeviceBase *Device, const BufferStorage*)
}
void EchoState::update(const ContextBase *context, const EffectSlot *slot,
- const EffectProps *props, const EffectTarget target)
+ const EffectProps *props_, const EffectTarget target)
{
+ auto &props = std::get<EchoProps>(*props_);
const DeviceBase *device{context->mDevice};
const auto frequency = static_cast<float>(device->Frequency);
- mDelayTap[0] = maxu(float2uint(props->Echo.Delay*frequency + 0.5f), 1);
- mDelayTap[1] = float2uint(props->Echo.LRDelay*frequency + 0.5f) + mDelayTap[0];
+ mDelayTap[0] = maxu(float2uint(props.Delay*frequency + 0.5f), 1);
+ mDelayTap[1] = float2uint(props.LRDelay*frequency + 0.5f) + mDelayTap[0];
- const float gainhf{maxf(1.0f - props->Echo.Damping, 0.0625f)}; /* Limit -24dB */
+ const float gainhf{maxf(1.0f - props.Damping, 0.0625f)}; /* Limit -24dB */
mFilter.setParamsFromSlope(BiquadType::HighShelf, LowpassFreqRef/frequency, gainhf, 1.0f);
- mFeedGain = props->Echo.Feedback;
+ mFeedGain = props.Feedback;
/* Convert echo spread (where 0 = center, +/-1 = sides) to angle. */
- const float angle{std::asin(props->Echo.Spread)};
+ const float angle{std::asin(props.Spread)};
const auto coeffs0 = CalcAngleCoeffs(-angle, 0.0f, 0.0f);
const auto coeffs1 = CalcAngleCoeffs( angle, 0.0f, 0.0f);
diff --git a/alc/effects/equalizer.cpp b/alc/effects/equalizer.cpp
index 9cb42470..165d00f2 100644
--- a/alc/effects/equalizer.cpp
+++ b/alc/effects/equalizer.cpp
@@ -119,8 +119,9 @@ void EqualizerState::deviceUpdate(const DeviceBase*, const BufferStorage*)
}
void EqualizerState::update(const ContextBase *context, const EffectSlot *slot,
- const EffectProps *props, const EffectTarget target)
+ const EffectProps *props_, const EffectTarget target)
{
+ auto &props = std::get<EqualizerProps>(*props_);
const DeviceBase *device{context->mDevice};
auto frequency = static_cast<float>(device->Frequency);
@@ -130,22 +131,22 @@ void EqualizerState::update(const ContextBase *context, const EffectSlot *slot,
* property gains need their dB halved (sqrt of linear gain) for the
* shelf/peak to reach the provided gain.
*/
- float gain{std::sqrt(props->Equalizer.LowGain)};
- float f0norm{props->Equalizer.LowCutoff / frequency};
+ float gain{std::sqrt(props.LowGain)};
+ float f0norm{props.LowCutoff / frequency};
mChans[0].mFilter[0].setParamsFromSlope(BiquadType::LowShelf, f0norm, gain, 0.75f);
- gain = std::sqrt(props->Equalizer.Mid1Gain);
- f0norm = props->Equalizer.Mid1Center / frequency;
+ gain = std::sqrt(props.Mid1Gain);
+ f0norm = props.Mid1Center / frequency;
mChans[0].mFilter[1].setParamsFromBandwidth(BiquadType::Peaking, f0norm, gain,
- props->Equalizer.Mid1Width);
+ props.Mid1Width);
- gain = std::sqrt(props->Equalizer.Mid2Gain);
- f0norm = props->Equalizer.Mid2Center / frequency;
+ gain = std::sqrt(props.Mid2Gain);
+ f0norm = props.Mid2Center / frequency;
mChans[0].mFilter[2].setParamsFromBandwidth(BiquadType::Peaking, f0norm, gain,
- props->Equalizer.Mid2Width);
+ props.Mid2Width);
- gain = std::sqrt(props->Equalizer.HighGain);
- f0norm = props->Equalizer.HighCutoff / frequency;
+ gain = std::sqrt(props.HighGain);
+ f0norm = props.HighCutoff / frequency;
mChans[0].mFilter[3].setParamsFromSlope(BiquadType::HighShelf, f0norm, gain, 0.75f);
/* Copy the filter coefficients for the other input channels. */
diff --git a/alc/effects/fshifter.cpp b/alc/effects/fshifter.cpp
index 433ebfe4..076661cf 100644
--- a/alc/effects/fshifter.cpp
+++ b/alc/effects/fshifter.cpp
@@ -127,14 +127,15 @@ void FshifterState::deviceUpdate(const DeviceBase*, const BufferStorage*)
}
void FshifterState::update(const ContextBase *context, const EffectSlot *slot,
- const EffectProps *props, const EffectTarget target)
+ const EffectProps *props_, const EffectTarget target)
{
+ auto &props = std::get<FshifterProps>(*props_);
const DeviceBase *device{context->mDevice};
- const float step{props->Fshifter.Frequency / static_cast<float>(device->Frequency)};
+ const float step{props.Frequency / static_cast<float>(device->Frequency)};
mPhaseStep[0] = mPhaseStep[1] = fastf2u(minf(step, 1.0f) * MixerFracOne);
- switch(props->Fshifter.LeftDirection)
+ switch(props.LeftDirection)
{
case FShifterDirection::Down:
mSign[0] = -1.0;
@@ -148,7 +149,7 @@ void FshifterState::update(const ContextBase *context, const EffectSlot *slot,
break;
}
- switch(props->Fshifter.RightDirection)
+ switch(props.RightDirection)
{
case FShifterDirection::Down:
mSign[1] = -1.0;
diff --git a/alc/effects/modulator.cpp b/alc/effects/modulator.cpp
index 8144061a..7350ca5a 100644
--- a/alc/effects/modulator.cpp
+++ b/alc/effects/modulator.cpp
@@ -125,8 +125,9 @@ void ModulatorState::deviceUpdate(const DeviceBase*, const BufferStorage*)
}
void ModulatorState::update(const ContextBase *context, const EffectSlot *slot,
- const EffectProps *props, const EffectTarget target)
+ const EffectProps *props_, const EffectTarget target)
{
+ auto &props = std::get<ModulatorProps>(*props_);
const DeviceBase *device{context->mDevice};
/* The effective frequency will be adjusted to have a whole number of
@@ -136,8 +137,8 @@ void ModulatorState::update(const ContextBase *context, const EffectSlot *slot,
* but that may need a more efficient sin function since it needs to do
* many iterations per sample.
*/
- const float samplesPerCycle{props->Modulator.Frequency > 0.0f
- ? static_cast<float>(device->Frequency)/props->Modulator.Frequency + 0.5f
+ const float samplesPerCycle{props.Frequency > 0.0f
+ ? static_cast<float>(device->Frequency)/props.Frequency + 0.5f
: 1.0f};
const uint range{static_cast<uint>(clampf(samplesPerCycle, 1.0f,
static_cast<float>(device->Frequency)))};
@@ -149,17 +150,17 @@ void ModulatorState::update(const ContextBase *context, const EffectSlot *slot,
mIndexScale = 0.0f;
mGenModSamples = &ModulatorState::Modulate<One>;
}
- else if(props->Modulator.Waveform == ModulatorWaveform::Sinusoid)
+ else if(props.Waveform == ModulatorWaveform::Sinusoid)
{
mIndexScale = al::numbers::pi_v<float>*2.0f / static_cast<float>(mRange);
mGenModSamples = &ModulatorState::Modulate<Sin>;
}
- else if(props->Modulator.Waveform == ModulatorWaveform::Sawtooth)
+ else if(props.Waveform == ModulatorWaveform::Sawtooth)
{
mIndexScale = 2.0f / static_cast<float>(mRange-1);
mGenModSamples = &ModulatorState::Modulate<Saw>;
}
- else /*if(props->Modulator.Waveform == ModulatorWaveform::Square)*/
+ else /*if(props.Waveform == ModulatorWaveform::Square)*/
{
/* For square wave, the range should be even (there should be an equal
* number of high and low samples). An odd number of samples per cycle
@@ -170,7 +171,7 @@ void ModulatorState::update(const ContextBase *context, const EffectSlot *slot,
mGenModSamples = &ModulatorState::Modulate<Square>;
}
- float f0norm{props->Modulator.HighPassCutoff / static_cast<float>(device->Frequency)};
+ float f0norm{props.HighPassCutoff / static_cast<float>(device->Frequency)};
f0norm = clampf(f0norm, 1.0f/512.0f, 0.49f);
/* Bandwidth value is constant in octaves. */
mChans[0].mFilter.setParamsFromBandwidth(BiquadType::HighPass, f0norm, 1.0f, 0.75f);
diff --git a/alc/effects/pshifter.cpp b/alc/effects/pshifter.cpp
index 9714510f..1cc1a18c 100644
--- a/alc/effects/pshifter.cpp
+++ b/alc/effects/pshifter.cpp
@@ -138,9 +138,10 @@ void PshifterState::deviceUpdate(const DeviceBase*, const BufferStorage*)
}
void PshifterState::update(const ContextBase*, const EffectSlot *slot,
- const EffectProps *props, const EffectTarget target)
+ const EffectProps *props_, const EffectTarget target)
{
- const int tune{props->Pshifter.CoarseTune*100 + props->Pshifter.FineTune};
+ auto &props = std::get<PshifterProps>(*props_);
+ const int tune{props.CoarseTune*100 + props.FineTune};
const float pitch{std::pow(2.0f, static_cast<float>(tune) / 1200.0f)};
mPitchShiftI = clampu(fastf2u(pitch*MixerFracOne), MixerFracHalf, MixerFracOne*2);
mPitchShift = static_cast<float>(mPitchShiftI) * float{1.0f/MixerFracOne};
diff --git a/alc/effects/reverb.cpp b/alc/effects/reverb.cpp
index 5eefdfbf..ac599e41 100644
--- a/alc/effects/reverb.cpp
+++ b/alc/effects/reverb.cpp
@@ -1182,57 +1182,56 @@ void ReverbPipeline::update3DPanning(const al::span<const float,3> ReflectionsPa
}
void ReverbState::update(const ContextBase *Context, const EffectSlot *Slot,
- const EffectProps *props, const EffectTarget target)
+ const EffectProps *props_, const EffectTarget target)
{
+ auto &props = std::get<ReverbProps>(*props_);
const DeviceBase *Device{Context->mDevice};
const auto frequency = static_cast<float>(Device->Frequency);
/* If the HF limit parameter is flagged, calculate an appropriate limit
* based on the air absorption parameter.
*/
- float hfRatio{props->Reverb.DecayHFRatio};
- if(props->Reverb.DecayHFLimit && props->Reverb.AirAbsorptionGainHF < 1.0f)
- hfRatio = CalcLimitedHfRatio(hfRatio, props->Reverb.AirAbsorptionGainHF,
- props->Reverb.DecayTime);
+ float hfRatio{props.DecayHFRatio};
+ if(props.DecayHFLimit && props.AirAbsorptionGainHF < 1.0f)
+ hfRatio = CalcLimitedHfRatio(hfRatio, props.AirAbsorptionGainHF, props.DecayTime);
/* Calculate the LF/HF decay times. */
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)};
+ const float lfDecayTime{clampf(props.DecayTime*props.DecayLFRatio, MinDecayTime,MaxDecayTime)};
+ const float hfDecayTime{clampf(props.DecayTime*hfRatio, MinDecayTime, MaxDecayTime)};
/* Determine if a full update is required. */
const bool fullUpdate{mPipelineState == DeviceClear ||
/* Density is essentially a master control for the feedback delays, so
* changes the offsets of many delay lines.
*/
- mParams.Density != props->Reverb.Density ||
+ mParams.Density != props.Density ||
/* Diffusion and decay times influences the decay rate (gain) of the
* late reverb T60 filter.
*/
- mParams.Diffusion != props->Reverb.Diffusion ||
- mParams.DecayTime != props->Reverb.DecayTime ||
+ mParams.Diffusion != props.Diffusion ||
+ mParams.DecayTime != props.DecayTime ||
mParams.HFDecayTime != hfDecayTime ||
mParams.LFDecayTime != lfDecayTime ||
/* Modulation time and depth both require fading the modulation delay. */
- mParams.ModulationTime != props->Reverb.ModulationTime ||
- mParams.ModulationDepth != props->Reverb.ModulationDepth ||
+ mParams.ModulationTime != props.ModulationTime ||
+ mParams.ModulationDepth != props.ModulationDepth ||
/* HF/LF References control the weighting used to calculate the density
* gain.
*/
- mParams.HFReference != props->Reverb.HFReference ||
- mParams.LFReference != props->Reverb.LFReference};
+ mParams.HFReference != props.HFReference ||
+ mParams.LFReference != props.LFReference};
if(fullUpdate)
{
- mParams.Density = props->Reverb.Density;
- mParams.Diffusion = props->Reverb.Diffusion;
- mParams.DecayTime = props->Reverb.DecayTime;
+ mParams.Density = props.Density;
+ mParams.Diffusion = props.Diffusion;
+ mParams.DecayTime = props.DecayTime;
mParams.HFDecayTime = hfDecayTime;
mParams.LFDecayTime = lfDecayTime;
- mParams.ModulationTime = props->Reverb.ModulationTime;
- mParams.ModulationDepth = props->Reverb.ModulationDepth;
- mParams.HFReference = props->Reverb.HFReference;
- mParams.LFReference = props->Reverb.LFReference;
+ mParams.ModulationTime = props.ModulationTime;
+ mParams.ModulationDepth = props.ModulationDepth;
+ mParams.HFReference = props.HFReference;
+ mParams.LFReference = props.LFReference;
mPipelineState = (mPipelineState != DeviceClear) ? StartFade : Normal;
mCurrentPipeline = !mCurrentPipeline;
@@ -1241,16 +1240,15 @@ void ReverbState::update(const ContextBase *Context, const EffectSlot *Slot,
/* Update early and late 3D panning. */
mOutTarget = target.Main->Buffer;
- const float gain{props->Reverb.Gain * Slot->Gain * ReverbBoost};
- pipeline.update3DPanning(props->Reverb.ReflectionsPan, props->Reverb.LateReverbPan,
- props->Reverb.ReflectionsGain*gain, props->Reverb.LateReverbGain*gain, mUpmixOutput,
- target.Main);
+ const float gain{props.Gain * Slot->Gain * ReverbBoost};
+ pipeline.update3DPanning(props.ReflectionsPan, props.LateReverbPan, props.ReflectionsGain*gain,
+ props.LateReverbGain*gain, mUpmixOutput, target.Main);
/* Calculate the master filters */
- float hf0norm{minf(props->Reverb.HFReference/frequency, 0.49f)};
- pipeline.mFilter[0].Lp.setParamsFromSlope(BiquadType::HighShelf, hf0norm, props->Reverb.GainHF, 1.0f);
- float lf0norm{minf(props->Reverb.LFReference/frequency, 0.49f)};
- pipeline.mFilter[0].Hp.setParamsFromSlope(BiquadType::LowShelf, lf0norm, props->Reverb.GainLF, 1.0f);
+ float hf0norm{minf(props.HFReference/frequency, 0.49f)};
+ pipeline.mFilter[0].Lp.setParamsFromSlope(BiquadType::HighShelf, hf0norm, props.GainHF, 1.0f);
+ float lf0norm{minf(props.LFReference/frequency, 0.49f)};
+ pipeline.mFilter[0].Hp.setParamsFromSlope(BiquadType::LowShelf, lf0norm, props.GainLF, 1.0f);
for(size_t i{1u};i < NUM_LINES;i++)
{
pipeline.mFilter[i].Lp.copyParamsFrom(pipeline.mFilter[0].Lp);
@@ -1258,34 +1256,32 @@ void ReverbState::update(const ContextBase *Context, const EffectSlot *Slot,
}
/* The density-based room size (delay length) multiplier. */
- const float density_mult{CalcDelayLengthMult(props->Reverb.Density)};
+ const float density_mult{CalcDelayLengthMult(props.Density)};
/* Update the main effect delay and associated taps. */
- pipeline.updateDelayLine(props->Reverb.ReflectionsDelay, props->Reverb.LateReverbDelay,
- density_mult, props->Reverb.DecayTime, frequency);
+ pipeline.updateDelayLine(props.ReflectionsDelay, props.LateReverbDelay, density_mult,
+ props.DecayTime, frequency);
if(fullUpdate)
{
/* Update the early lines. */
- pipeline.mEarly.updateLines(density_mult, props->Reverb.Diffusion, props->Reverb.DecayTime,
- frequency);
+ pipeline.mEarly.updateLines(density_mult, props.Diffusion, props.DecayTime, frequency);
/* Get the mixing matrix coefficients. */
- CalcMatrixCoeffs(props->Reverb.Diffusion, &pipeline.mMixX, &pipeline.mMixY);
+ CalcMatrixCoeffs(props.Diffusion, &pipeline.mMixX, &pipeline.mMixY);
/* Update the modulator rate and depth. */
- pipeline.mLate.Mod.updateModulator(props->Reverb.ModulationTime,
- props->Reverb.ModulationDepth, frequency);
+ pipeline.mLate.Mod.updateModulator(props.ModulationTime, props.ModulationDepth, frequency);
/* Update the late lines. */
- pipeline.mLate.updateLines(density_mult, props->Reverb.Diffusion, lfDecayTime,
- props->Reverb.DecayTime, hfDecayTime, lf0norm, hf0norm, frequency);
+ pipeline.mLate.updateLines(density_mult, props.Diffusion, lfDecayTime, props.DecayTime,
+ hfDecayTime, lf0norm, hf0norm, frequency);
}
/* Calculate the gain at the start of the late reverb stage, and the gain
* difference from the decay target (0.001, or -60dB).
*/
- const float decayBase{props->Reverb.ReflectionsGain * props->Reverb.LateReverbGain};
+ const float decayBase{props.ReflectionsGain * props.LateReverbGain};
const float decayDiff{ReverbDecayGain / decayBase};
if(decayDiff < 1.0f)
@@ -1294,10 +1290,10 @@ void ReverbState::update(const ContextBase *Context, const EffectSlot *Slot,
* by -60dB), calculate the time to decay to -60dB from the start of
* the late reverb.
*/
- const float diffTime{std::log10(decayDiff)*(20.0f / -60.0f) * props->Reverb.DecayTime};
+ const float diffTime{std::log10(decayDiff)*(20.0f / -60.0f) * props.DecayTime};
- const float decaySamples{(props->Reverb.ReflectionsDelay + props->Reverb.LateReverbDelay
- + diffTime) * frequency};
+ const float decaySamples{(props.ReflectionsDelay+props.LateReverbDelay+diffTime)
+ * frequency};
/* Limit to 100,000 samples (a touch over 2 seconds at 48khz) to
* avoid excessive double-processing.
*/
@@ -1308,8 +1304,7 @@ void ReverbState::update(const ContextBase *Context, const EffectSlot *Slot,
/* Otherwise, if the late reverb already starts at -60dB or less, only
* include the time to get to the late reverb.
*/
- const float decaySamples{(props->Reverb.ReflectionsDelay + props->Reverb.LateReverbDelay)
- * frequency};
+ const float decaySamples{(props.ReflectionsDelay+props.LateReverbDelay) * frequency};
pipeline.mFadeSampleCount = static_cast<size_t>(minf(decaySamples, 100'000.0f));
}
}
diff --git a/alc/effects/vmorpher.cpp b/alc/effects/vmorpher.cpp
index adbcdeab..eaf30d07 100644
--- a/alc/effects/vmorpher.cpp
+++ b/alc/effects/vmorpher.cpp
@@ -241,29 +241,28 @@ void VmorpherState::deviceUpdate(const DeviceBase*, const BufferStorage*)
}
void VmorpherState::update(const ContextBase *context, const EffectSlot *slot,
- const EffectProps *props, const EffectTarget target)
+ const EffectProps *props_, const EffectTarget target)
{
+ auto &props = std::get<VmorpherProps>(*props_);
const DeviceBase *device{context->mDevice};
const float frequency{static_cast<float>(device->Frequency)};
- const float step{props->Vmorpher.Rate / frequency};
+ const float step{props.Rate / frequency};
mStep = fastf2u(clampf(step*WaveformFracOne, 0.0f, float{WaveformFracOne}-1.0f));
if(mStep == 0)
mGetSamples = Oscillate<Half>;
- else if(props->Vmorpher.Waveform == VMorpherWaveform::Sinusoid)
+ else if(props.Waveform == VMorpherWaveform::Sinusoid)
mGetSamples = Oscillate<Sin>;
- else if(props->Vmorpher.Waveform == VMorpherWaveform::Triangle)
+ else if(props.Waveform == VMorpherWaveform::Triangle)
mGetSamples = Oscillate<Triangle>;
- else /*if(props->Vmorpher.Waveform == VMorpherWaveform::Sawtooth)*/
+ else /*if(props.Waveform == VMorpherWaveform::Sawtooth)*/
mGetSamples = Oscillate<Saw>;
- const float pitchA{std::pow(2.0f,
- static_cast<float>(props->Vmorpher.PhonemeACoarseTuning) / 12.0f)};
- const float pitchB{std::pow(2.0f,
- static_cast<float>(props->Vmorpher.PhonemeBCoarseTuning) / 12.0f)};
+ const float pitchA{std::pow(2.0f, static_cast<float>(props.PhonemeACoarseTuning) / 12.0f)};
+ const float pitchB{std::pow(2.0f, static_cast<float>(props.PhonemeBCoarseTuning) / 12.0f)};
- auto vowelA = getFiltersByPhoneme(props->Vmorpher.PhonemeA, frequency, pitchA);
- auto vowelB = getFiltersByPhoneme(props->Vmorpher.PhonemeB, frequency, pitchB);
+ auto vowelA = getFiltersByPhoneme(props.PhonemeA, frequency, pitchA);
+ auto vowelB = getFiltersByPhoneme(props.PhonemeB, frequency, pitchB);
/* Copy the filter coefficients to the input channels. */
for(size_t i{0u};i < slot->Wet.Buffer.size();++i)