From bf3f63fb4c5faa45784d7433d68b7013e29ee2c1 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Wed, 31 Aug 2022 08:29:55 -0700 Subject: Don't apply the HF scaling for "upsampling" ambisonics Not sure if this is best, but it fixes the issue of upsampling lower orders to higher orders multiple times (mixing lower order to higher order, cutting back to lower order by dropping the extra channels, then upsampling again, applying the HF scale multiple times and messing up the high frequencies/energy vector), as well as having too-strong high frequencies of upsampled content in general. As it is, with the new upsampling method, the lower order signal contributes to some higher order channels, which helps offset the high frequency scaling difference (except first- to second-order, which adds nothing). --- alc/effects/reverb.cpp | 33 ++++----------------------------- 1 file changed, 4 insertions(+), 29 deletions(-) (limited to 'alc/effects/reverb.cpp') diff --git a/alc/effects/reverb.cpp b/alc/effects/reverb.cpp index ea3367d0..72f58db5 100644 --- a/alc/effects/reverb.cpp +++ b/alc/effects/reverb.cpp @@ -453,8 +453,6 @@ struct ReverbState final : public EffectState { bool mUpmixOutput{false}; - std::array mOrderScales{}; - std::array,2> mAmbiSplitter; static void DoMixRow(const al::span OutBuffer, const al::span Gains, @@ -501,30 +499,19 @@ struct ReverbState final : public EffectState { { ASSUME(todo > 0); - /* When upsampling, the B-Format conversion needs to be done separately - * so the proper HF scaling can be applied to each B-Format channel. - * The panning gains then pan and upsample the B-Format channels. + /* TODO: If HF scaling isn't needed for upsampling, the A-to-B-Format + * matrix can be included with the panning gains like non-upsampled + * output. */ const al::span tmpspan{al::assume_aligned<16>(mTempLine.data()), todo}; for(size_t c{0u};c < NUM_LINES;c++) { DoMixRow(tmpspan, EarlyA2B[c], mEarlySamples[0].data(), mEarlySamples[0].size()); - - /* Apply scaling to the B-Format's HF response to "upsample" it to - * higher-order output. - */ - const float hfscale{(c==0) ? mOrderScales[0] : mOrderScales[1]}; - mAmbiSplitter[0][c].processHfScale(tmpspan, hfscale); - MixSamples(tmpspan, samplesOut, mEarly.CurrentGain[c], mEarly.PanGain[c], todo, 0); } for(size_t c{0u};c < NUM_LINES;c++) { DoMixRow(tmpspan, LateA2B[c], mLateSamples[0].data(), mLateSamples[0].size()); - - const float hfscale{(c==0) ? mOrderScales[0] : mOrderScales[1]}; - mAmbiSplitter[1][c].processHfScale(tmpspan, hfscale); - MixSamples(tmpspan, samplesOut, mLate.CurrentGain[c], mLate.PanGain[c], todo, 0); } } @@ -683,19 +670,7 @@ void ReverbState::deviceUpdate(const DeviceBase *device, const Buffer&) mDoFading = true; mOffset = 0; - if(device->mAmbiOrder > 1) - { - mUpmixOutput = true; - mOrderScales = AmbiScale::GetHFOrderScales(1, true); - } - else - { - mUpmixOutput = false; - mOrderScales.fill(1.0f); - } - mAmbiSplitter[0][0].init(device->mXOverFreq / frequency); - std::fill(mAmbiSplitter[0].begin()+1, mAmbiSplitter[0].end(), mAmbiSplitter[0][0]); - std::fill(mAmbiSplitter[1].begin(), mAmbiSplitter[1].end(), mAmbiSplitter[0][0]); + mUpmixOutput = (device->mAmbiOrder > 1); } /************************************** -- cgit v1.2.3