diff options
author | Chris Robinson <[email protected]> | 2018-12-10 22:32:10 -0800 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2018-12-10 22:35:32 -0800 |
commit | 0d36ba0fbbed583e5f5fbe0a99fa0fd60773e2e0 (patch) | |
tree | ccece6d3fb7130026316134bdc60b1f0d38ba63f /Alc | |
parent | e87eb07db411a0ecd02b5b5c50a4a721150e846e (diff) |
Use helpers to get the Ambisonic scales and layout maps
Diffstat (limited to 'Alc')
-rw-r--r-- | Alc/bformatdec.cpp | 12 | ||||
-rw-r--r-- | Alc/panning.cpp | 34 |
2 files changed, 32 insertions, 14 deletions
diff --git a/Alc/bformatdec.cpp b/Alc/bformatdec.cpp index 8b12149a..888c7cab 100644 --- a/Alc/bformatdec.cpp +++ b/Alc/bformatdec.cpp @@ -69,6 +69,13 @@ ALsizei GetACNIndex(const BFChannelConfig *chans, ALsizei numchans, ALsizei acn) } #define GetChannelForACN(b, a) GetACNIndex((b).Ambi.Map, (b).NumChannels, (a)) +auto GetAmbiScales(AmbDecScale scaletype) noexcept -> decltype(AmbiScale::N3D2N3D)& +{ + if(scaletype == AmbDecScale::FuMa) return AmbiScale::FuMa2N3D; + if(scaletype == AmbDecScale::SN3D) return AmbiScale::SN3D2N3D; + return AmbiScale::N3D2N3D; +} + } // namespace @@ -122,10 +129,7 @@ void BFormatDec::reset(const AmbDecConf *conf, ALsizei chancount, ALuint srate, mUpSampler[3].Gains[LF_BAND] = 0.0f; } - const ALfloat (&coeff_scale)[MAX_AMBI_COEFFS] = - (conf->CoeffScale == AmbDecScale::FuMa) ? AmbiScale::FuMa2N3D : - (conf->CoeffScale == AmbDecScale::SN3D) ? AmbiScale::SN3D2N3D : - /*(conf->CoeffScale == AmbDecScale::N3D) ?*/ AmbiScale::N3D2N3D; + const ALfloat (&coeff_scale)[MAX_AMBI_COEFFS] = GetAmbiScales(conf->CoeffScale); mMatrix = MatrixU{}; if(conf->FreqBands == 1) diff --git a/Alc/panning.cpp b/Alc/panning.cpp index 2d42106b..6a510e7b 100644 --- a/Alc/panning.cpp +++ b/Alc/panning.cpp @@ -342,6 +342,27 @@ void InitDistanceComp(ALCdevice *device, const AmbDecConf *conf, const ALsizei ( } } +auto GetAmbiScales(AmbDecScale scaletype) noexcept -> const float(&)[MAX_AMBI_COEFFS] +{ + if(scaletype == AmbDecScale::FuMa) return AmbiScale::FuMa2N3D; + if(scaletype == AmbDecScale::SN3D) return AmbiScale::SN3D2N3D; + return AmbiScale::N3D2N3D; +} + +auto GetAmbiScales(AmbiNorm scaletype) noexcept -> const float(&)[MAX_AMBI_COEFFS] +{ + if(scaletype == AmbiNorm::FuMa) return AmbiScale::FuMa2N3D; + if(scaletype == AmbiNorm::SN3D) return AmbiScale::SN3D2N3D; + return AmbiScale::N3D2N3D; +} + +auto GetAmbiLayout(AmbiLayout layouttype) noexcept -> const ALsizei(&)[MAX_AMBI_COEFFS] +{ + if(layouttype == AmbiLayout::FuMa) return FuMa2ACN; + return ACN2ACN; +} + + void InitPanning(ALCdevice *device) { const ChannelMap *chanmap = NULL; @@ -400,12 +421,8 @@ void InitPanning(ALCdevice *device) if(device->FmtChans == DevFmtAmbi3D) { const char *devname{device->DeviceName.c_str()}; - const ALsizei (&acnmap)[MAX_AMBI_COEFFS] = - (device->mAmbiLayout == AmbiLayout::FuMa) ? FuMa2ACN : ACN2ACN; - const ALfloat (&n3dscale)[MAX_AMBI_COEFFS] = - (device->mAmbiScale == AmbiNorm::FuMa) ? AmbiScale::FuMa2N3D : - (device->mAmbiScale == AmbiNorm::SN3D) ? AmbiScale::SN3D2N3D : - /*(device->mAmbiScale == AmbiNorm::N3D) ?*/ AmbiScale::N3D2N3D; + const ALsizei (&acnmap)[MAX_AMBI_COEFFS] = GetAmbiLayout(device->mAmbiLayout); + const ALfloat (&n3dscale)[MAX_AMBI_COEFFS] = GetAmbiScales(device->mAmbiScale); count = (device->mAmbiOrder == 3) ? 16 : (device->mAmbiOrder == 2) ? 9 : @@ -520,10 +537,7 @@ void InitCustomPanning(ALCdevice *device, const AmbDecConf *conf, const ALsizei } } - const ALfloat (&coeff_scale)[MAX_AMBI_COEFFS] = - (conf->CoeffScale == AmbDecScale::FuMa) ? AmbiScale::FuMa2N3D : - (conf->CoeffScale == AmbDecScale::SN3D) ? AmbiScale::SN3D2N3D : - /*(conf->CoeffScale == AmbDecScale::N3D) ?*/ AmbiScale::N3D2N3D; + const ALfloat (&coeff_scale)[MAX_AMBI_COEFFS] = GetAmbiScales(conf->CoeffScale); ChannelMap chanmap[MAX_OUTPUT_CHANNELS]{}; for(ALsizei i{0};i < conf->NumSpeakers;i++) { |