Use a span for effect state input
This commit is contained in:
+1
-2
@@ -1416,8 +1416,7 @@ void ProcessContext(ALCcontext *ctx, const ALuint SamplesToDo)
|
||||
[SamplesToDo](const ALeffectslot *slot) -> void
|
||||
{
|
||||
EffectState *state{slot->Params.mEffectState};
|
||||
state->process(SamplesToDo, slot->Wet.Buffer.data(),
|
||||
static_cast<ALsizei>(slot->Wet.Buffer.size()), state->mOutTarget);
|
||||
state->process(SamplesToDo, slot->Wet.Buffer, state->mOutTarget);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
+12
-11
@@ -71,7 +71,7 @@ struct ALautowahState final : public EffectState {
|
||||
|
||||
ALboolean deviceUpdate(const ALCdevice *device) override;
|
||||
void update(const ALCcontext *context, const ALeffectslot *slot, const EffectProps *props, const EffectTarget target) override;
|
||||
void process(const size_t samplesToDo, const FloatBufferLine *RESTRICT samplesIn, const ALsizei numInput, const al::span<FloatBufferLine> samplesOut) override;
|
||||
void process(const size_t samplesToDo, const al::span<const FloatBufferLine> samplesIn, const al::span<FloatBufferLine> samplesOut) override;
|
||||
|
||||
DEF_NEWDEL(ALautowahState)
|
||||
};
|
||||
@@ -126,7 +126,7 @@ void ALautowahState::update(const ALCcontext *context, const ALeffectslot *slot,
|
||||
}
|
||||
}
|
||||
|
||||
void ALautowahState::process(const size_t samplesToDo, const FloatBufferLine *RESTRICT samplesIn, const ALsizei numInput, const al::span<FloatBufferLine> samplesOut)
|
||||
void ALautowahState::process(const size_t samplesToDo, const al::span<const FloatBufferLine> samplesIn, const al::span<FloatBufferLine> samplesOut)
|
||||
{
|
||||
const ALfloat attack_rate = mAttackRate;
|
||||
const ALfloat release_rate = mReleaseRate;
|
||||
@@ -154,8 +154,8 @@ void ALautowahState::process(const size_t samplesToDo, const FloatBufferLine *RE
|
||||
}
|
||||
mEnvDelay = env_delay;
|
||||
|
||||
ASSUME(numInput > 0);
|
||||
for(ALsizei c{0};c < numInput;++c)
|
||||
auto chandata = std::addressof(mChans[0]);
|
||||
for(const auto &insamples : samplesIn)
|
||||
{
|
||||
/* This effectively inlines BiquadFilter_setParams for a peaking
|
||||
* filter and BiquadFilter_processC. The alpha and cosine components
|
||||
@@ -163,8 +163,8 @@ void ALautowahState::process(const size_t samplesToDo, const FloatBufferLine *RE
|
||||
* envelope. Because the filter changes for each sample, the
|
||||
* coefficients are transient and don't need to be held.
|
||||
*/
|
||||
ALfloat z1{mChans[c].Filter.z1};
|
||||
ALfloat z2{mChans[c].Filter.z2};
|
||||
ALfloat z1{chandata->Filter.z1};
|
||||
ALfloat z2{chandata->Filter.z2};
|
||||
|
||||
for(size_t i{0u};i < samplesToDo;i++)
|
||||
{
|
||||
@@ -180,18 +180,19 @@ void ALautowahState::process(const size_t samplesToDo, const FloatBufferLine *RE
|
||||
a[1] = -2.0f * cos_w0;
|
||||
a[2] = 1.0f - alpha/res_gain;
|
||||
|
||||
input = samplesIn[c][i];
|
||||
input = insamples[i];
|
||||
output = input*(b[0]/a[0]) + z1;
|
||||
z1 = input*(b[1]/a[0]) - output*(a[1]/a[0]) + z2;
|
||||
z2 = input*(b[2]/a[0]) - output*(a[2]/a[0]);
|
||||
mBufferOut[i] = output;
|
||||
}
|
||||
mChans[c].Filter.z1 = z1;
|
||||
mChans[c].Filter.z2 = z2;
|
||||
chandata->Filter.z1 = z1;
|
||||
chandata->Filter.z2 = z2;
|
||||
|
||||
/* Now, mix the processed sound data to the output. */
|
||||
MixSamples({mBufferOut, samplesToDo}, samplesOut, mChans[c].CurrentGains,
|
||||
mChans[c].TargetGains, samplesToDo, 0);
|
||||
MixSamples({mBufferOut, samplesToDo}, samplesOut, chandata->CurrentGains,
|
||||
chandata->TargetGains, samplesToDo, 0);
|
||||
++chandata;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -159,7 +159,7 @@ struct EffectState : public al::intrusive_ref<EffectState> {
|
||||
|
||||
virtual ALboolean deviceUpdate(const ALCdevice *device) = 0;
|
||||
virtual void update(const ALCcontext *context, const ALeffectslot *slot, const EffectProps *props, const EffectTarget target) = 0;
|
||||
virtual void process(const size_t samplesToDo, const FloatBufferLine *RESTRICT samplesIn, const ALsizei numInput, const al::span<FloatBufferLine> samplesOut) = 0;
|
||||
virtual void process(const size_t samplesToDo, const al::span<const FloatBufferLine> samplesIn, const al::span<FloatBufferLine> samplesOut) = 0;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -111,7 +111,7 @@ struct ChorusState final : public EffectState {
|
||||
|
||||
ALboolean deviceUpdate(const ALCdevice *device) override;
|
||||
void update(const ALCcontext *context, const ALeffectslot *slot, const EffectProps *props, const EffectTarget target) override;
|
||||
void process(const size_t samplesToDo, const FloatBufferLine *RESTRICT samplesIn, const ALsizei numInput, const al::span<FloatBufferLine> samplesOut) override;
|
||||
void process(const size_t samplesToDo, const al::span<const FloatBufferLine> samplesIn, const al::span<FloatBufferLine> samplesOut) override;
|
||||
|
||||
DEF_NEWDEL(ChorusState)
|
||||
};
|
||||
@@ -207,7 +207,7 @@ void ChorusState::update(const ALCcontext *Context, const ALeffectslot *Slot, co
|
||||
}
|
||||
}
|
||||
|
||||
void ChorusState::process(const size_t samplesToDo, const FloatBufferLine *RESTRICT samplesIn, const ALsizei /*numInput*/, const al::span<FloatBufferLine> samplesOut)
|
||||
void ChorusState::process(const size_t samplesToDo, const al::span<const FloatBufferLine> samplesIn, const al::span<FloatBufferLine> samplesOut)
|
||||
{
|
||||
const auto bufmask = static_cast<ALsizei>(mSampleBuffer.size()-1);
|
||||
const ALfloat feedback{mFeedback};
|
||||
|
||||
@@ -51,7 +51,7 @@ struct CompressorState final : public EffectState {
|
||||
|
||||
ALboolean deviceUpdate(const ALCdevice *device) override;
|
||||
void update(const ALCcontext *context, const ALeffectslot *slot, const EffectProps *props, const EffectTarget target) override;
|
||||
void process(const size_t samplesToDo, const FloatBufferLine *RESTRICT samplesIn, const ALsizei numInput, const al::span<FloatBufferLine> samplesOut) override;
|
||||
void process(const size_t samplesToDo, const al::span<const FloatBufferLine> samplesIn, const al::span<FloatBufferLine> samplesOut) override;
|
||||
|
||||
DEF_NEWDEL(CompressorState)
|
||||
};
|
||||
@@ -85,7 +85,7 @@ void CompressorState::update(const ALCcontext*, const ALeffectslot *slot, const
|
||||
}
|
||||
}
|
||||
|
||||
void CompressorState::process(const size_t samplesToDo, const FloatBufferLine *RESTRICT samplesIn, const ALsizei numInput, const al::span<FloatBufferLine> samplesOut)
|
||||
void CompressorState::process(const size_t samplesToDo, const al::span<const FloatBufferLine> samplesIn, const al::span<FloatBufferLine> samplesOut)
|
||||
{
|
||||
for(size_t base{0u};base < samplesToDo;)
|
||||
{
|
||||
@@ -134,10 +134,10 @@ void CompressorState::process(const size_t samplesToDo, const FloatBufferLine *R
|
||||
mEnvFollower = env;
|
||||
|
||||
/* Now compress the signal amplitude to output. */
|
||||
ASSUME(numInput > 0);
|
||||
for(ALsizei j{0};j < numInput;j++)
|
||||
auto changains = std::addressof(mGain[0]);
|
||||
for(const auto &input : samplesIn)
|
||||
{
|
||||
const ALfloat *outgains{mGain[j]};
|
||||
const ALfloat *outgains{*(changains++)};
|
||||
for(FloatBufferLine &output : samplesOut)
|
||||
{
|
||||
const ALfloat gain{*(outgains++)};
|
||||
@@ -145,7 +145,7 @@ void CompressorState::process(const size_t samplesToDo, const FloatBufferLine *R
|
||||
continue;
|
||||
|
||||
for(size_t i{0u};i < td;i++)
|
||||
output[base+i] += samplesIn[j][base+i] * gains[i] * gain;
|
||||
output[base+i] += input[base+i] * gains[i] * gain;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ struct DedicatedState final : public EffectState {
|
||||
|
||||
ALboolean deviceUpdate(const ALCdevice *device) override;
|
||||
void update(const ALCcontext *context, const ALeffectslot *slot, const EffectProps *props, const EffectTarget target) override;
|
||||
void process(const size_t samplesToDo, const FloatBufferLine *RESTRICT samplesIn, const ALsizei numInput, const al::span<FloatBufferLine> samplesOut) override;
|
||||
void process(const size_t samplesToDo, const al::span<const FloatBufferLine> samplesIn, const al::span<FloatBufferLine> samplesOut) override;
|
||||
|
||||
DEF_NEWDEL(DedicatedState)
|
||||
};
|
||||
@@ -86,7 +86,7 @@ void DedicatedState::update(const ALCcontext*, const ALeffectslot *slot, const E
|
||||
}
|
||||
}
|
||||
|
||||
void DedicatedState::process(const size_t samplesToDo, const FloatBufferLine *RESTRICT samplesIn, const ALsizei /*numInput*/, const al::span<FloatBufferLine> samplesOut)
|
||||
void DedicatedState::process(const size_t samplesToDo, const al::span<const FloatBufferLine> samplesIn, const al::span<FloatBufferLine> samplesOut)
|
||||
{
|
||||
MixSamples({samplesIn[0].data(), samplesToDo}, samplesOut, mCurrentGains, mTargetGains,
|
||||
samplesToDo, 0);
|
||||
|
||||
@@ -49,7 +49,7 @@ struct DistortionState final : public EffectState {
|
||||
|
||||
ALboolean deviceUpdate(const ALCdevice *device) override;
|
||||
void update(const ALCcontext *context, const ALeffectslot *slot, const EffectProps *props, const EffectTarget target) override;
|
||||
void process(const size_t samplesToDo, const FloatBufferLine *RESTRICT samplesIn, const ALsizei numInput, const al::span<FloatBufferLine> samplesOut) override;
|
||||
void process(const size_t samplesToDo, const al::span<const FloatBufferLine> samplesIn, const al::span<FloatBufferLine> samplesOut) override;
|
||||
|
||||
DEF_NEWDEL(DistortionState)
|
||||
};
|
||||
@@ -93,7 +93,7 @@ void DistortionState::update(const ALCcontext *context, const ALeffectslot *slot
|
||||
ComputePanGains(target.Main, coeffs, slot->Params.Gain*props->Distortion.Gain, mGain);
|
||||
}
|
||||
|
||||
void DistortionState::process(const size_t samplesToDo, const FloatBufferLine *RESTRICT samplesIn, const ALsizei /*numInput*/, const al::span<FloatBufferLine> samplesOut)
|
||||
void DistortionState::process(const size_t samplesToDo, const al::span<const FloatBufferLine> samplesIn, const al::span<FloatBufferLine> samplesOut)
|
||||
{
|
||||
const ALfloat fc{mEdgeCoeff};
|
||||
for(size_t base{0u};base < samplesToDo;)
|
||||
|
||||
@@ -59,7 +59,7 @@ struct EchoState final : public EffectState {
|
||||
|
||||
ALboolean deviceUpdate(const ALCdevice *device) override;
|
||||
void update(const ALCcontext *context, const ALeffectslot *slot, const EffectProps *props, const EffectTarget target) override;
|
||||
void process(const size_t samplesToDo, const FloatBufferLine *RESTRICT samplesIn, const ALsizei numInput, const al::span<FloatBufferLine> samplesOut) override;
|
||||
void process(const size_t samplesToDo, const al::span<const FloatBufferLine> samplesIn, const al::span<FloatBufferLine> samplesOut) override;
|
||||
|
||||
DEF_NEWDEL(EchoState)
|
||||
};
|
||||
@@ -117,7 +117,7 @@ void EchoState::update(const ALCcontext *context, const ALeffectslot *slot, cons
|
||||
ComputePanGains(target.Main, coeffs[1], slot->Params.Gain, mGains[1].Target);
|
||||
}
|
||||
|
||||
void EchoState::process(const size_t samplesToDo, const FloatBufferLine *RESTRICT samplesIn, const ALsizei /*numInput*/, const al::span<FloatBufferLine> samplesOut)
|
||||
void EchoState::process(const size_t samplesToDo, const al::span<const FloatBufferLine> samplesIn, const al::span<FloatBufferLine> samplesOut)
|
||||
{
|
||||
const auto mask = static_cast<ALsizei>(mSampleBuffer.size()-1);
|
||||
ALfloat *RESTRICT delaybuf{mSampleBuffer.data()};
|
||||
|
||||
+11
-10
@@ -93,7 +93,7 @@ struct EqualizerState final : public EffectState {
|
||||
|
||||
ALboolean deviceUpdate(const ALCdevice *device) override;
|
||||
void update(const ALCcontext *context, const ALeffectslot *slot, const EffectProps *props, const EffectTarget target) override;
|
||||
void process(const size_t samplesToDo, const FloatBufferLine *RESTRICT samplesIn, const ALsizei numInput, const al::span<FloatBufferLine> samplesOut) override;
|
||||
void process(const size_t samplesToDo, const al::span<const FloatBufferLine> samplesIn, const al::span<FloatBufferLine> samplesOut) override;
|
||||
|
||||
DEF_NEWDEL(EqualizerState)
|
||||
};
|
||||
@@ -157,18 +157,19 @@ void EqualizerState::update(const ALCcontext *context, const ALeffectslot *slot,
|
||||
}
|
||||
}
|
||||
|
||||
void EqualizerState::process(const size_t samplesToDo, const FloatBufferLine *RESTRICT samplesIn, const ALsizei numInput, const al::span<FloatBufferLine> samplesOut)
|
||||
void EqualizerState::process(const size_t samplesToDo, const al::span<const FloatBufferLine> samplesIn, const al::span<FloatBufferLine> samplesOut)
|
||||
{
|
||||
ASSUME(numInput > 0);
|
||||
for(ALsizei c{0};c < numInput;c++)
|
||||
auto chandata = std::addressof(mChans[0]);
|
||||
for(const auto &input : samplesIn)
|
||||
{
|
||||
mChans[c].filter[0].process(mSampleBuffer, samplesIn[c].data(), samplesToDo);
|
||||
mChans[c].filter[1].process(mSampleBuffer, mSampleBuffer, samplesToDo);
|
||||
mChans[c].filter[2].process(mSampleBuffer, mSampleBuffer, samplesToDo);
|
||||
mChans[c].filter[3].process(mSampleBuffer, mSampleBuffer, samplesToDo);
|
||||
chandata->filter[0].process(mSampleBuffer, input.data(), samplesToDo);
|
||||
chandata->filter[1].process(mSampleBuffer, mSampleBuffer, samplesToDo);
|
||||
chandata->filter[2].process(mSampleBuffer, mSampleBuffer, samplesToDo);
|
||||
chandata->filter[3].process(mSampleBuffer, mSampleBuffer, samplesToDo);
|
||||
|
||||
MixSamples({mSampleBuffer, samplesToDo}, samplesOut, mChans[c].CurrentGains,
|
||||
mChans[c].TargetGains, samplesToDo, 0);
|
||||
MixSamples({mSampleBuffer, samplesToDo}, samplesOut, chandata->CurrentGains,
|
||||
chandata->TargetGains, samplesToDo, 0);
|
||||
++chandata;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -85,7 +85,7 @@ struct FshifterState final : public EffectState {
|
||||
|
||||
ALboolean deviceUpdate(const ALCdevice *device) override;
|
||||
void update(const ALCcontext *context, const ALeffectslot *slot, const EffectProps *props, const EffectTarget target) override;
|
||||
void process(const size_t samplesToDo, const FloatBufferLine *RESTRICT samplesIn, const ALsizei numInput, const al::span<FloatBufferLine> samplesOut) override;
|
||||
void process(const size_t samplesToDo, const al::span<const FloatBufferLine> samplesIn, const al::span<FloatBufferLine> samplesOut) override;
|
||||
|
||||
DEF_NEWDEL(FshifterState)
|
||||
};
|
||||
@@ -160,7 +160,7 @@ void FshifterState::update(const ALCcontext *context, const ALeffectslot *slot,
|
||||
ComputePanGains(target.Main, coeffs[1], slot->Params.Gain, mGains[1].Target);
|
||||
}
|
||||
|
||||
void FshifterState::process(const size_t samplesToDo, const FloatBufferLine *RESTRICT samplesIn, const ALsizei /*numInput*/, const al::span<FloatBufferLine> samplesOut)
|
||||
void FshifterState::process(const size_t samplesToDo, const al::span<const FloatBufferLine> samplesIn, const al::span<FloatBufferLine> samplesOut)
|
||||
{
|
||||
static constexpr complex_d complex_zero{0.0, 0.0};
|
||||
ALfloat *RESTRICT BufferOut = mBufferOut;
|
||||
|
||||
@@ -91,7 +91,7 @@ struct ModulatorState final : public EffectState {
|
||||
|
||||
ALboolean deviceUpdate(const ALCdevice *device) override;
|
||||
void update(const ALCcontext *context, const ALeffectslot *slot, const EffectProps *props, const EffectTarget target) override;
|
||||
void process(const size_t samplesToDo, const FloatBufferLine *RESTRICT samplesIn, const ALsizei numInput, const al::span<FloatBufferLine> samplesOut) override;
|
||||
void process(const size_t samplesToDo, const al::span<const FloatBufferLine> samplesIn, const al::span<FloatBufferLine> samplesOut) override;
|
||||
|
||||
DEF_NEWDEL(ModulatorState)
|
||||
};
|
||||
@@ -138,7 +138,7 @@ void ModulatorState::update(const ALCcontext *context, const ALeffectslot *slot,
|
||||
}
|
||||
}
|
||||
|
||||
void ModulatorState::process(const size_t samplesToDo, const FloatBufferLine *RESTRICT samplesIn, const ALsizei numInput, const al::span<FloatBufferLine> samplesOut)
|
||||
void ModulatorState::process(const size_t samplesToDo, const al::span<const FloatBufferLine> samplesIn, const al::span<FloatBufferLine> samplesOut)
|
||||
{
|
||||
for(size_t base{0u};base < samplesToDo;)
|
||||
{
|
||||
@@ -149,17 +149,18 @@ void ModulatorState::process(const size_t samplesToDo, const FloatBufferLine *RE
|
||||
mIndex += (mStep*td) & WAVEFORM_FRACMASK;
|
||||
mIndex &= WAVEFORM_FRACMASK;
|
||||
|
||||
ASSUME(numInput > 0);
|
||||
for(ALsizei c{0};c < numInput;c++)
|
||||
auto chandata = std::addressof(mChans[0]);
|
||||
for(const auto &input : samplesIn)
|
||||
{
|
||||
alignas(16) ALfloat temps[MAX_UPDATE_SAMPLES];
|
||||
|
||||
mChans[c].Filter.process(temps, &samplesIn[c][base], td);
|
||||
chandata->Filter.process(temps, &input[base], td);
|
||||
for(size_t i{0u};i < td;i++)
|
||||
temps[i] *= modsamples[i];
|
||||
|
||||
MixSamples({temps, td}, samplesOut, mChans[c].CurrentGains, mChans[c].TargetGains,
|
||||
MixSamples({temps, td}, samplesOut, chandata->CurrentGains, chandata->TargetGains,
|
||||
samplesToDo-base, base);
|
||||
++chandata;
|
||||
}
|
||||
|
||||
base += td;
|
||||
|
||||
@@ -20,7 +20,7 @@ struct NullState final : public EffectState {
|
||||
|
||||
ALboolean deviceUpdate(const ALCdevice *device) override;
|
||||
void update(const ALCcontext *context, const ALeffectslot *slot, const EffectProps *props, const EffectTarget target) override;
|
||||
void process(const size_t samplesToDo, const FloatBufferLine *RESTRICT samplesIn, const ALsizei numInput, const al::span<FloatBufferLine> samplesOut) override;
|
||||
void process(const size_t samplesToDo, const al::span<const FloatBufferLine> samplesIn, const al::span<FloatBufferLine> samplesOut) override;
|
||||
|
||||
DEF_NEWDEL(NullState)
|
||||
};
|
||||
@@ -58,7 +58,7 @@ void NullState::update(const ALCcontext* /*context*/, const ALeffectslot* /*slot
|
||||
* not replace it.
|
||||
*/
|
||||
void NullState::process(const size_t/*samplesToDo*/,
|
||||
const FloatBufferLine *RESTRICT /*samplesIn*/, const ALsizei /*numInput*/,
|
||||
const al::span<const FloatBufferLine> /*samplesIn*/,
|
||||
const al::span<FloatBufferLine> /*samplesOut*/)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -118,7 +118,7 @@ struct PshifterState final : public EffectState {
|
||||
|
||||
ALboolean deviceUpdate(const ALCdevice *device) override;
|
||||
void update(const ALCcontext *context, const ALeffectslot *slot, const EffectProps *props, const EffectTarget target) override;
|
||||
void process(const size_t samplesToDo, const FloatBufferLine *RESTRICT samplesIn, const ALsizei numInput, const al::span<FloatBufferLine> samplesOut) override;
|
||||
void process(const size_t samplesToDo, const al::span<const FloatBufferLine> samplesIn, const al::span<FloatBufferLine> samplesOut) override;
|
||||
|
||||
DEF_NEWDEL(PshifterState)
|
||||
};
|
||||
@@ -161,7 +161,7 @@ void PshifterState::update(const ALCcontext*, const ALeffectslot *slot, const Ef
|
||||
ComputePanGains(target.Main, coeffs, slot->Params.Gain, mTargetGains);
|
||||
}
|
||||
|
||||
void PshifterState::process(const size_t samplesToDo, const FloatBufferLine *RESTRICT samplesIn, const ALsizei /*numInput*/, const al::span<FloatBufferLine> samplesOut)
|
||||
void PshifterState::process(const size_t samplesToDo, const al::span<const FloatBufferLine> samplesIn, const al::span<FloatBufferLine> samplesOut)
|
||||
{
|
||||
/* Pitch shifter engine based on the work of Stephan Bernsee.
|
||||
* http://blogs.zynaptiq.com/bernsee/pitch-shifting-using-the-ft/
|
||||
|
||||
@@ -483,7 +483,7 @@ struct ReverbState final : public EffectState {
|
||||
|
||||
ALboolean deviceUpdate(const ALCdevice *device) override;
|
||||
void update(const ALCcontext *context, const ALeffectslot *slot, const EffectProps *props, const EffectTarget target) override;
|
||||
void process(const size_t samplesToDo, const FloatBufferLine *RESTRICT samplesIn, const ALsizei numInput, const al::span<FloatBufferLine> samplesOut) override;
|
||||
void process(const size_t samplesToDo, const al::span<const FloatBufferLine> samplesIn, const al::span<FloatBufferLine> samplesOut) override;
|
||||
|
||||
DEF_NEWDEL(ReverbState)
|
||||
};
|
||||
@@ -1440,18 +1440,19 @@ void ReverbState::lateFaded(const size_t offset, const size_t todo, const ALfloa
|
||||
VectorScatterRevDelayIn(late_delay, offset, mixX, mixY, temps, todo);
|
||||
}
|
||||
|
||||
void ReverbState::process(const size_t samplesToDo, const FloatBufferLine *RESTRICT samplesIn, const ALsizei numInput, const al::span<FloatBufferLine> samplesOut)
|
||||
void ReverbState::process(const size_t samplesToDo, const al::span<const FloatBufferLine> samplesIn, const al::span<FloatBufferLine> samplesOut)
|
||||
{
|
||||
size_t offset{mOffset};
|
||||
|
||||
ASSUME(samplesToDo > 0);
|
||||
|
||||
/* Convert B-Format to A-Format for processing. */
|
||||
const size_t numInput{samplesIn.size()};
|
||||
const al::span<float> tmpspan{mTempLine.data(), samplesToDo};
|
||||
for(size_t c{0u};c < NUM_LINES;c++)
|
||||
{
|
||||
std::fill(tmpspan.begin(), tmpspan.end(), 0.0f);
|
||||
MixRowSamples(tmpspan, {B2A[c], B2A[c]+numInput}, samplesIn->data(), samplesIn->size());
|
||||
MixRowSamples(tmpspan, {B2A[c], numInput}, samplesIn[0].data(), samplesIn[0].size());
|
||||
|
||||
/* Band-pass the incoming samples and feed the initial delay line. */
|
||||
mFilter[c].Lp.process(mTempLine.data(), mTempLine.data(), samplesToDo);
|
||||
|
||||
+16
-15
@@ -137,7 +137,7 @@ struct VmorpherState final : public EffectState {
|
||||
|
||||
ALboolean deviceUpdate(const ALCdevice *device) override;
|
||||
void update(const ALCcontext *context, const ALeffectslot *slot, const EffectProps *props, const EffectTarget target) override;
|
||||
void process(const size_t samplesToDo, const FloatBufferLine *RESTRICT samplesIn, const ALsizei numInput, const al::span<FloatBufferLine> samplesOut) override;
|
||||
void process(const size_t samplesToDo, const al::span<const FloatBufferLine> samplesIn, const al::span<FloatBufferLine> samplesOut) override;
|
||||
|
||||
static std::array<FormantFilter,4> getFiltersByPhoneme(ALenum phoneme, ALfloat frequency, ALfloat pitch);
|
||||
|
||||
@@ -244,7 +244,7 @@ void VmorpherState::update(const ALCcontext *context, const ALeffectslot *slot,
|
||||
}
|
||||
}
|
||||
|
||||
void VmorpherState::process(const size_t samplesToDo, const FloatBufferLine *RESTRICT samplesIn, const ALsizei numInput, const al::span<FloatBufferLine> samplesOut)
|
||||
void VmorpherState::process(const size_t samplesToDo, const al::span<const FloatBufferLine> samplesIn, const al::span<FloatBufferLine> samplesOut)
|
||||
{
|
||||
/* Following the EFX specification for a conformant implementation which describes
|
||||
* the effect as a pair of 4-band formant filters blended together using an LFO.
|
||||
@@ -258,34 +258,35 @@ void VmorpherState::process(const size_t samplesToDo, const FloatBufferLine *RES
|
||||
mIndex += (mStep * td) & WAVEFORM_FRACMASK;
|
||||
mIndex &= WAVEFORM_FRACMASK;
|
||||
|
||||
ASSUME(numInput > 0);
|
||||
for(ALsizei c{0};c < numInput;c++)
|
||||
auto chandata = std::addressof(mChans[0]);
|
||||
for(const auto &input : samplesIn)
|
||||
{
|
||||
std::fill_n(std::begin(mSampleBufferA), td, 0.0f);
|
||||
std::fill_n(std::begin(mSampleBufferB), td, 0.0f);
|
||||
|
||||
auto& vowelA = mChans[c].Formants[VOWEL_A_INDEX];
|
||||
auto& vowelB = mChans[c].Formants[VOWEL_B_INDEX];
|
||||
auto& vowelA = chandata->Formants[VOWEL_A_INDEX];
|
||||
auto& vowelB = chandata->Formants[VOWEL_B_INDEX];
|
||||
|
||||
/* Process first vowel. */
|
||||
vowelA[0].process(&samplesIn[c][base], mSampleBufferA, td);
|
||||
vowelA[1].process(&samplesIn[c][base], mSampleBufferA, td);
|
||||
vowelA[2].process(&samplesIn[c][base], mSampleBufferA, td);
|
||||
vowelA[3].process(&samplesIn[c][base], mSampleBufferA, td);
|
||||
vowelA[0].process(&input[base], mSampleBufferA, td);
|
||||
vowelA[1].process(&input[base], mSampleBufferA, td);
|
||||
vowelA[2].process(&input[base], mSampleBufferA, td);
|
||||
vowelA[3].process(&input[base], mSampleBufferA, td);
|
||||
|
||||
/* Process second vowel. */
|
||||
vowelB[0].process(&samplesIn[c][base], mSampleBufferB, td);
|
||||
vowelB[1].process(&samplesIn[c][base], mSampleBufferB, td);
|
||||
vowelB[2].process(&samplesIn[c][base], mSampleBufferB, td);
|
||||
vowelB[3].process(&samplesIn[c][base], mSampleBufferB, td);
|
||||
vowelB[0].process(&input[base], mSampleBufferB, td);
|
||||
vowelB[1].process(&input[base], mSampleBufferB, td);
|
||||
vowelB[2].process(&input[base], mSampleBufferB, td);
|
||||
vowelB[3].process(&input[base], mSampleBufferB, td);
|
||||
|
||||
alignas(16) ALfloat blended[MAX_UPDATE_SAMPLES];
|
||||
for(size_t i{0u};i < td;i++)
|
||||
blended[i] = lerp(mSampleBufferA[i], mSampleBufferB[i], lfo[i]);
|
||||
|
||||
/* Now, mix the processed sound data to the output. */
|
||||
MixSamples({blended, td}, samplesOut, mChans[c].CurrentGains, mChans[c].TargetGains,
|
||||
MixSamples({blended, td}, samplesOut, chandata->CurrentGains, chandata->TargetGains,
|
||||
samplesToDo-base, base);
|
||||
++chandata;
|
||||
}
|
||||
|
||||
base += td;
|
||||
|
||||
Reference in New Issue
Block a user