From 54c4bea48791f353baf66917f967ef3a39af9b0b Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Wed, 15 Dec 2021 02:01:22 -0800 Subject: 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. --- core/buffer_storage.h | 7 ------- core/voice.cpp | 21 +++++++++++++++++++++ core/voice.h | 1 + 3 files changed, 22 insertions(+), 7 deletions(-) (limited to 'core') diff --git a/core/buffer_storage.h b/core/buffer_storage.h index cde7704e..ec934681 100644 --- a/core/buffer_storage.h +++ b/core/buffer_storage.h @@ -93,14 +93,7 @@ struct BufferStorage { { return ChannelsFromFmt(mChannels, mAmbiOrder); } inline uint frameSizeFromFmt() const noexcept { return channelsFromFmt() * bytesFromFmt(); } - inline uint mixerChannelsFromFmt() const noexcept - { - if(mChannels == FmtUHJ2 || mChannels == FmtSuperStereo) return 3; - return ChannelsFromFmt(mChannels, minu(mAmbiOrder, MaxAmbiOrder)); - } - inline bool isBFormat() const noexcept { return IsBFormat(mChannels); } - inline bool isUhj() const noexcept { return IsUHJ(mChannels); } }; #endif /* CORE_BUFFER_STORAGE_H */ 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(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(); diff --git a/core/voice.h b/core/voice.h index ba5e82cc..8866f8d4 100644 --- a/core/voice.h +++ b/core/voice.h @@ -138,6 +138,7 @@ struct VoiceProps { std::array StereoPan; float Radius; + float EnhWidth; /** Direct filter and auxiliary send info. */ struct { -- cgit v1.2.3