diff options
author | Chris Robinson <[email protected]> | 2022-08-31 08:29:55 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2022-08-31 09:06:53 -0700 |
commit | bf3f63fb4c5faa45784d7433d68b7013e29ee2c1 (patch) | |
tree | 14067933535ae809ab42c62e8c53d993df756fc7 /alc | |
parent | 042c3d4a4241d03f7a2368d8744f93a3a4fb7565 (diff) |
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).
Diffstat (limited to 'alc')
-rw-r--r-- | alc/effects/convolution.cpp | 13 | ||||
-rw-r--r-- | alc/effects/reverb.cpp | 33 |
2 files changed, 4 insertions, 42 deletions
diff --git a/alc/effects/convolution.cpp b/alc/effects/convolution.cpp index 90220a50..f72695bd 100644 --- a/alc/effects/convolution.cpp +++ b/alc/effects/convolution.cpp @@ -194,8 +194,6 @@ struct ConvolutionState final : public EffectState { struct ChannelData { alignas(16) FloatBufferLine mBuffer{}; - float mHfScale{}; - BandSplitter mFilter{}; float Current[MAX_OUTPUT_CHANNELS]{}; float Target[MAX_OUTPUT_CHANNELS]{}; }; @@ -235,7 +233,6 @@ void ConvolutionState::UpsampleMix(const al::span<FloatBufferLine> samplesOut, for(auto &chan : *mChans) { const al::span<float> src{chan.mBuffer.data(), samplesToDo}; - chan.mFilter.processHfScale(src, chan.mHfScale); MixSamples(src, samplesOut, chan.Current, chan.Target, samplesToDo, 0); } } @@ -280,10 +277,6 @@ void ConvolutionState::deviceUpdate(const DeviceBase *device, const Buffer &buff (uint64_t{buffer.storage->mSampleLen}*device->Frequency+(buffer.storage->mSampleRate-1)) / buffer.storage->mSampleRate); - const BandSplitter splitter{device->mXOverFreq / static_cast<float>(device->Frequency)}; - for(auto &e : *mChans) - e.mFilter = splitter; - mFilter.resize(numChannels, {}); mOutput.resize(numChannels, {}); @@ -418,13 +411,7 @@ void ConvolutionState::update(const ContextBase *context, const EffectSlot *slot { DeviceBase *device{context->mDevice}; if(device->mAmbiOrder > mAmbiOrder) - { mMix = &ConvolutionState::UpsampleMix; - const auto scales = AmbiScale::GetHFOrderScales(mAmbiOrder, true); - (*mChans)[0].mHfScale = scales[0]; - for(size_t i{1};i < mChans->size();++i) - (*mChans)[i].mHfScale = scales[1]; - } mOutTarget = target.Main->Buffer; auto&& scales = GetAmbiScales(mAmbiScaling); 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<float,MaxAmbiOrder+1> mOrderScales{}; - std::array<std::array<BandSplitter,NUM_LINES>,2> mAmbiSplitter; static void DoMixRow(const al::span<float> OutBuffer, const al::span<const float,4> 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<float> 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); } /************************************** |