aboutsummaryrefslogtreecommitdiffstats
path: root/Alc
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2018-12-23 08:51:28 -0800
committerChris Robinson <[email protected]>2018-12-23 08:51:28 -0800
commit3fe38fed7c29869a43b42d634417452b1a5fedbc (patch)
treeb61cd690dbaced50afef8ff69c880d9a99136149 /Alc
parente218999b4f408b7fd35daa9d021288b68f5b4ab5 (diff)
Mix effect slot output to the effect target if it's set
Diffstat (limited to 'Alc')
-rw-r--r--Alc/effects/autowah.cpp21
-rw-r--r--Alc/effects/chorus.cpp22
-rw-r--r--Alc/effects/compressor.cpp24
-rw-r--r--Alc/effects/dedicated.cpp16
-rw-r--r--Alc/effects/distortion.cpp13
-rw-r--r--Alc/effects/echo.cpp24
-rw-r--r--Alc/effects/equalizer.cpp21
-rw-r--r--Alc/effects/fshifter.cpp13
-rw-r--r--Alc/effects/modulator.cpp21
-rw-r--r--Alc/effects/pshifter.cpp23
-rw-r--r--Alc/effects/reverb.cpp39
-rw-r--r--Alc/panning.cpp3
12 files changed, 179 insertions, 61 deletions
diff --git a/Alc/effects/autowah.cpp b/Alc/effects/autowah.cpp
index e034c610..e455acf2 100644
--- a/Alc/effects/autowah.cpp
+++ b/Alc/effects/autowah.cpp
@@ -119,11 +119,22 @@ void ALautowahState::update(const ALCcontext *context, const ALeffectslot *slot,
mFreqMinNorm = MIN_FREQ / device->Frequency;
mBandwidthNorm = (MAX_FREQ-MIN_FREQ) / device->Frequency;
- 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);
+ 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);
+ }
}
void ALautowahState::process(ALsizei SamplesToDo, const ALfloat (*RESTRICT SamplesIn)[BUFFERSIZE], ALfloat (*RESTRICT SamplesOut)[BUFFERSIZE], ALsizei NumChannels)
diff --git a/Alc/effects/chorus.cpp b/Alc/effects/chorus.cpp
index 925cd09f..1a444525 100644
--- a/Alc/effects/chorus.cpp
+++ b/Alc/effects/chorus.cpp
@@ -146,11 +146,23 @@ void ChorusState::update(const ALCcontext *Context, const ALeffectslot *Slot, co
mFeedback = props->Chorus.Feedback;
/* Gains for left and right sides */
- ALfloat coeffs[MAX_AMBI_COEFFS];
- CalcAngleCoeffs(-F_PI_2, 0.0f, 0.0f, coeffs);
- ComputePanGains(&device->Dry, coeffs, Slot->Params.Gain, mGains[0].Target);
- CalcAngleCoeffs( F_PI_2, 0.0f, 0.0f, coeffs);
- ComputePanGains(&device->Dry, coeffs, Slot->Params.Gain, mGains[1].Target);
+ 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);
+ }
ALfloat rate{props->Chorus.Rate};
if(!(rate > 0.0f))
diff --git a/Alc/effects/compressor.cpp b/Alc/effects/compressor.cpp
index d502be43..8505f161 100644
--- a/Alc/effects/compressor.cpp
+++ b/Alc/effects/compressor.cpp
@@ -74,15 +74,25 @@ ALboolean ALcompressorState::deviceUpdate(const ALCdevice *device)
void ALcompressorState::update(const ALCcontext *context, const ALeffectslot *slot, const ALeffectProps *props)
{
- const ALCdevice *device = context->Device;
-
mEnabled = props->Compressor.OnOff;
- 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]);
+ 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]);
+ }
}
void ALcompressorState::process(ALsizei SamplesToDo, const ALfloat (*RESTRICT SamplesIn)[BUFFERSIZE], ALfloat (*RESTRICT SamplesOut)[BUFFERSIZE], ALsizei NumChannels)
diff --git a/Alc/effects/dedicated.cpp b/Alc/effects/dedicated.cpp
index fa550397..851e48a5 100644
--- a/Alc/effects/dedicated.cpp
+++ b/Alc/effects/dedicated.cpp
@@ -52,11 +52,23 @@ ALboolean ALdedicatedState::deviceUpdate(const ALCdevice *UNUSED(device))
void ALdedicatedState::update(const ALCcontext *context, const ALeffectslot *slot, const ALeffectProps *props)
{
const ALCdevice *device = context->Device;
- ALfloat Gain;
std::fill(std::begin(mTargetGains), std::end(mTargetGains), 0.0f);
- Gain = slot->Params.Gain * props->Dedicated.Gain;
+ 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;
diff --git a/Alc/effects/distortion.cpp b/Alc/effects/distortion.cpp
index 58d05e8f..eb4ff975 100644
--- a/Alc/effects/distortion.cpp
+++ b/Alc/effects/distortion.cpp
@@ -90,7 +90,18 @@ void ALdistortionState::update(const ALCcontext *context, const ALeffectslot *sl
);
CalcAngleCoeffs(0.0f, 0.0f, 0.0f, coeffs);
- ComputePanGains(&device->Dry, coeffs, slot->Params.Gain*props->Distortion.Gain, mGain);
+ 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);
+ }
}
void ALdistortionState::process(ALsizei SamplesToDo, const ALfloat (*RESTRICT SamplesIn)[BUFFERSIZE], ALfloat (*RESTRICT SamplesOut)[BUFFERSIZE], ALsizei NumChannels)
diff --git a/Alc/effects/echo.cpp b/Alc/effects/echo.cpp
index b9310193..dae99912 100644
--- a/Alc/effects/echo.cpp
+++ b/Alc/effects/echo.cpp
@@ -94,7 +94,6 @@ void ALechoState::update(const ALCcontext *context, const ALeffectslot *slot, co
{
const ALCdevice *device = context->Device;
ALuint frequency = device->Frequency;
- ALfloat coeffs[MAX_AMBI_COEFFS];
ALfloat gainhf, lrpan, spread;
mTap[0].delay = maxi(float2int(props->Echo.Delay*frequency + 0.5f), 1);
@@ -116,13 +115,24 @@ void ALechoState::update(const ALCcontext *context, const ALeffectslot *slot, co
calc_rcpQ_from_slope(gainhf, 1.0f)
);
- /* First tap panning */
- CalcAngleCoeffs(-F_PI_2*lrpan, 0.0f, spread, coeffs);
- ComputePanGains(&device->Dry, coeffs, slot->Params.Gain, mGains[0].Target);
+ ALfloat coeffs[2][MAX_AMBI_COEFFS];
+ CalcAngleCoeffs(-F_PI_2*lrpan, 0.0f, spread, coeffs[0]);
+ CalcAngleCoeffs( F_PI_2*lrpan, 0.0f, spread, coeffs[1]);
- /* Second tap panning */
- CalcAngleCoeffs( F_PI_2*lrpan, 0.0f, spread, coeffs);
- ComputePanGains(&device->Dry, coeffs, slot->Params.Gain, mGains[1].Target);
+ 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);
+ }
}
void ALechoState::process(ALsizei SamplesToDo, const ALfloat (*RESTRICT SamplesIn)[BUFFERSIZE], ALfloat (*RESTRICT SamplesOut)[BUFFERSIZE], ALsizei NumChannels)
diff --git a/Alc/effects/equalizer.cpp b/Alc/effects/equalizer.cpp
index a10316e8..53975d19 100644
--- a/Alc/effects/equalizer.cpp
+++ b/Alc/effects/equalizer.cpp
@@ -152,11 +152,22 @@ void ALequalizerState::update(const ALCcontext *context, const ALeffectslot *slo
mChans[i].filter[3].copyParamsFrom(mChans[0].filter[3]);
}
- 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);
+ 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);
+ }
}
void ALequalizerState::process(ALsizei SamplesToDo, const ALfloat (*RESTRICT SamplesIn)[BUFFERSIZE], ALfloat (*RESTRICT SamplesOut)[BUFFERSIZE], ALsizei NumChannels)
diff --git a/Alc/effects/fshifter.cpp b/Alc/effects/fshifter.cpp
index 9b6d700c..e8311620 100644
--- a/Alc/effects/fshifter.cpp
+++ b/Alc/effects/fshifter.cpp
@@ -132,7 +132,18 @@ void ALfshifterState::update(const ALCcontext *context, const ALeffectslot *slot
ALfloat coeffs[MAX_AMBI_COEFFS];
CalcAngleCoeffs(0.0f, 0.0f, 0.0f, coeffs);
- ComputePanGains(&device->Dry, coeffs, slot->Params.Gain, mTargetGains);
+ 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);
+ }
}
void ALfshifterState::process(ALsizei SamplesToDo, const ALfloat (*RESTRICT SamplesIn)[BUFFERSIZE], ALfloat (*RESTRICT SamplesOut)[BUFFERSIZE], ALsizei NumChannels)
diff --git a/Alc/effects/modulator.cpp b/Alc/effects/modulator.cpp
index d686c362..84aa0e2c 100644
--- a/Alc/effects/modulator.cpp
+++ b/Alc/effects/modulator.cpp
@@ -131,11 +131,22 @@ void ALmodulatorState::update(const ALCcontext *context, const ALeffectslot *slo
for(i = 1;i < MAX_EFFECT_CHANNELS;i++)
mChans[i].Filter.copyParamsFrom(mChans[0].Filter);
- 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);
+ 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);
+ }
}
void ALmodulatorState::process(ALsizei SamplesToDo, const ALfloat (*RESTRICT SamplesIn)[BUFFERSIZE], ALfloat (*RESTRICT SamplesOut)[BUFFERSIZE], ALsizei NumChannels)
diff --git a/Alc/effects/pshifter.cpp b/Alc/effects/pshifter.cpp
index 3825bfd5..321e7492 100644
--- a/Alc/effects/pshifter.cpp
+++ b/Alc/effects/pshifter.cpp
@@ -175,18 +175,27 @@ ALboolean ALpshifterState::deviceUpdate(const ALCdevice *device)
void ALpshifterState::update(const ALCcontext *context, const ALeffectslot *slot, const ALeffectProps *props)
{
- const ALCdevice *device = context->Device;
- ALfloat coeffs[MAX_AMBI_COEFFS];
- float pitch;
-
- pitch = std::pow(2.0f,
+ const float pitch{std::pow(2.0f,
(ALfloat)(props->Pshifter.CoarseTune*100 + props->Pshifter.FineTune) / 1200.0f
- );
+ )};
mPitchShiftI = fastf2i(pitch*FRACTIONONE);
mPitchShift = mPitchShiftI * (1.0f/FRACTIONONE);
+ ALfloat coeffs[MAX_AMBI_COEFFS];
CalcAngleCoeffs(0.0f, 0.0f, 0.0f, coeffs);
- ComputePanGains(&device->Dry, coeffs, slot->Params.Gain, mTargetGains);
+ 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);
+ }
}
void ALpshifterState::process(ALsizei SamplesToDo, const ALfloat (*RESTRICT SamplesIn)[BUFFERSIZE], ALfloat (*RESTRICT SamplesOut)[BUFFERSIZE], ALsizei NumChannels)
diff --git a/Alc/effects/reverb.cpp b/Alc/effects/reverb.cpp
index b70e3d45..a84749d8 100644
--- a/Alc/effects/reverb.cpp
+++ b/Alc/effects/reverb.cpp
@@ -763,11 +763,8 @@ 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, ReverbState *State)
+ALvoid Update3DPanning(const ALCdevice *Device, const ALfloat *ReflectionsPan, const ALfloat *LateReverbPan, const ALfloat earlyGain, const ALfloat lateGain, ALeffectslot *target, ReverbState *State)
{
- State->mOutBuffer = Device->FOAOut.Buffer;
- State->mOutChannels = Device->FOAOut.NumChannels;
-
/* Note: ret is transposed. */
auto MatrixMult = [](const alu::Matrix &m1, const alu::Matrix &m2) noexcept -> alu::Matrix
{
@@ -784,17 +781,27 @@ ALvoid Update3DPanning(const ALCdevice *Device, const ALfloat *ReflectionsPan, c
/* Create a matrix that first converts A-Format to B-Format, then
* transforms the B-Format signal according to the panning vector.
*/
- alu::Matrix rot{GetTransformFromVector(ReflectionsPan)};
- alu::Matrix transform{MatrixMult(rot, A2B)};
- for(ALsizei i{0};i < MAX_EFFECT_CHANNELS;i++)
- ComputePanGains(&Device->FOAOut, transform[i].data(), earlyGain,
- State->mEarly.PanGain[i]);
-
- rot = GetTransformFromVector(LateReverbPan);
- transform = MatrixMult(rot, A2B);
- for(ALsizei i{0};i < MAX_EFFECT_CHANNELS;i++)
- ComputePanGains(&Device->FOAOut, transform[i].data(), lateGain,
- State->mLate.PanGain[i]);
+ 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]);
+ }
}
void ReverbState::update(const ALCcontext *Context, const ALeffectslot *Slot, const ALeffectProps *props)
@@ -858,7 +865,7 @@ void ReverbState::update(const ALCcontext *Context, const ALeffectslot *Slot, co
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,
- this);
+ Slot->Params.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]));
diff --git a/Alc/panning.cpp b/Alc/panning.cpp
index f15c086e..cec6eaf7 100644
--- a/Alc/panning.cpp
+++ b/Alc/panning.cpp
@@ -867,6 +867,9 @@ void ComputePanningGainsBF(const BFChannelConfig *chanmap, ALsizei numchans, con
std::fill(iter, std::end(gains), 0.0f);
}
+void ComputePanGains(const ALeffectslot *slot, const ALfloat*RESTRICT coeffs, ALfloat ingain, ALfloat (&gains)[MAX_OUTPUT_CHANNELS])
+{ ComputePanningGainsBF(slot->ChanMap, slot->NumChannels, coeffs, ingain, gains); }
+
void aluInitRenderer(ALCdevice *device, ALint hrtf_id, HrtfRequestMode hrtf_appreq, HrtfRequestMode hrtf_userreq)
{