aboutsummaryrefslogtreecommitdiffstats
path: root/alc
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2019-12-02 12:50:18 -0800
committerChris Robinson <[email protected]>2019-12-02 12:50:18 -0800
commit38037e29ba2ac9e452f2704e3722f745f0664a8c (patch)
tree4bbbc107e192774564a5e9d8e0c10b704b8f1b4e /alc
parent799c60f3bbf041c5eafeb6b3acb7fc5d3f395718 (diff)
Handle the buffer's ambisonic properties
Diffstat (limited to 'alc')
-rw-r--r--alc/alu.cpp36
-rw-r--r--alc/voice.h9
2 files changed, 31 insertions, 14 deletions
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;