diff options
author | Chris Robinson <[email protected]> | 2019-04-28 08:56:41 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2019-04-28 08:56:41 -0700 |
commit | 9d6619efdc35aad2d33878c28b13dc5e56b495a7 (patch) | |
tree | fa590f9de054107afb5265e32c3cf1dd8021156f /Alc/effects/reverb.cpp | |
parent | ec869234f7f69887ca02ea0982d18e8c5d3195d2 (diff) |
Combine some reverb processing loops
Specifically, the A2B and output mixing, as well as applying the band-pass with
B2A mixing (the latter of which hiding a bug that was overwriting the early
buffer storage).
Diffstat (limited to 'Alc/effects/reverb.cpp')
-rw-r--r-- | Alc/effects/reverb.cpp | 60 |
1 files changed, 31 insertions, 29 deletions
diff --git a/Alc/effects/reverb.cpp b/Alc/effects/reverb.cpp index c0a835fc..628f4349 100644 --- a/Alc/effects/reverb.cpp +++ b/Alc/effects/reverb.cpp @@ -90,15 +90,6 @@ alignas(16) constexpr ALfloat A2B[NUM_LINES][NUM_LINES]{ { 0.866025403785f, 0.866025403785f, -0.866025403785f, -0.866025403785f } }; -inline void ConvertA2B(ALfloat (&dst)[NUM_LINES][BUFFERSIZE], - const ALfloat (&src)[NUM_LINES][BUFFERSIZE], const ALsizei todo) -{ - for(ALsizei c{0};c < NUM_LINES;c++) - { - std::fill(std::begin(dst[c]), std::end(dst[c]), 0.0f); - MixRowSamples(dst[c], A2B[c], src, NUM_LINES, 0, todo); - } -} constexpr ALfloat FadeStep{1.0f / FADE_SAMPLES}; @@ -404,42 +395,55 @@ struct ReverbState final : public EffectState { void MixOutPlain(const ALsizei numOutput, ALfloat (*samplesOut)[BUFFERSIZE], const ALsizei todo) { + ASSUME(todo > 0); + /* Convert back to B-Format, and mix the results to output. */ - ConvertA2B(mTempSamples, mEarlyBuffer, todo); for(ALsizei c{0};c < NUM_LINES;c++) - MixSamples(mTempSamples[c], numOutput, samplesOut, mEarly.CurrentGain[c], + { + std::fill_n(std::begin(mTempSamples[0]), todo, 0.0f); + MixRowSamples(mTempSamples[0], A2B[c], mEarlyBuffer, NUM_LINES, 0, todo); + MixSamples(mTempSamples[0], numOutput, samplesOut, mEarly.CurrentGain[c], mEarly.PanGain[c], todo, 0, todo); + } - ConvertA2B(mTempSamples, mLateBuffer, todo); for(ALsizei c{0};c < NUM_LINES;c++) - MixSamples(mTempSamples[c], numOutput, samplesOut, mLate.CurrentGain[c], + { + std::fill_n(std::begin(mTempSamples[0]), todo, 0.0f); + MixRowSamples(mTempSamples[0], A2B[c], mLateBuffer, NUM_LINES, 0, todo); + MixSamples(mTempSamples[0], numOutput, samplesOut, mLate.CurrentGain[c], mLate.PanGain[c], todo, 0, todo); + } } void MixOutAmbiUp(const ALsizei numOutput, ALfloat (*samplesOut)[BUFFERSIZE], const ALsizei todo) { ASSUME(todo > 0); - ConvertA2B(mTempSamples, mEarlyBuffer, todo); + for(ALsizei c{0};c < NUM_LINES;c++) { + std::fill_n(std::begin(mTempSamples[0]), todo, 0.0f); + MixRowSamples(mTempSamples[0], A2B[c], mEarlyBuffer, NUM_LINES, 0, todo); + /* Apply scaling to the B-Format's HF response to "upsample" it to * higher-order output. */ const ALfloat hfscale{(c==0) ? mOrderScales[0] : mOrderScales[1]}; - mAmbiSplitter[0][c].applyHfScale(mTempSamples[c], hfscale, todo); + mAmbiSplitter[0][c].applyHfScale(mTempSamples[0], hfscale, todo); - MixSamples(mTempSamples[c], numOutput, samplesOut, mEarly.CurrentGain[c], + MixSamples(mTempSamples[0], numOutput, samplesOut, mEarly.CurrentGain[c], mEarly.PanGain[c], todo, 0, todo); } - ConvertA2B(mTempSamples, mLateBuffer, todo); for(ALsizei c{0};c < NUM_LINES;c++) { + std::fill_n(std::begin(mTempSamples[0]), todo, 0.0f); + MixRowSamples(mTempSamples[0], A2B[c], mLateBuffer, NUM_LINES, 0, todo); + const ALfloat hfscale{(c==0) ? mOrderScales[0] : mOrderScales[1]}; - mAmbiSplitter[1][c].applyHfScale(mTempSamples[c], hfscale, todo); + mAmbiSplitter[1][c].applyHfScale(mTempSamples[0], hfscale, todo); - MixSamples(mTempSamples[c], numOutput, samplesOut, mLate.CurrentGain[c], + MixSamples(mTempSamples[0], numOutput, samplesOut, mLate.CurrentGain[c], mLate.PanGain[c], todo, 0, todo); } } @@ -1382,8 +1386,12 @@ void ReverbState::process(ALsizei samplesToDo, const ALfloat (*RESTRICT samplesI ALfloat (&afmt)[NUM_LINES][BUFFERSIZE] = mTempSamples; for(ALsizei c{0};c < NUM_LINES;c++) { - std::fill(std::begin(afmt[c]), std::end(afmt[c]), 0.0f); + std::fill_n(std::begin(afmt[c]), samplesToDo, 0.0f); MixRowSamples(afmt[c], B2A[c], samplesIn, numInput, 0, samplesToDo); + + /* Band-pass the incoming samples. */ + mFilter[c].Lp.process(afmt[c], afmt[c], samplesToDo); + mFilter[c].Hp.process(afmt[c], afmt[c], samplesToDo); } /* Process reverb for these samples. */ @@ -1399,17 +1407,11 @@ void ReverbState::process(ALsizei samplesToDo, const ALfloat (*RESTRICT samplesI todo = mini(todo, mMaxUpdate[1]); ASSUME(todo > 0); - /* Process the samples for reverb. */ + /* Feed the initial delay line. */ for(ALsizei c{0};c < NUM_LINES;c++) - { - /* Band-pass the incoming samples. */ - mFilter[c].Lp.process(mEarlyBuffer[0], afmt[c]+base, todo); - mFilter[c].Hp.process(mEarlyBuffer[1], mEarlyBuffer[0], todo); - - /* Feed the initial delay line. */ - mDelay.write(offset, c, mEarlyBuffer[1], todo); - } + mDelay.write(offset, c, afmt[c]+base, todo); + /* Process the samples for reverb. */ if(UNLIKELY(fadeCount < FADE_SAMPLES)) { auto fade = static_cast<ALfloat>(fadeCount); |