diff options
author | Chris Robinson <[email protected]> | 2023-01-01 19:14:05 -0800 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2023-01-01 19:14:05 -0800 |
commit | b959aa9ee667730c61e973ce42bc8fb6afe2cf22 (patch) | |
tree | 34231ca141234ed164250ca601521926f90c5644 /core/voice.cpp | |
parent | 073f970788a35657537da1b1dc7c4af450888698 (diff) |
Swap the order of some checks to simplify voice setup
Diffstat (limited to 'core/voice.cpp')
-rw-r--r-- | core/voice.cpp | 60 |
1 files changed, 25 insertions, 35 deletions
diff --git a/core/voice.cpp b/core/voice.cpp index eab8f851..9add9797 100644 --- a/core/voice.cpp +++ b/core/voice.cpp @@ -945,26 +945,8 @@ void Voice::prepare(DeviceBase *device) /* Make sure the sample history is cleared. */ std::fill(mPrevSamples.begin(), mPrevSamples.end(), HistoryLine{}); - /* Don't need to set the VoiceIsAmbisonic flag if the device is not higher - * order than the voice. No HF scaling is necessary to mix it. - */ - if(mAmbiOrder && device->mAmbiOrder > mAmbiOrder) + if(mFmtChannels == FmtUHJ2 && !device->mUhjEncoder) { - const uint8_t *OrderFromChan{Is2DAmbisonic(mFmtChannels) ? - AmbiIndex::OrderFrom2DChannel().data() : AmbiIndex::OrderFromChannel().data()}; - const auto scales = AmbiScale::GetHFOrderScales(mAmbiOrder, device->mAmbiOrder, - device->m2DMixing); - - const BandSplitter splitter{device->mXOverFreq / static_cast<float>(device->Frequency)}; - for(auto &chandata : mChans) - { - chandata.mAmbiHFScale = scales[*(OrderFromChan++)]; - chandata.mAmbiLFScale = 1.0f; - chandata.mAmbiSplitter = splitter; - chandata.mDryParams = DirectParams{}; - chandata.mDryParams.NFCtrlFilter = device->mNFCtrlFilter; - std::fill_n(chandata.mWetParams.begin(), device->NumAuxSends, SendParams{}); - } /* 2-channel UHJ needs different shelf filters. However, we can't just * use different shelf filters after mixing it, given any old speaker * setup the user has. To make this work, we apply the expected shelf @@ -974,22 +956,8 @@ void Voice::prepare(DeviceBase *device) * * This isn't perfect, but without an entirely separate and limited * UHJ2 path, it's better than nothing. - */ - if(mFmtChannels == FmtUHJ2) - { - mChans[0].mAmbiHFScale = 1.0f; - mChans[0].mAmbiLFScale = DecoderBase::sWLFScale; - mChans[1].mAmbiHFScale = 1.0f; - mChans[1].mAmbiLFScale = DecoderBase::sXYLFScale; - mChans[2].mAmbiHFScale = 1.0f; - mChans[2].mAmbiLFScale = DecoderBase::sXYLFScale; - } - mFlags.set(VoiceIsAmbisonic); - } - else if(mFmtChannels == FmtUHJ2 && !device->mUhjEncoder) - { - /* 2-channel UHJ with first-order output also needs the shelf filter - * correction applied, except with UHJ output (UHJ2->B-Format->UHJ2 is + * + * Note this isn't needed with UHJ output (UHJ2->B-Format->UHJ2 is * identity, so don't mess with it). */ const BandSplitter splitter{device->mXOverFreq / static_cast<float>(device->Frequency)}; @@ -1007,6 +975,28 @@ void Voice::prepare(DeviceBase *device) mChans[2].mAmbiLFScale = DecoderBase::sXYLFScale; mFlags.set(VoiceIsAmbisonic); } + /* Don't need to set the VoiceIsAmbisonic flag if the device is not higher + * order than the voice. No HF scaling is necessary to mix it. + */ + else if(mAmbiOrder && device->mAmbiOrder > mAmbiOrder) + { + const uint8_t *OrderFromChan{Is2DAmbisonic(mFmtChannels) ? + AmbiIndex::OrderFrom2DChannel().data() : AmbiIndex::OrderFromChannel().data()}; + const auto scales = AmbiScale::GetHFOrderScales(mAmbiOrder, device->mAmbiOrder, + device->m2DMixing); + + const BandSplitter splitter{device->mXOverFreq / static_cast<float>(device->Frequency)}; + for(auto &chandata : mChans) + { + chandata.mAmbiHFScale = scales[*(OrderFromChan++)]; + chandata.mAmbiLFScale = 1.0f; + chandata.mAmbiSplitter = splitter; + chandata.mDryParams = DirectParams{}; + chandata.mDryParams.NFCtrlFilter = device->mNFCtrlFilter; + std::fill_n(chandata.mWetParams.begin(), device->NumAuxSends, SendParams{}); + } + mFlags.set(VoiceIsAmbisonic); + } else { for(auto &chandata : mChans) |