diff options
Diffstat (limited to 'OpenAL32')
-rw-r--r-- | OpenAL32/Include/alu.h | 38 | ||||
-rw-r--r-- | OpenAL32/alSource.cpp | 40 |
2 files changed, 37 insertions, 41 deletions
diff --git a/OpenAL32/Include/alu.h b/OpenAL32/Include/alu.h index cb0b675c..25a1d422 100644 --- a/OpenAL32/Include/alu.h +++ b/OpenAL32/Include/alu.h @@ -253,39 +253,33 @@ struct ALvoice { ALuint mFlags; - struct ResampleData { - alignas(16) std::array<ALfloat,MAX_RESAMPLE_PADDING*2> mPrevSamples; - - ALfloat mAmbiScale; - BandSplitter mAmbiSplitter; - }; - std::array<ResampleData,MAX_INPUT_CHANNELS> mResampleData; - - struct { + struct DirectData { int FilterType; - DirectParams Params[MAX_INPUT_CHANNELS]; - al::span<FloatBufferLine> Buffer; ALsizei ChannelsPerOrder[MAX_AMBI_ORDER+1]; - } mDirect; + }; + DirectData mDirect; struct SendData { int FilterType; - SendParams Params[MAX_INPUT_CHANNELS]; - al::span<FloatBufferLine> Buffer; }; - al::FlexArray<SendData> mSend; + std::array<SendData,MAX_SENDS> mSend; + + struct ChannelData { + alignas(16) std::array<ALfloat,MAX_RESAMPLE_PADDING*2> mPrevSamples; - ALvoice(size_t numsends) : mSend{numsends} { } + ALfloat mAmbiScale; + BandSplitter mAmbiSplitter; + + DirectParams mDryParams; + std::array<SendParams,MAX_SENDS> mWetParams; + }; + std::array<ChannelData,MAX_INPUT_CHANNELS> mChans; + + ALvoice() = default; ALvoice(const ALvoice&) = delete; ALvoice& operator=(const ALvoice&) = delete; - - static constexpr size_t Sizeof(size_t numsends) noexcept - { - return maxz(sizeof(ALvoice), - al::FlexArray<SendData>::Sizeof(numsends, offsetof(ALvoice, mSend))); - } }; void DeinitVoice(ALvoice *voice) noexcept; diff --git a/OpenAL32/alSource.cpp b/OpenAL32/alSource.cpp index 02396fd0..d2414e50 100644 --- a/OpenAL32/alSource.cpp +++ b/OpenAL32/alSource.cpp @@ -2938,40 +2938,42 @@ START_API_FUNC BandSplitter splitter{400.0f / static_cast<ALfloat>(device->Frequency)}; const auto scales = BFormatDec::GetHFOrderScales(1, device->mAmbiOrder); - auto init_ambi = [scales,&OrderFromChan,&splitter](ALvoice::ResampleData &resdata) -> void + auto init_ambi = [scales,&OrderFromChan,&splitter](ALvoice::ChannelData &chandata) -> void { - resdata.mPrevSamples.fill(0.0f); - resdata.mAmbiScale = scales[*(OrderFromChan++)]; - resdata.mAmbiSplitter = splitter; + chandata.mPrevSamples.fill(0.0f); + chandata.mAmbiScale = scales[*(OrderFromChan++)]; + chandata.mAmbiSplitter = splitter; }; - std::for_each(voice->mResampleData.begin(), - voice->mResampleData.begin()+voice->mNumChannels, init_ambi); + std::for_each(voice->mChans.begin(), voice->mChans.begin()+voice->mNumChannels, + init_ambi); voice->mFlags |= VOICE_IS_AMBISONIC; } else { /* Clear previous samples. */ - auto clear_prevs = [](ALvoice::ResampleData &resdata) -> void - { resdata.mPrevSamples.fill(0.0f); }; - std::for_each(voice->mResampleData.begin(), - voice->mResampleData.begin()+voice->mNumChannels, clear_prevs); + auto clear_prevs = [](ALvoice::ChannelData &chandata) -> void + { chandata.mPrevSamples.fill(0.0f); }; + std::for_each(voice->mChans.begin(), voice->mChans.begin()+voice->mNumChannels, + clear_prevs); } - std::fill_n(std::begin(voice->mDirect.Params), voice->mNumChannels, DirectParams{}); - std::for_each(voice->mSend.begin(), voice->mSend.end(), - [voice](ALvoice::SendData &send) -> void - { std::fill_n(std::begin(send.Params), voice->mNumChannels, SendParams{}); } - ); + auto clear_params = [device](ALvoice::ChannelData &chandata) -> void + { + chandata.mDryParams = DirectParams{}; + std::fill_n(chandata.mWetParams.begin(), device->NumAuxSends, SendParams{}); + }; + std::for_each(voice->mChans.begin(), voice->mChans.begin()+voice->mNumChannels, + clear_params); if(device->AvgSpeakerDist > 0.0f) { const ALfloat w1{SPEEDOFSOUNDMETRESPERSEC / (device->AvgSpeakerDist * device->Frequency)}; - std::for_each(voice->mDirect.Params+0, voice->mDirect.Params+voice->mNumChannels, - [w1](DirectParams &parms) noexcept -> void - { parms.NFCtrlFilter.init(w1); } - ); + auto init_nfc = [w1](ALvoice::ChannelData &chandata) -> void + { chandata.mDryParams.NFCtrlFilter.init(w1); }; + std::for_each(voice->mChans.begin(), voice->mChans.begin()+voice->mNumChannels, + init_nfc); } voice->mSourceID.store(source->id, std::memory_order_relaxed); |