Provide effect target parameters through a common struct
This commit is contained in:
+20
-2
@@ -412,7 +412,7 @@ bool CalcEffectSlotParams(ALeffectslot *slot, ALCcontext *context, bool force)
|
||||
evt.u.mEffectState = slot->Params.mEffectState;
|
||||
|
||||
slot->Params.mEffectState = state;
|
||||
props->State = NULL;
|
||||
props->State = nullptr;
|
||||
|
||||
if(LIKELY(ll_ringbuffer_write(context->AsyncEvents, &evt, 1) != 0))
|
||||
context->EventSem.post();
|
||||
@@ -430,7 +430,25 @@ bool CalcEffectSlotParams(ALeffectslot *slot, ALCcontext *context, bool force)
|
||||
AtomicReplaceHead(context->FreeEffectslotProps, props);
|
||||
}
|
||||
|
||||
state->update(context, slot, &slot->Params.EffectProps);
|
||||
MixParams params;
|
||||
EffectTarget output;
|
||||
if(ALeffectslot *target{slot->Params.Target})
|
||||
{
|
||||
auto iter = std::copy(std::begin(target->ChanMap), std::end(target->ChanMap),
|
||||
std::begin(params.Ambi.Map));
|
||||
std::fill(iter, std::end(params.Ambi.Map), BFChannelConfig{});
|
||||
params.CoeffCount = 0;
|
||||
params.Buffer = target->WetBuffer;
|
||||
params.NumChannels = target->NumChannels;
|
||||
|
||||
output = EffectTarget{¶ms, ¶ms, nullptr};
|
||||
}
|
||||
else
|
||||
{
|
||||
ALCdevice *device{context->Device};
|
||||
output = EffectTarget{&device->Dry, &device->FOAOut, &device->RealOut};
|
||||
}
|
||||
state->update(context, slot, &slot->Params.EffectProps, output);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
+7
-18
@@ -69,7 +69,7 @@ struct ALautowahState final : public EffectState {
|
||||
|
||||
|
||||
ALboolean deviceUpdate(const ALCdevice *device) override;
|
||||
void update(const ALCcontext *context, const ALeffectslot *slot, const ALeffectProps *props) override;
|
||||
void update(const ALCcontext *context, const ALeffectslot *slot, const ALeffectProps *props, const EffectTarget target) override;
|
||||
void process(ALsizei samplesToDo, const ALfloat (*RESTRICT samplesIn)[BUFFERSIZE], ALfloat (*RESTRICT samplesOut)[BUFFERSIZE], ALsizei numChannels) override;
|
||||
|
||||
DEF_NEWDEL(ALautowahState)
|
||||
@@ -103,7 +103,7 @@ ALboolean ALautowahState::deviceUpdate(const ALCdevice *UNUSED(device))
|
||||
return AL_TRUE;
|
||||
}
|
||||
|
||||
void ALautowahState::update(const ALCcontext *context, const ALeffectslot *slot, const ALeffectProps *props)
|
||||
void ALautowahState::update(const ALCcontext *context, const ALeffectslot *slot, const ALeffectProps *props, const EffectTarget target)
|
||||
{
|
||||
const ALCdevice *device = context->Device;
|
||||
ALfloat ReleaseTime;
|
||||
@@ -119,22 +119,11 @@ void ALautowahState::update(const ALCcontext *context, const ALeffectslot *slot,
|
||||
mFreqMinNorm = MIN_FREQ / device->Frequency;
|
||||
mBandwidthNorm = (MAX_FREQ-MIN_FREQ) / device->Frequency;
|
||||
|
||||
if(ALeffectslot *target{slot->Params.Target})
|
||||
{
|
||||
mOutBuffer = target->WetBuffer;
|
||||
mOutChannels = target->NumChannels;
|
||||
for(i = 0;i < MAX_EFFECT_CHANNELS;i++)
|
||||
ComputePanGains(target, alu::Matrix::Identity()[i].data(), slot->Params.Gain,
|
||||
mChans[i].TargetGains);
|
||||
}
|
||||
else
|
||||
{
|
||||
mOutBuffer = device->FOAOut.Buffer;
|
||||
mOutChannels = device->FOAOut.NumChannels;
|
||||
for(i = 0;i < MAX_EFFECT_CHANNELS;i++)
|
||||
ComputePanGains(&device->FOAOut, alu::Matrix::Identity()[i].data(), slot->Params.Gain,
|
||||
mChans[i].TargetGains);
|
||||
}
|
||||
mOutBuffer = target.FOAOut->Buffer;
|
||||
mOutChannels = target.FOAOut->NumChannels;
|
||||
for(i = 0;i < MAX_EFFECT_CHANNELS;i++)
|
||||
ComputePanGains(target.FOAOut, alu::Matrix::Identity()[i].data(), slot->Params.Gain,
|
||||
mChans[i].TargetGains);
|
||||
}
|
||||
|
||||
void ALautowahState::process(ALsizei SamplesToDo, const ALfloat (*RESTRICT SamplesIn)[BUFFERSIZE], ALfloat (*RESTRICT SamplesOut)[BUFFERSIZE], ALsizei NumChannels)
|
||||
|
||||
+7
-16
@@ -91,7 +91,7 @@ struct ChorusState final : public EffectState {
|
||||
|
||||
|
||||
ALboolean deviceUpdate(const ALCdevice *device) override;
|
||||
void update(const ALCcontext *context, const ALeffectslot *slot, const ALeffectProps *props) override;
|
||||
void update(const ALCcontext *context, const ALeffectslot *slot, const ALeffectProps *props, const EffectTarget target) override;
|
||||
void process(ALsizei samplesToDo, const ALfloat (*RESTRICT samplesIn)[BUFFERSIZE], ALfloat (*RESTRICT samplesOut)[BUFFERSIZE], ALsizei numChannels) override;
|
||||
|
||||
DEF_NEWDEL(ChorusState)
|
||||
@@ -121,7 +121,7 @@ ALboolean ChorusState::deviceUpdate(const ALCdevice *Device)
|
||||
return AL_TRUE;
|
||||
}
|
||||
|
||||
void ChorusState::update(const ALCcontext *Context, const ALeffectslot *Slot, const ALeffectProps *props)
|
||||
void ChorusState::update(const ALCcontext *Context, const ALeffectslot *Slot, const ALeffectProps *props, const EffectTarget target)
|
||||
{
|
||||
static constexpr ALsizei mindelay = MAX_RESAMPLE_PADDING << FRACTIONBITS;
|
||||
|
||||
@@ -149,20 +149,11 @@ void ChorusState::update(const ALCcontext *Context, const ALeffectslot *Slot, co
|
||||
ALfloat coeffs[2][MAX_AMBI_COEFFS];
|
||||
CalcAngleCoeffs(-F_PI_2, 0.0f, 0.0f, coeffs[0]);
|
||||
CalcAngleCoeffs( F_PI_2, 0.0f, 0.0f, coeffs[1]);
|
||||
if(ALeffectslot *target{Slot->Params.Target})
|
||||
{
|
||||
mOutBuffer = target->WetBuffer;
|
||||
mOutChannels = target->NumChannels;
|
||||
ComputePanGains(target, coeffs[0], Slot->Params.Gain, mGains[0].Target);
|
||||
ComputePanGains(target, coeffs[1], Slot->Params.Gain, mGains[1].Target);
|
||||
}
|
||||
else
|
||||
{
|
||||
mOutBuffer = device->Dry.Buffer;
|
||||
mOutChannels = device->Dry.NumChannels;
|
||||
ComputePanGains(&device->Dry, coeffs[0], Slot->Params.Gain, mGains[0].Target);
|
||||
ComputePanGains(&device->Dry, coeffs[1], Slot->Params.Gain, mGains[1].Target);
|
||||
}
|
||||
|
||||
mOutBuffer = target.Main->Buffer;
|
||||
mOutChannels = target.Main->NumChannels;
|
||||
ComputePanGains(target.Main, coeffs[0], Slot->Params.Gain, mGains[0].Target);
|
||||
ComputePanGains(target.Main, coeffs[1], Slot->Params.Gain, mGains[1].Target);
|
||||
|
||||
ALfloat rate{props->Chorus.Rate};
|
||||
if(!(rate > 0.0f))
|
||||
|
||||
@@ -49,7 +49,7 @@ struct ALcompressorState final : public EffectState {
|
||||
|
||||
|
||||
ALboolean deviceUpdate(const ALCdevice *device) override;
|
||||
void update(const ALCcontext *context, const ALeffectslot *slot, const ALeffectProps *props) override;
|
||||
void update(const ALCcontext *context, const ALeffectslot *slot, const ALeffectProps *props, const EffectTarget target) override;
|
||||
void process(ALsizei samplesToDo, const ALfloat (*RESTRICT samplesIn)[BUFFERSIZE], ALfloat (*RESTRICT samplesOut)[BUFFERSIZE], ALsizei numChannels) override;
|
||||
|
||||
DEF_NEWDEL(ALcompressorState)
|
||||
@@ -72,27 +72,15 @@ ALboolean ALcompressorState::deviceUpdate(const ALCdevice *device)
|
||||
return AL_TRUE;
|
||||
}
|
||||
|
||||
void ALcompressorState::update(const ALCcontext *context, const ALeffectslot *slot, const ALeffectProps *props)
|
||||
void ALcompressorState::update(const ALCcontext* UNUSED(context), const ALeffectslot *slot, const ALeffectProps *props, const EffectTarget target)
|
||||
{
|
||||
mEnabled = props->Compressor.OnOff;
|
||||
|
||||
if(ALeffectslot *target{slot->Params.Target})
|
||||
{
|
||||
mOutBuffer = target->WetBuffer;
|
||||
mOutChannels = target->NumChannels;
|
||||
for(ALsizei i{0};i < MAX_EFFECT_CHANNELS;i++)
|
||||
ComputePanGains(target, alu::Matrix::Identity()[i].data(), slot->Params.Gain,
|
||||
mGain[i]);
|
||||
}
|
||||
else
|
||||
{
|
||||
const ALCdevice *device{context->Device};
|
||||
mOutBuffer = device->FOAOut.Buffer;
|
||||
mOutChannels = device->FOAOut.NumChannels;
|
||||
for(ALsizei i{0};i < 4;i++)
|
||||
ComputePanGains(&device->FOAOut, alu::Matrix::Identity()[i].data(),
|
||||
slot->Params.Gain, mGain[i]);
|
||||
}
|
||||
mOutBuffer = target.FOAOut->Buffer;
|
||||
mOutChannels = target.FOAOut->NumChannels;
|
||||
for(ALsizei i{0};i < 4;i++)
|
||||
ComputePanGains(target.FOAOut, alu::Matrix::Identity()[i].data(),
|
||||
slot->Params.Gain, mGain[i]);
|
||||
}
|
||||
|
||||
void ALcompressorState::process(ALsizei SamplesToDo, const ALfloat (*RESTRICT SamplesIn)[BUFFERSIZE], ALfloat (*RESTRICT SamplesOut)[BUFFERSIZE], ALsizei NumChannels)
|
||||
|
||||
+12
-26
@@ -37,7 +37,7 @@ struct ALdedicatedState final : public EffectState {
|
||||
|
||||
|
||||
ALboolean deviceUpdate(const ALCdevice *device) override;
|
||||
void update(const ALCcontext *context, const ALeffectslot *slot, const ALeffectProps *props) override;
|
||||
void update(const ALCcontext *context, const ALeffectslot *slot, const ALeffectProps *props, const EffectTarget target) override;
|
||||
void process(ALsizei samplesToDo, const ALfloat (*RESTRICT samplesIn)[BUFFERSIZE], ALfloat (*RESTRICT samplesOut)[BUFFERSIZE], ALsizei numChannels) override;
|
||||
|
||||
DEF_NEWDEL(ALdedicatedState)
|
||||
@@ -49,33 +49,19 @@ ALboolean ALdedicatedState::deviceUpdate(const ALCdevice *UNUSED(device))
|
||||
return AL_TRUE;
|
||||
}
|
||||
|
||||
void ALdedicatedState::update(const ALCcontext *context, const ALeffectslot *slot, const ALeffectProps *props)
|
||||
void ALdedicatedState::update(const ALCcontext* UNUSED(context), const ALeffectslot *slot, const ALeffectProps *props, const EffectTarget target)
|
||||
{
|
||||
const ALCdevice *device = context->Device;
|
||||
|
||||
std::fill(std::begin(mTargetGains), std::end(mTargetGains), 0.0f);
|
||||
|
||||
const ALfloat Gain{slot->Params.Gain * props->Dedicated.Gain};
|
||||
if(ALeffectslot *target{slot->Params.Target})
|
||||
{
|
||||
mOutBuffer = target->WetBuffer;
|
||||
mOutChannels = target->NumChannels;
|
||||
if(slot->Params.EffectType == AL_EFFECT_DEDICATED_DIALOGUE)
|
||||
{
|
||||
ALfloat coeffs[MAX_AMBI_COEFFS];
|
||||
CalcAngleCoeffs(0.0f, 0.0f, 0.0f, coeffs);
|
||||
ComputePanGains(target, coeffs, Gain, mTargetGains);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if(slot->Params.EffectType == AL_EFFECT_DEDICATED_LOW_FREQUENCY_EFFECT)
|
||||
{
|
||||
int idx;
|
||||
if((idx=GetChannelIdxByName(device->RealOut, LFE)) != -1)
|
||||
const int idx{!target.RealOut ? -1 : GetChannelIdxByName(*target.RealOut, LFE)};
|
||||
if(idx != -1)
|
||||
{
|
||||
mOutBuffer = device->RealOut.Buffer;
|
||||
mOutChannels = device->RealOut.NumChannels;
|
||||
mOutBuffer = target.RealOut->Buffer;
|
||||
mOutChannels = target.RealOut->NumChannels;
|
||||
mTargetGains[idx] = Gain;
|
||||
}
|
||||
}
|
||||
@@ -83,11 +69,11 @@ void ALdedicatedState::update(const ALCcontext *context, const ALeffectslot *slo
|
||||
{
|
||||
/* Dialog goes to the front-center speaker if it exists, otherwise it
|
||||
* plays from the front-center location. */
|
||||
int idx{GetChannelIdxByName(device->RealOut, FrontCenter)};
|
||||
const int idx{!target.RealOut ? -1 : GetChannelIdxByName(*target.RealOut, FrontCenter)};
|
||||
if(idx != -1)
|
||||
{
|
||||
mOutBuffer = device->RealOut.Buffer;
|
||||
mOutChannels = device->RealOut.NumChannels;
|
||||
mOutBuffer = target.RealOut->Buffer;
|
||||
mOutChannels = target.RealOut->NumChannels;
|
||||
mTargetGains[idx] = Gain;
|
||||
}
|
||||
else
|
||||
@@ -95,9 +81,9 @@ void ALdedicatedState::update(const ALCcontext *context, const ALeffectslot *slo
|
||||
ALfloat coeffs[MAX_AMBI_COEFFS];
|
||||
CalcAngleCoeffs(0.0f, 0.0f, 0.0f, coeffs);
|
||||
|
||||
mOutBuffer = device->Dry.Buffer;
|
||||
mOutChannels = device->Dry.NumChannels;
|
||||
ComputePanGains(&device->Dry, coeffs, Gain, mTargetGains);
|
||||
mOutBuffer = target.Main->Buffer;
|
||||
mOutChannels = target.Main->NumChannels;
|
||||
ComputePanGains(target.Main, coeffs, Gain, mTargetGains);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+14
-24
@@ -23,6 +23,8 @@
|
||||
#include <math.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <cmath>
|
||||
|
||||
#include "alMain.h"
|
||||
#include "alcontext.h"
|
||||
#include "alAuxEffectSlot.h"
|
||||
@@ -45,7 +47,7 @@ struct ALdistortionState final : public EffectState {
|
||||
|
||||
|
||||
ALboolean deviceUpdate(const ALCdevice *device) override;
|
||||
void update(const ALCcontext *context, const ALeffectslot *slot, const ALeffectProps *props) override;
|
||||
void update(const ALCcontext *context, const ALeffectslot *slot, const ALeffectProps *props, const EffectTarget target) override;
|
||||
void process(ALsizei samplesToDo, const ALfloat (*RESTRICT samplesIn)[BUFFERSIZE], ALfloat (*RESTRICT samplesOut)[BUFFERSIZE], ALsizei numChannels) override;
|
||||
|
||||
DEF_NEWDEL(ALdistortionState)
|
||||
@@ -58,26 +60,21 @@ ALboolean ALdistortionState::deviceUpdate(const ALCdevice *UNUSED(device))
|
||||
return AL_TRUE;
|
||||
}
|
||||
|
||||
void ALdistortionState::update(const ALCcontext *context, const ALeffectslot *slot, const ALeffectProps *props)
|
||||
void ALdistortionState::update(const ALCcontext *context, const ALeffectslot *slot, const ALeffectProps *props, const EffectTarget target)
|
||||
{
|
||||
const ALCdevice *device = context->Device;
|
||||
ALfloat frequency = (ALfloat)device->Frequency;
|
||||
ALfloat coeffs[MAX_AMBI_COEFFS];
|
||||
ALfloat bandwidth;
|
||||
ALfloat cutoff;
|
||||
ALfloat edge;
|
||||
const ALCdevice *device{context->Device};
|
||||
|
||||
/* Store waveshaper edge settings. */
|
||||
edge = sinf(props->Distortion.Edge * (F_PI_2));
|
||||
edge = minf(edge, 0.99f);
|
||||
const ALfloat edge{minf(std::sin(props->Distortion.Edge * F_PI_2), 0.99f)};
|
||||
mEdgeCoeff = 2.0f * edge / (1.0f-edge);
|
||||
|
||||
cutoff = props->Distortion.LowpassCutoff;
|
||||
ALfloat cutoff{props->Distortion.LowpassCutoff};
|
||||
/* Bandwidth value is constant in octaves. */
|
||||
bandwidth = (cutoff / 2.0f) / (cutoff * 0.67f);
|
||||
ALfloat bandwidth{(cutoff / 2.0f) / (cutoff * 0.67f)};
|
||||
/* Multiply sampling frequency by the amount of oversampling done during
|
||||
* processing.
|
||||
*/
|
||||
auto frequency = static_cast<ALfloat>(device->Frequency);
|
||||
mLowpass.setParams(BiquadType::LowPass, 1.0f, cutoff / (frequency*4.0f),
|
||||
calc_rcpQ_from_bandwidth(cutoff / (frequency*4.0f), bandwidth)
|
||||
);
|
||||
@@ -89,19 +86,12 @@ void ALdistortionState::update(const ALCcontext *context, const ALeffectslot *sl
|
||||
calc_rcpQ_from_bandwidth(cutoff / (frequency*4.0f), bandwidth)
|
||||
);
|
||||
|
||||
ALfloat coeffs[MAX_AMBI_COEFFS];
|
||||
CalcAngleCoeffs(0.0f, 0.0f, 0.0f, coeffs);
|
||||
if(ALeffectslot *target{slot->Params.Target})
|
||||
{
|
||||
mOutBuffer = target->WetBuffer;
|
||||
mOutChannels = target->NumChannels;
|
||||
ComputePanGains(target, coeffs, slot->Params.Gain*props->Distortion.Gain, mGain);
|
||||
}
|
||||
else
|
||||
{
|
||||
mOutBuffer = device->Dry.Buffer;
|
||||
mOutChannels = device->Dry.NumChannels;
|
||||
ComputePanGains(&device->Dry, coeffs, slot->Params.Gain*props->Distortion.Gain, mGain);
|
||||
}
|
||||
|
||||
mOutBuffer = target.Main->Buffer;
|
||||
mOutChannels = target.Main->NumChannels;
|
||||
ComputePanGains(target.Main, coeffs, slot->Params.Gain*props->Distortion.Gain, mGain);
|
||||
}
|
||||
|
||||
void ALdistortionState::process(ALsizei SamplesToDo, const ALfloat (*RESTRICT SamplesIn)[BUFFERSIZE], ALfloat (*RESTRICT SamplesOut)[BUFFERSIZE], ALsizei NumChannels)
|
||||
|
||||
+6
-16
@@ -57,7 +57,7 @@ struct ALechoState final : public EffectState {
|
||||
|
||||
|
||||
ALboolean deviceUpdate(const ALCdevice *device) override;
|
||||
void update(const ALCcontext *context, const ALeffectslot *slot, const ALeffectProps *props) override;
|
||||
void update(const ALCcontext *context, const ALeffectslot *slot, const ALeffectProps *props, const EffectTarget target) override;
|
||||
void process(ALsizei samplesToDo, const ALfloat (*RESTRICT samplesIn)[BUFFERSIZE], ALfloat (*RESTRICT samplesOut)[BUFFERSIZE], ALsizei numChannels) override;
|
||||
|
||||
DEF_NEWDEL(ALechoState)
|
||||
@@ -90,7 +90,7 @@ ALboolean ALechoState::deviceUpdate(const ALCdevice *Device)
|
||||
return AL_TRUE;
|
||||
}
|
||||
|
||||
void ALechoState::update(const ALCcontext *context, const ALeffectslot *slot, const ALeffectProps *props)
|
||||
void ALechoState::update(const ALCcontext *context, const ALeffectslot *slot, const ALeffectProps *props, const EffectTarget target)
|
||||
{
|
||||
const ALCdevice *device = context->Device;
|
||||
ALuint frequency = device->Frequency;
|
||||
@@ -119,20 +119,10 @@ void ALechoState::update(const ALCcontext *context, const ALeffectslot *slot, co
|
||||
CalcAngleCoeffs(-F_PI_2*lrpan, 0.0f, spread, coeffs[0]);
|
||||
CalcAngleCoeffs( F_PI_2*lrpan, 0.0f, spread, coeffs[1]);
|
||||
|
||||
if(ALeffectslot *target{slot->Params.Target})
|
||||
{
|
||||
mOutBuffer = target->WetBuffer;
|
||||
mOutChannels = target->NumChannels;
|
||||
ComputePanGains(target, coeffs[0], slot->Params.Gain, mGains[0].Target);
|
||||
ComputePanGains(target, coeffs[1], slot->Params.Gain, mGains[1].Target);
|
||||
}
|
||||
else
|
||||
{
|
||||
mOutBuffer = device->Dry.Buffer;
|
||||
mOutChannels = device->Dry.NumChannels;
|
||||
ComputePanGains(&device->Dry, coeffs[0], slot->Params.Gain, mGains[0].Target);
|
||||
ComputePanGains(&device->Dry, coeffs[1], slot->Params.Gain, mGains[1].Target);
|
||||
}
|
||||
mOutBuffer = target.Main->Buffer;
|
||||
mOutChannels = target.Main->NumChannels;
|
||||
ComputePanGains(target.Main, coeffs[0], slot->Params.Gain, mGains[0].Target);
|
||||
ComputePanGains(target.Main, coeffs[1], slot->Params.Gain, mGains[1].Target);
|
||||
}
|
||||
|
||||
void ALechoState::process(ALsizei SamplesToDo, const ALfloat (*RESTRICT SamplesIn)[BUFFERSIZE], ALfloat (*RESTRICT SamplesOut)[BUFFERSIZE], ALsizei NumChannels)
|
||||
|
||||
@@ -91,7 +91,7 @@ struct ALequalizerState final : public EffectState {
|
||||
|
||||
|
||||
ALboolean deviceUpdate(const ALCdevice *device) override;
|
||||
void update(const ALCcontext *context, const ALeffectslot *slot, const ALeffectProps *props) override;
|
||||
void update(const ALCcontext *context, const ALeffectslot *slot, const ALeffectProps *props, const EffectTarget target) override;
|
||||
void process(ALsizei samplesToDo, const ALfloat (*RESTRICT samplesIn)[BUFFERSIZE], ALfloat (*RESTRICT samplesOut)[BUFFERSIZE], ALsizei numChannels) override;
|
||||
|
||||
DEF_NEWDEL(ALequalizerState)
|
||||
@@ -108,7 +108,7 @@ ALboolean ALequalizerState::deviceUpdate(const ALCdevice *UNUSED(device))
|
||||
return AL_TRUE;
|
||||
}
|
||||
|
||||
void ALequalizerState::update(const ALCcontext *context, const ALeffectslot *slot, const ALeffectProps *props)
|
||||
void ALequalizerState::update(const ALCcontext *context, const ALeffectslot *slot, const ALeffectProps *props, const EffectTarget target)
|
||||
{
|
||||
const ALCdevice *device = context->Device;
|
||||
ALfloat frequency = (ALfloat)device->Frequency;
|
||||
@@ -152,22 +152,11 @@ void ALequalizerState::update(const ALCcontext *context, const ALeffectslot *slo
|
||||
mChans[i].filter[3].copyParamsFrom(mChans[0].filter[3]);
|
||||
}
|
||||
|
||||
if(ALeffectslot *target{slot->Params.Target})
|
||||
{
|
||||
mOutBuffer = target->WetBuffer;
|
||||
mOutChannels = target->NumChannels;
|
||||
for(i = 0;i < MAX_EFFECT_CHANNELS;i++)
|
||||
ComputePanGains(target, alu::Matrix::Identity()[i].data(), slot->Params.Gain,
|
||||
mChans[i].TargetGains);
|
||||
}
|
||||
else
|
||||
{
|
||||
mOutBuffer = device->FOAOut.Buffer;
|
||||
mOutChannels = device->FOAOut.NumChannels;
|
||||
for(i = 0;i < MAX_EFFECT_CHANNELS;i++)
|
||||
ComputePanGains(&device->FOAOut, alu::Matrix::Identity()[i].data(), slot->Params.Gain,
|
||||
mChans[i].TargetGains);
|
||||
}
|
||||
mOutBuffer = target.FOAOut->Buffer;
|
||||
mOutChannels = target.FOAOut->NumChannels;
|
||||
for(i = 0;i < MAX_EFFECT_CHANNELS;i++)
|
||||
ComputePanGains(target.FOAOut, alu::Matrix::Identity()[i].data(), slot->Params.Gain,
|
||||
mChans[i].TargetGains);
|
||||
}
|
||||
|
||||
void ALequalizerState::process(ALsizei SamplesToDo, const ALfloat (*RESTRICT SamplesIn)[BUFFERSIZE], ALfloat (*RESTRICT SamplesOut)[BUFFERSIZE], ALsizei NumChannels)
|
||||
|
||||
@@ -82,7 +82,7 @@ struct ALfshifterState final : public EffectState {
|
||||
|
||||
|
||||
ALboolean deviceUpdate(const ALCdevice *device) override;
|
||||
void update(const ALCcontext *context, const ALeffectslot *slot, const ALeffectProps *props) override;
|
||||
void update(const ALCcontext *context, const ALeffectslot *slot, const ALeffectProps *props, const EffectTarget target) override;
|
||||
void process(ALsizei samplesToDo, const ALfloat (*RESTRICT samplesIn)[BUFFERSIZE], ALfloat (*RESTRICT samplesOut)[BUFFERSIZE], ALsizei numChannels) override;
|
||||
|
||||
DEF_NEWDEL(ALfshifterState)
|
||||
@@ -107,7 +107,7 @@ ALboolean ALfshifterState::deviceUpdate(const ALCdevice *UNUSED(device))
|
||||
return AL_TRUE;
|
||||
}
|
||||
|
||||
void ALfshifterState::update(const ALCcontext *context, const ALeffectslot *slot, const ALeffectProps *props)
|
||||
void ALfshifterState::update(const ALCcontext *context, const ALeffectslot *slot, const ALeffectProps *props, const EffectTarget target)
|
||||
{
|
||||
const ALCdevice *device{context->Device};
|
||||
|
||||
@@ -132,18 +132,10 @@ void ALfshifterState::update(const ALCcontext *context, const ALeffectslot *slot
|
||||
|
||||
ALfloat coeffs[MAX_AMBI_COEFFS];
|
||||
CalcAngleCoeffs(0.0f, 0.0f, 0.0f, coeffs);
|
||||
if(ALeffectslot *target{slot->Params.Target})
|
||||
{
|
||||
mOutBuffer = target->WetBuffer;
|
||||
mOutChannels = target->NumChannels;
|
||||
ComputePanGains(target, coeffs, slot->Params.Gain, mTargetGains);
|
||||
}
|
||||
else
|
||||
{
|
||||
mOutBuffer = device->Dry.Buffer;
|
||||
mOutChannels = device->Dry.NumChannels;
|
||||
ComputePanGains(&device->Dry, coeffs, slot->Params.Gain, mTargetGains);
|
||||
}
|
||||
|
||||
mOutBuffer = target.Main->Buffer;
|
||||
mOutChannels = target.Main->NumChannels;
|
||||
ComputePanGains(target.Main, coeffs, slot->Params.Gain, mTargetGains);
|
||||
}
|
||||
|
||||
void ALfshifterState::process(ALsizei SamplesToDo, const ALfloat (*RESTRICT SamplesIn)[BUFFERSIZE], ALfloat (*RESTRICT SamplesOut)[BUFFERSIZE], ALsizei NumChannels)
|
||||
|
||||
@@ -89,7 +89,7 @@ struct ALmodulatorState final : public EffectState {
|
||||
|
||||
|
||||
ALboolean deviceUpdate(const ALCdevice *device) override;
|
||||
void update(const ALCcontext *context, const ALeffectslot *slot, const ALeffectProps *props) override;
|
||||
void update(const ALCcontext *context, const ALeffectslot *slot, const ALeffectProps *props, const EffectTarget target) override;
|
||||
void process(ALsizei samplesToDo, const ALfloat (*RESTRICT samplesIn)[BUFFERSIZE], ALfloat (*RESTRICT samplesOut)[BUFFERSIZE], ALsizei numChannels) override;
|
||||
|
||||
DEF_NEWDEL(ALmodulatorState)
|
||||
@@ -105,7 +105,7 @@ ALboolean ALmodulatorState::deviceUpdate(const ALCdevice *UNUSED(device))
|
||||
return AL_TRUE;
|
||||
}
|
||||
|
||||
void ALmodulatorState::update(const ALCcontext *context, const ALeffectslot *slot, const ALeffectProps *props)
|
||||
void ALmodulatorState::update(const ALCcontext *context, const ALeffectslot *slot, const ALeffectProps *props, const EffectTarget target)
|
||||
{
|
||||
const ALCdevice *device = context->Device;
|
||||
ALfloat f0norm;
|
||||
@@ -131,22 +131,11 @@ void ALmodulatorState::update(const ALCcontext *context, const ALeffectslot *slo
|
||||
for(i = 1;i < MAX_EFFECT_CHANNELS;i++)
|
||||
mChans[i].Filter.copyParamsFrom(mChans[0].Filter);
|
||||
|
||||
if(ALeffectslot *target{slot->Params.Target})
|
||||
{
|
||||
mOutBuffer = target->WetBuffer;
|
||||
mOutChannels = target->NumChannels;
|
||||
for(i = 0;i < MAX_EFFECT_CHANNELS;i++)
|
||||
ComputePanGains(target, alu::Matrix::Identity()[i].data(), slot->Params.Gain,
|
||||
mChans[i].TargetGains);
|
||||
}
|
||||
else
|
||||
{
|
||||
mOutBuffer = device->FOAOut.Buffer;
|
||||
mOutChannels = device->FOAOut.NumChannels;
|
||||
for(i = 0;i < MAX_EFFECT_CHANNELS;i++)
|
||||
ComputePanGains(&device->FOAOut, alu::Matrix::Identity()[i].data(), slot->Params.Gain,
|
||||
mChans[i].TargetGains);
|
||||
}
|
||||
mOutBuffer = target.FOAOut->Buffer;
|
||||
mOutChannels = target.FOAOut->NumChannels;
|
||||
for(i = 0;i < MAX_EFFECT_CHANNELS;i++)
|
||||
ComputePanGains(target.FOAOut, alu::Matrix::Identity()[i].data(), slot->Params.Gain,
|
||||
mChans[i].TargetGains);
|
||||
}
|
||||
|
||||
void ALmodulatorState::process(ALsizei SamplesToDo, const ALfloat (*RESTRICT SamplesIn)[BUFFERSIZE], ALfloat (*RESTRICT SamplesOut)[BUFFERSIZE], ALsizei NumChannels)
|
||||
|
||||
@@ -16,7 +16,7 @@ struct ALnullState final : public EffectState {
|
||||
~ALnullState() override;
|
||||
|
||||
ALboolean deviceUpdate(const ALCdevice *device) override;
|
||||
void update(const ALCcontext *context, const ALeffectslot *slot, const ALeffectProps *props) override;
|
||||
void update(const ALCcontext *context, const ALeffectslot *slot, const ALeffectProps *props, const EffectTarget target) override;
|
||||
void process(ALsizei samplesToDo, const ALfloat (*RESTRICT samplesIn)[BUFFERSIZE], ALfloat (*RESTRICT samplesOut)[BUFFERSIZE], ALsizei numChannels) override;
|
||||
|
||||
DEF_NEWDEL(ALnullState)
|
||||
@@ -48,7 +48,7 @@ ALboolean ALnullState::deviceUpdate(const ALCdevice* UNUSED(device))
|
||||
/* This updates the effect state. This is called any time the effect is
|
||||
* (re)loaded into a slot.
|
||||
*/
|
||||
void ALnullState::update(const ALCcontext* UNUSED(context), const ALeffectslot* UNUSED(slot), const ALeffectProps* UNUSED(props))
|
||||
void ALnullState::update(const ALCcontext* UNUSED(context), const ALeffectslot* UNUSED(slot), const ALeffectProps* UNUSED(props), const EffectTarget UNUSED(target))
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -144,7 +144,7 @@ struct ALpshifterState final : public EffectState {
|
||||
|
||||
|
||||
ALboolean deviceUpdate(const ALCdevice *device) override;
|
||||
void update(const ALCcontext *context, const ALeffectslot *slot, const ALeffectProps *props) override;
|
||||
void update(const ALCcontext *context, const ALeffectslot *slot, const ALeffectProps *props, const EffectTarget target) override;
|
||||
void process(ALsizei samplesToDo, const ALfloat (*RESTRICT samplesIn)[BUFFERSIZE], ALfloat (*RESTRICT samplesOut)[BUFFERSIZE], ALsizei numChannels) override;
|
||||
|
||||
DEF_NEWDEL(ALpshifterState)
|
||||
@@ -173,7 +173,7 @@ ALboolean ALpshifterState::deviceUpdate(const ALCdevice *device)
|
||||
return AL_TRUE;
|
||||
}
|
||||
|
||||
void ALpshifterState::update(const ALCcontext *context, const ALeffectslot *slot, const ALeffectProps *props)
|
||||
void ALpshifterState::update(const ALCcontext* UNUSED(context), const ALeffectslot *slot, const ALeffectProps *props, const EffectTarget target)
|
||||
{
|
||||
const float pitch{std::pow(2.0f,
|
||||
(ALfloat)(props->Pshifter.CoarseTune*100 + props->Pshifter.FineTune) / 1200.0f
|
||||
@@ -183,19 +183,10 @@ void ALpshifterState::update(const ALCcontext *context, const ALeffectslot *slot
|
||||
|
||||
ALfloat coeffs[MAX_AMBI_COEFFS];
|
||||
CalcAngleCoeffs(0.0f, 0.0f, 0.0f, coeffs);
|
||||
if(ALeffectslot *target{slot->Params.Target})
|
||||
{
|
||||
mOutBuffer = target->WetBuffer;
|
||||
mOutChannels = target->NumChannels;
|
||||
ComputePanGains(target, coeffs, slot->Params.Gain, mTargetGains);
|
||||
}
|
||||
else
|
||||
{
|
||||
const ALCdevice *device{context->Device};
|
||||
mOutBuffer = device->Dry.Buffer;
|
||||
mOutChannels = device->Dry.NumChannels;
|
||||
ComputePanGains(&device->Dry, coeffs, slot->Params.Gain, mTargetGains);
|
||||
}
|
||||
|
||||
mOutBuffer = target.Main->Buffer;
|
||||
mOutChannels = target.Main->NumChannels;
|
||||
ComputePanGains(target.Main, coeffs, slot->Params.Gain, mTargetGains);
|
||||
}
|
||||
|
||||
void ALpshifterState::process(ALsizei SamplesToDo, const ALfloat (*RESTRICT SamplesIn)[BUFFERSIZE], ALfloat (*RESTRICT SamplesOut)[BUFFERSIZE], ALsizei NumChannels)
|
||||
|
||||
+12
-25
@@ -337,7 +337,7 @@ struct ReverbState final : public EffectState {
|
||||
|
||||
|
||||
ALboolean deviceUpdate(const ALCdevice *device) override;
|
||||
void update(const ALCcontext *context, const ALeffectslot *slot, const ALeffectProps *props) override;
|
||||
void update(const ALCcontext *context, const ALeffectslot *slot, const ALeffectProps *props, const EffectTarget target) override;
|
||||
void process(ALsizei samplesToDo, const ALfloat (*RESTRICT samplesIn)[BUFFERSIZE], ALfloat (*RESTRICT samplesOut)[BUFFERSIZE], ALsizei numChannels) override;
|
||||
|
||||
DEF_NEWDEL(ReverbState)
|
||||
@@ -763,7 +763,7 @@ alu::Matrix GetTransformFromVector(const ALfloat *vec)
|
||||
}
|
||||
|
||||
/* Update the early and late 3D panning gains. */
|
||||
ALvoid Update3DPanning(const ALCdevice *Device, const ALfloat *ReflectionsPan, const ALfloat *LateReverbPan, const ALfloat earlyGain, const ALfloat lateGain, ALeffectslot *target, ReverbState *State)
|
||||
ALvoid Update3DPanning(const ALfloat *ReflectionsPan, const ALfloat *LateReverbPan, const ALfloat earlyGain, const ALfloat lateGain, const EffectTarget &target, ReverbState *State)
|
||||
{
|
||||
/* Note: ret is transposed. */
|
||||
auto MatrixMult = [](const alu::Matrix &m1, const alu::Matrix &m2) noexcept -> alu::Matrix
|
||||
@@ -783,28 +783,16 @@ ALvoid Update3DPanning(const ALCdevice *Device, const ALfloat *ReflectionsPan, c
|
||||
*/
|
||||
alu::Matrix earlymat{MatrixMult(GetTransformFromVector(ReflectionsPan), A2B)};
|
||||
alu::Matrix latemat{MatrixMult(GetTransformFromVector(LateReverbPan), A2B)};
|
||||
if(target)
|
||||
{
|
||||
State->mOutBuffer = target->WetBuffer;
|
||||
State->mOutChannels = target->NumChannels;
|
||||
for(ALsizei i{0};i < MAX_EFFECT_CHANNELS;i++)
|
||||
ComputePanGains(target, earlymat[i].data(), earlyGain, State->mEarly.PanGain[i]);
|
||||
for(ALsizei i{0};i < MAX_EFFECT_CHANNELS;i++)
|
||||
ComputePanGains(target, latemat[i].data(), lateGain, State->mLate.PanGain[i]);
|
||||
}
|
||||
else
|
||||
{
|
||||
State->mOutBuffer = Device->FOAOut.Buffer;
|
||||
State->mOutChannels = Device->FOAOut.NumChannels;
|
||||
for(ALsizei i{0};i < MAX_EFFECT_CHANNELS;i++)
|
||||
ComputePanGains(&Device->FOAOut, earlymat[i].data(), earlyGain,
|
||||
State->mEarly.PanGain[i]);
|
||||
for(ALsizei i{0};i < MAX_EFFECT_CHANNELS;i++)
|
||||
ComputePanGains(&Device->FOAOut, latemat[i].data(), lateGain, State->mLate.PanGain[i]);
|
||||
}
|
||||
State->mOutBuffer = target.FOAOut->Buffer;
|
||||
State->mOutChannels = target.FOAOut->NumChannels;
|
||||
for(ALsizei i{0};i < MAX_EFFECT_CHANNELS;i++)
|
||||
ComputePanGains(target.FOAOut, earlymat[i].data(), earlyGain,
|
||||
State->mEarly.PanGain[i]);
|
||||
for(ALsizei i{0};i < MAX_EFFECT_CHANNELS;i++)
|
||||
ComputePanGains(target.FOAOut, latemat[i].data(), lateGain, State->mLate.PanGain[i]);
|
||||
}
|
||||
|
||||
void ReverbState::update(const ALCcontext *Context, const ALeffectslot *Slot, const ALeffectProps *props)
|
||||
void ReverbState::update(const ALCcontext *Context, const ALeffectslot *Slot, const ALeffectProps *props, const EffectTarget target)
|
||||
{
|
||||
const ALCdevice *Device{Context->Device};
|
||||
const ALlistener &Listener = Context->Listener;
|
||||
@@ -863,9 +851,8 @@ void ReverbState::update(const ALCcontext *Context, const ALeffectslot *Slot, co
|
||||
|
||||
/* Update early and late 3D panning. */
|
||||
const ALfloat gain{props->Reverb.Gain * Slot->Params.Gain * ReverbBoost};
|
||||
Update3DPanning(Device, props->Reverb.ReflectionsPan, props->Reverb.LateReverbPan,
|
||||
props->Reverb.ReflectionsGain*gain, props->Reverb.LateReverbGain*gain,
|
||||
Slot->Params.Target, this);
|
||||
Update3DPanning(props->Reverb.ReflectionsPan, props->Reverb.LateReverbPan,
|
||||
props->Reverb.ReflectionsGain*gain, props->Reverb.LateReverbGain*gain, target, this);
|
||||
|
||||
/* Calculate the max update size from the smallest relevant delay. */
|
||||
mMaxUpdate[1] = mini(MAX_UPDATE_SAMPLES, mini(mEarly.Offset[0][1], mLate.Offset[0][1]));
|
||||
|
||||
@@ -10,6 +10,11 @@
|
||||
|
||||
struct ALeffectslot;
|
||||
|
||||
struct EffectTarget {
|
||||
MixParams *Main;
|
||||
MixParams *FOAOut;
|
||||
RealMixParams *RealOut;
|
||||
};
|
||||
|
||||
struct EffectState {
|
||||
RefCount mRef{1u};
|
||||
@@ -21,7 +26,7 @@ struct EffectState {
|
||||
virtual ~EffectState() = default;
|
||||
|
||||
virtual ALboolean deviceUpdate(const ALCdevice *device) = 0;
|
||||
virtual void update(const ALCcontext *context, const ALeffectslot *slot, const ALeffectProps *props) = 0;
|
||||
virtual void update(const ALCcontext *context, const ALeffectslot *slot, const ALeffectProps *props, const EffectTarget target) = 0;
|
||||
virtual void process(ALsizei samplesToDo, const ALfloat (*RESTRICT samplesIn)[BUFFERSIZE], ALfloat (*RESTRICT samplesOut)[BUFFERSIZE], ALsizei numChannels) = 0;
|
||||
|
||||
void IncRef() noexcept;
|
||||
|
||||
@@ -538,10 +538,10 @@ enum RenderMode {
|
||||
|
||||
|
||||
typedef ALfloat ChannelConfig[MAX_AMBI_COEFFS];
|
||||
typedef struct BFChannelConfig {
|
||||
struct BFChannelConfig {
|
||||
ALfloat Scale;
|
||||
ALsizei Index;
|
||||
} BFChannelConfig;
|
||||
};
|
||||
|
||||
typedef union AmbiConfig {
|
||||
/* Ambisonic coefficients for mixing to the dry buffer. */
|
||||
|
||||
Reference in New Issue
Block a user