Inline and precompute some CalcDirectionCoeffs calls
parent
4f75f9258c
commit
ed9408e537
|
@ -906,7 +906,7 @@ void CalcPanningAndFilters(Voice *voice, const float xpos, const float ypos, con
|
||||||
auto calc_coeffs = [xpos,ypos,zpos](RenderMode mode)
|
auto calc_coeffs = [xpos,ypos,zpos](RenderMode mode)
|
||||||
{
|
{
|
||||||
if(mode != RenderMode::Pairwise)
|
if(mode != RenderMode::Pairwise)
|
||||||
return CalcDirectionCoeffs({xpos, ypos, zpos}, 0.0f);
|
return CalcDirectionCoeffs({xpos, ypos, zpos});
|
||||||
|
|
||||||
/* Clamp Y, in case rounding errors caused it to end up outside
|
/* Clamp Y, in case rounding errors caused it to end up outside
|
||||||
* of -1...+1.
|
* of -1...+1.
|
||||||
|
|
|
@ -120,8 +120,8 @@ void ChorusState::update(const ContextBase *Context, const EffectSlot *Slot,
|
||||||
mFeedback = props->Chorus.Feedback;
|
mFeedback = props->Chorus.Feedback;
|
||||||
|
|
||||||
/* Gains for left and right sides */
|
/* Gains for left and right sides */
|
||||||
const auto lcoeffs = CalcDirectionCoeffs({-1.0f, 0.0f, 0.0f}, 0.0f);
|
static constexpr auto lcoeffs = CalcDirectionCoeffs({-1.0f, 0.0f, 0.0f});
|
||||||
const auto rcoeffs = CalcDirectionCoeffs({ 1.0f, 0.0f, 0.0f}, 0.0f);
|
static constexpr auto rcoeffs = CalcDirectionCoeffs({ 1.0f, 0.0f, 0.0f});
|
||||||
|
|
||||||
mOutTarget = target.Main->Buffer;
|
mOutTarget = target.Main->Buffer;
|
||||||
ComputePanGains(target.Main, lcoeffs.data(), Slot->Gain, mGains[0].Target);
|
ComputePanGains(target.Main, lcoeffs.data(), Slot->Gain, mGains[0].Target);
|
||||||
|
|
|
@ -94,7 +94,7 @@ void DedicatedState::update(const ContextBase*, const EffectSlot *slot,
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
const auto coeffs = CalcDirectionCoeffs({0.0f, 0.0f, -1.0f}, 0.0f);
|
static constexpr auto coeffs = CalcDirectionCoeffs({0.0f, 0.0f, -1.0f});
|
||||||
|
|
||||||
mOutTarget = target.Main->Buffer;
|
mOutTarget = target.Main->Buffer;
|
||||||
ComputePanGains(target.Main, coeffs.data(), Gain, mTargetGains);
|
ComputePanGains(target.Main, coeffs.data(), Gain, mTargetGains);
|
||||||
|
|
|
@ -95,7 +95,7 @@ void DistortionState::update(const ContextBase *context, const EffectSlot *slot,
|
||||||
bandwidth = props->Distortion.EQBandwidth / (cutoff * 0.67f);
|
bandwidth = props->Distortion.EQBandwidth / (cutoff * 0.67f);
|
||||||
mBandpass.setParamsFromBandwidth(BiquadType::BandPass, cutoff/frequency/4.0f, 1.0f, bandwidth);
|
mBandpass.setParamsFromBandwidth(BiquadType::BandPass, cutoff/frequency/4.0f, 1.0f, bandwidth);
|
||||||
|
|
||||||
const auto coeffs = CalcDirectionCoeffs({0.0f, 0.0f, -1.0f}, 0.0f);
|
static constexpr auto coeffs = CalcDirectionCoeffs({0.0f, 0.0f, -1.0f});
|
||||||
|
|
||||||
mOutTarget = target.Main->Buffer;
|
mOutTarget = target.Main->Buffer;
|
||||||
ComputePanGains(target.Main, coeffs.data(), slot->Gain*props->Distortion.Gain, mGain);
|
ComputePanGains(target.Main, coeffs.data(), slot->Gain*props->Distortion.Gain, mGain);
|
||||||
|
|
|
@ -160,8 +160,8 @@ void FshifterState::update(const ContextBase *context, const EffectSlot *slot,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto lcoeffs = CalcDirectionCoeffs({-1.0f, 0.0f, 0.0f}, 0.0f);
|
static constexpr auto lcoeffs = CalcDirectionCoeffs({-1.0f, 0.0f, 0.0f});
|
||||||
const auto rcoeffs = CalcDirectionCoeffs({ 1.0f, 0.0f, 0.0f}, 0.0f);
|
static constexpr auto rcoeffs = CalcDirectionCoeffs({ 1.0f, 0.0f, 0.0f});
|
||||||
|
|
||||||
mOutTarget = target.Main->Buffer;
|
mOutTarget = target.Main->Buffer;
|
||||||
ComputePanGains(target.Main, lcoeffs.data(), slot->Gain, mGains[0].Target);
|
ComputePanGains(target.Main, lcoeffs.data(), slot->Gain, mGains[0].Target);
|
||||||
|
|
|
@ -140,7 +140,7 @@ void PshifterState::update(const ContextBase*, const EffectSlot *slot,
|
||||||
mPitchShiftI = fastf2u(pitch*MixerFracOne);
|
mPitchShiftI = fastf2u(pitch*MixerFracOne);
|
||||||
mPitchShift = mPitchShiftI * double{1.0/MixerFracOne};
|
mPitchShift = mPitchShiftI * double{1.0/MixerFracOne};
|
||||||
|
|
||||||
const auto coeffs = CalcDirectionCoeffs({0.0f, 0.0f, -1.0f}, 0.0f);
|
static constexpr auto coeffs = CalcDirectionCoeffs({0.0f, 0.0f, -1.0f});
|
||||||
|
|
||||||
mOutTarget = target.Main->Buffer;
|
mOutTarget = target.Main->Buffer;
|
||||||
ComputePanGains(target.Main, coeffs.data(), slot->Gain, mTargetGains);
|
ComputePanGains(target.Main, coeffs.data(), slot->Gain, mTargetGains);
|
||||||
|
|
12
core/mixer.h
12
core/mixer.h
|
@ -51,6 +51,18 @@ inline std::array<float,MaxAmbiChannels> CalcDirectionCoeffs(const float (&dir)[
|
||||||
return CalcAmbiCoeffs(-dir[0], dir[1], -dir[2], spread);
|
return CalcAmbiCoeffs(-dir[0], dir[1], -dir[2], spread);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* CalcDirectionCoeffs
|
||||||
|
*
|
||||||
|
* Calculates ambisonic coefficients based on an OpenAL direction vector. The
|
||||||
|
* vector must be normalized (unit length).
|
||||||
|
*/
|
||||||
|
constexpr std::array<float,MaxAmbiChannels> CalcDirectionCoeffs(const float (&dir)[3])
|
||||||
|
{
|
||||||
|
/* Convert from OpenAL coords to Ambisonics. */
|
||||||
|
return CalcAmbiCoeffs(-dir[0], dir[1], -dir[2]);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* CalcAngleCoeffs
|
* CalcAngleCoeffs
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue