diff options
author | Chris Robinson <[email protected]> | 2021-12-15 02:01:22 -0800 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2021-12-15 02:01:22 -0800 |
commit | 54c4bea48791f353baf66917f967ef3a39af9b0b (patch) | |
tree | 92ab9aad66fa8499cf338e22ce127c8db12d1cfa /core/voice.cpp | |
parent | b489705b25bb3967e04f7099cb21797783ccf7c0 (diff) |
Add source properties for Super Stereo
When playing a stereo format, enabling Super Stereo causes the source to behave
as a B-Format source, with a variable width control.
Diffstat (limited to 'core/voice.cpp')
-rw-r--r-- | core/voice.cpp | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/core/voice.cpp b/core/voice.cpp index 44ba897a..d93a4a18 100644 --- a/core/voice.cpp +++ b/core/voice.cpp @@ -814,6 +814,27 @@ void Voice::mix(const State vstate, ContextBase *Context, const uint SamplesToDo void Voice::prepare(DeviceBase *device) { + /* Even if storing really high order ambisonics, we only mix channels for + * orders up to MaxAmbiOrder. The rest are simply dropped. + */ + uint num_channels{(mFmtChannels == FmtUHJ2 || mFmtChannels == FmtSuperStereo) ? 3 : + ChannelsFromFmt(mFmtChannels, minu(mAmbiOrder, MaxAmbiOrder))}; + if(unlikely(num_channels > device->mSampleData.size())) + { + ERR("Unexpected channel count: %u (limit: %zu, %d:%d)\n", num_channels, + device->mSampleData.size(), mFmtChannels, mAmbiOrder); + num_channels = static_cast<uint>(device->mSampleData.size()); + } + if(mChans.capacity() > 2 && num_channels < mChans.capacity()) + { + decltype(mChans){}.swap(mChans); + decltype(mPrevSamples){}.swap(mPrevSamples); + } + mChans.reserve(maxu(2, num_channels)); + mChans.resize(num_channels); + mPrevSamples.reserve(maxu(2, num_channels)); + mPrevSamples.resize(num_channels); + if(IsUHJ(mFmtChannels)) { mDecoder = std::make_unique<UhjDecoder>(); |