diff options
-rw-r--r-- | al/source.cpp | 8 | ||||
-rw-r--r-- | alc/alu.cpp | 36 | ||||
-rw-r--r-- | alc/voice.h | 9 |
3 files changed, 38 insertions, 15 deletions
diff --git a/al/source.cpp b/al/source.cpp index 04fd3b66..11049eab 100644 --- a/al/source.cpp +++ b/al/source.cpp @@ -2788,9 +2788,11 @@ START_API_FUNC ALbuffer *buffer{BufferList->mBuffer}; voice->mFrequency = buffer->Frequency; voice->mFmtChannels = buffer->mFmtChannels; - voice->mAmbiOrder = 1; voice->mNumChannels = ChannelsFromFmt(buffer->mFmtChannels); voice->mSampleSize = BytesFromFmt(buffer->mFmtType); + voice->mAmbiLayout = static_cast<AmbiLayout>(buffer->AmbiLayout); + voice->mAmbiScaling = static_cast<AmbiNorm>(buffer->AmbiScaling); + voice->mAmbiOrder = 1; /* Clear the stepping value so the mixer knows not to mix this until * the update gets applied. @@ -3136,6 +3138,10 @@ START_API_FUNC BufferFmt = buffer; else if(BufferFmt->Frequency != buffer->Frequency || BufferFmt->mFmtChannels != buffer->mFmtChannels || + ((BufferFmt->mFmtChannels == FmtBFormat2D || + BufferFmt->mFmtChannels == FmtBFormat3D) && + (BufferFmt->AmbiLayout != buffer->AmbiLayout || + BufferFmt->AmbiScaling != buffer->AmbiScaling)) || BufferFmt->OriginalType != buffer->OriginalType) { context->setError(AL_INVALID_OPERATION, "Queueing buffer with mismatched format"); diff --git a/alc/alu.cpp b/alc/alu.cpp index 2d9826d4..bec01164 100644 --- a/alc/alu.cpp +++ b/alc/alu.cpp @@ -337,6 +337,26 @@ inline ALuint dither_rng(ALuint *seed) noexcept } +auto GetAmbiScales(AmbiNorm scaletype) noexcept -> const std::array<float,MAX_AMBI_CHANNELS>& +{ + if(scaletype == AmbiNorm::FuMa) return AmbiScale::FromFuMa; + if(scaletype == AmbiNorm::SN3D) return AmbiScale::FromSN3D; + return AmbiScale::FromN3D; +} + +auto GetAmbiLayout(AmbiLayout layouttype) noexcept -> const std::array<uint8_t,MAX_AMBI_CHANNELS>& +{ + if(layouttype == AmbiLayout::FuMa) return AmbiIndex::FromFuMa; + return AmbiIndex::FromACN; +} + +auto GetAmbi2DLayout(AmbiLayout layouttype) noexcept -> const std::array<uint8_t,MAX_AMBI2D_CHANNELS>& +{ + if(layouttype == AmbiLayout::FuMa) return AmbiIndex::FromFuMa2D; + return AmbiIndex::From2D; +} + + inline alu::Vector aluCrossproduct(const alu::Vector &in1, const alu::Vector &in2) { return alu::Vector{ @@ -875,18 +895,10 @@ void CalcPanningAndFilters(ALvoice *voice, const ALfloat xpos, const ALfloat ypo /* Convert the rotation matrix for FuMa input ordering and scaling, * and whether input is 2D or 3D. */ - const uint8_t *index_map{}; - const float *scales{}; - if(voice->mFmtChannels == FmtBFormat2D) - { - index_map = AmbiIndex::FromFuMa2D.data(); - scales = AmbiScale::FromFuMa.data(); - } - else - { - index_map = AmbiIndex::FromFuMa.data(); - scales = AmbiScale::FromFuMa.data(); - } + const uint8_t *index_map{(voice->mFmtChannels == FmtBFormat2D) ? + GetAmbi2DLayout(voice->mAmbiLayout).data() : + GetAmbiLayout(voice->mAmbiLayout).data()}; + const float *scales{GetAmbiScales(voice->mAmbiScaling).data()}; static const uint8_t OrderFromChan[MAX_AMBI_CHANNELS]{ 0, 1,1,1, 2,2,2,2,2, 3,3,3,3,3,3,3, diff --git a/alc/voice.h b/alc/voice.h index af2b5dba..67678cd9 100644 --- a/alc/voice.h +++ b/alc/voice.h @@ -9,6 +9,7 @@ #include "al/buffer.h" #include "alspan.h" #include "alu.h" +#include "devformat.h" #include "filters/biquad.h" #include "filters/nfc.h" #include "filters/splitter.h" @@ -211,10 +212,12 @@ struct ALvoice { /* Properties for the attached buffer(s). */ FmtChannels mFmtChannels; - ALuint mAmbiOrder; ALuint mFrequency; ALuint mNumChannels; ALuint mSampleSize; + AmbiLayout mAmbiLayout; + AmbiNorm mAmbiScaling; + ALuint mAmbiOrder; /** Current target parameters used for mixing. */ ALuint mStep; @@ -270,10 +273,12 @@ struct ALvoice { std::memory_order_relaxed); mFmtChannels = rhs.mFmtChannels; - mAmbiOrder = rhs.mAmbiOrder; mFrequency = rhs.mFrequency; mNumChannels = rhs.mNumChannels; mSampleSize = rhs.mSampleSize; + mAmbiLayout = rhs.mAmbiLayout; + mAmbiScaling = rhs.mAmbiScaling; + mAmbiOrder = rhs.mAmbiOrder; mStep = rhs.mStep; mResampler = rhs.mResampler; |