diff options
Diffstat (limited to 'core')
-rw-r--r-- | core/buffer_storage.h | 7 | ||||
-rw-r--r-- | core/voice.cpp | 21 | ||||
-rw-r--r-- | core/voice.h | 1 |
3 files changed, 22 insertions, 7 deletions
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<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>(); 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<float,2> StereoPan; float Radius; + float EnhWidth; /** Direct filter and auxiliary send info. */ struct { |