Use a helper to set an identity ambisonic pan
This commit is contained in:
parent
b52fde7c0e
commit
fe7a74b09a
19
alc/alu.h
19
alc/alu.h
@ -4,6 +4,7 @@
|
||||
#include <array>
|
||||
#include <cmath>
|
||||
#include <cstddef>
|
||||
#include <type_traits>
|
||||
|
||||
#include "AL/al.h"
|
||||
|
||||
@ -134,11 +135,21 @@ void ComputePanGains(const MixParams *mix, const float*RESTRICT coeffs, const fl
|
||||
const al::span<float,MAX_OUTPUT_CHANNELS> gains);
|
||||
|
||||
|
||||
inline std::array<float,MAX_AMBI_CHANNELS> GetAmbiIdentityRow(size_t i) noexcept
|
||||
/** Helper to set an identity/pass-through panning for ambisonic mixing (3D input). */
|
||||
template<typename T, typename I, typename F>
|
||||
auto SetAmbiPanIdentity(T iter, I count, F func) -> std::enable_if_t<std::is_integral<I>::value>
|
||||
{
|
||||
std::array<float,MAX_AMBI_CHANNELS> ret{};
|
||||
ret[i] = 1.0f;
|
||||
return ret;
|
||||
if(count < 1) return;
|
||||
|
||||
std::array<float,MAX_AMBI_CHANNELS> coeffs{{1.0f}};
|
||||
func(*iter, coeffs);
|
||||
++iter;
|
||||
for(I i{1};i < count;++i,++iter)
|
||||
{
|
||||
coeffs[i-1] = 0.0f;
|
||||
coeffs[i ] = 1.0f;
|
||||
func(*iter, coeffs);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -118,11 +118,9 @@ void AutowahState::update(const ALCcontext *context, const ALeffectslot *slot, c
|
||||
mBandwidthNorm = (MAX_FREQ-MIN_FREQ) / frequency;
|
||||
|
||||
mOutTarget = target.Main->Buffer;
|
||||
for(size_t i{0u};i < slot->Wet.Buffer.size();++i)
|
||||
{
|
||||
auto coeffs = GetAmbiIdentityRow(i);
|
||||
ComputePanGains(target.Main, coeffs.data(), slot->Params.Gain, mChans[i].TargetGains);
|
||||
}
|
||||
auto set_gains = [slot,target](auto &chan, al::span<const float,MAX_AMBI_CHANNELS> coeffs)
|
||||
{ ComputePanGains(target.Main, coeffs.data(), slot->Params.Gain, chan.TargetGains); };
|
||||
SetAmbiPanIdentity(std::begin(mChans), slot->Wet.Buffer.size(), set_gains);
|
||||
}
|
||||
|
||||
void AutowahState::process(const size_t samplesToDo, const al::span<const FloatBufferLine> samplesIn, const al::span<FloatBufferLine> samplesOut)
|
||||
|
@ -76,11 +76,9 @@ void CompressorState::update(const ALCcontext*, const ALeffectslot *slot, const
|
||||
mEnabled = props->Compressor.OnOff;
|
||||
|
||||
mOutTarget = target.Main->Buffer;
|
||||
for(size_t i{0u};i < slot->Wet.Buffer.size();++i)
|
||||
{
|
||||
auto coeffs = GetAmbiIdentityRow(i);
|
||||
ComputePanGains(target.Main, coeffs.data(), slot->Params.Gain, mGain[i]);
|
||||
}
|
||||
auto set_gains = [slot,target](auto &gains, al::span<const float,MAX_AMBI_CHANNELS> coeffs)
|
||||
{ ComputePanGains(target.Main, coeffs.data(), slot->Params.Gain, gains); };
|
||||
SetAmbiPanIdentity(std::begin(mGain), slot->Wet.Buffer.size(), set_gains);
|
||||
}
|
||||
|
||||
void CompressorState::process(const size_t samplesToDo, const al::span<const FloatBufferLine> samplesIn, const al::span<FloatBufferLine> samplesOut)
|
||||
|
@ -147,11 +147,9 @@ void EqualizerState::update(const ALCcontext *context, const ALeffectslot *slot,
|
||||
}
|
||||
|
||||
mOutTarget = target.Main->Buffer;
|
||||
for(size_t i{0u};i < slot->Wet.Buffer.size();++i)
|
||||
{
|
||||
auto coeffs = GetAmbiIdentityRow(i);
|
||||
ComputePanGains(target.Main, coeffs.data(), slot->Params.Gain, mChans[i].TargetGains);
|
||||
}
|
||||
auto set_gains = [slot,target](auto &chan, al::span<const float,MAX_AMBI_CHANNELS> coeffs)
|
||||
{ ComputePanGains(target.Main, coeffs.data(), slot->Params.Gain, chan.TargetGains); };
|
||||
SetAmbiPanIdentity(std::begin(mChans), slot->Wet.Buffer.size(), set_gains);
|
||||
}
|
||||
|
||||
void EqualizerState::process(const size_t samplesToDo, const al::span<const FloatBufferLine> samplesIn, const al::span<FloatBufferLine> samplesOut)
|
||||
|
@ -122,11 +122,9 @@ void ModulatorState::update(const ALCcontext *context, const ALeffectslot *slot,
|
||||
mChans[i].Filter.copyParamsFrom(mChans[0].Filter);
|
||||
|
||||
mOutTarget = target.Main->Buffer;
|
||||
for(size_t i{0u};i < slot->Wet.Buffer.size();++i)
|
||||
{
|
||||
auto coeffs = GetAmbiIdentityRow(i);
|
||||
ComputePanGains(target.Main, coeffs.data(), slot->Params.Gain, mChans[i].TargetGains);
|
||||
}
|
||||
auto set_gains = [slot,target](auto &chan, al::span<const float,MAX_AMBI_CHANNELS> coeffs)
|
||||
{ ComputePanGains(target.Main, coeffs.data(), slot->Params.Gain, chan.TargetGains); };
|
||||
SetAmbiPanIdentity(std::begin(mChans), slot->Wet.Buffer.size(), set_gains);
|
||||
}
|
||||
|
||||
void ModulatorState::process(const size_t samplesToDo, const al::span<const FloatBufferLine> samplesIn, const al::span<FloatBufferLine> samplesOut)
|
||||
|
@ -237,11 +237,9 @@ void VmorpherState::update(const ALCcontext *context, const ALeffectslot *slot,
|
||||
}
|
||||
|
||||
mOutTarget = target.Main->Buffer;
|
||||
for(size_t i{0u};i < slot->Wet.Buffer.size();++i)
|
||||
{
|
||||
auto coeffs = GetAmbiIdentityRow(i);
|
||||
ComputePanGains(target.Main, coeffs.data(), slot->Params.Gain, mChans[i].TargetGains);
|
||||
}
|
||||
auto set_gains = [slot,target](auto &chan, al::span<const float,MAX_AMBI_CHANNELS> coeffs)
|
||||
{ ComputePanGains(target.Main, coeffs.data(), slot->Params.Gain, chan.TargetGains); };
|
||||
SetAmbiPanIdentity(std::begin(mChans), slot->Wet.Buffer.size(), set_gains);
|
||||
}
|
||||
|
||||
void VmorpherState::process(const size_t samplesToDo, const al::span<const FloatBufferLine> samplesIn, const al::span<FloatBufferLine> samplesOut)
|
||||
|
Loading…
x
Reference in New Issue
Block a user