diff options
author | Chris Robinson <[email protected]> | 2022-09-11 21:07:47 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2022-09-11 21:07:47 -0700 |
commit | 583bd0e47c0d3c579c9e5b716e112cc4ab5c6960 (patch) | |
tree | 9670e6b9023aef1822fa024290b97de750f2e999 | |
parent | f73f6e61b7d9649ffe286dca915f7f4eab453309 (diff) |
Ensure coeff_scale is set for ambdec files
-rw-r--r-- | alc/panning.cpp | 1 | ||||
-rw-r--r-- | core/ambdec.cpp | 15 | ||||
-rw-r--r-- | core/ambdec.h | 3 |
3 files changed, 13 insertions, 6 deletions
diff --git a/alc/panning.cpp b/alc/panning.cpp index 678a2639..6826b539 100644 --- a/alc/panning.cpp +++ b/alc/panning.cpp @@ -338,6 +338,7 @@ DecoderView MakeDecoderView(ALCdevice *device, const AmbDecConf *conf, switch(conf->CoeffScale) { + case AmbDecScale::Unset: ASSUME(0); break; case AmbDecScale::N3D: decoder.mScaling = DevAmbiScaling::N3D; break; case AmbDecScale::SN3D: decoder.mScaling = DevAmbiScaling::SN3D; break; case AmbDecScale::FuMa: decoder.mScaling = DevAmbiScaling::FuMa; break; diff --git a/core/ambdec.cpp b/core/ambdec.cpp index e40b3868..31eaf391 100644 --- a/core/ambdec.cpp +++ b/core/ambdec.cpp @@ -220,8 +220,6 @@ al::optional<std::string> AmbDecConf::load(const char *fname) noexcept if(!ChanMask) return al::make_optional("Invalid chan_mask: "+std::to_string(ChanMask)); - if(ChanMask > Ambi3OrderMask && CoeffScale == AmbDecScale::FuMa) - return al::make_optional<std::string>("FuMa not compatible with over third-order"); } else if(command == "/dec/freq_bands") { @@ -252,15 +250,15 @@ al::optional<std::string> AmbDecConf::load(const char *fname) noexcept } else if(command == "/dec/coeff_scale") { + if(CoeffScale != AmbDecScale::Unset) + return al::make_optional<std::string>("Duplicate coeff_scale"); + std::string scale = read_word(istr); if(scale == "n3d") CoeffScale = AmbDecScale::N3D; else if(scale == "sn3d") CoeffScale = AmbDecScale::SN3D; else if(scale == "fuma") CoeffScale = AmbDecScale::FuMa; else return al::make_optional("Unexpected coeff_scale: "+scale); - - if(ChanMask > Ambi3OrderMask && CoeffScale == AmbDecScale::FuMa) - return al::make_optional<std::string>("FuMa not compatible with over third-order"); } else if(command == "/opt/xover_freq") { @@ -362,8 +360,15 @@ al::optional<std::string> AmbDecConf::load(const char *fname) noexcept if(!is_at_end(buffer, endpos)) return al::make_optional("Extra junk on end: " + buffer.substr(endpos)); + if(ChanMask == 0) + return al::make_optional<std::string>("No channel mask defined"); if(!speakers_loaded || !matrix_loaded || (FreqBands == 2 && !lfmatrix_loaded)) return al::make_optional<std::string>("No decoder defined"); + if(CoeffScale == AmbDecScale::Unset) + return al::make_optional<std::string>("No coefficient scaling defined"); + + if(ChanMask > Ambi3OrderMask && CoeffScale == AmbDecScale::FuMa) + return al::make_optional<std::string>("FuMa not compatible with over third-order"); return al::nullopt; } diff --git a/core/ambdec.h b/core/ambdec.h index e1bcde26..7f739781 100644 --- a/core/ambdec.h +++ b/core/ambdec.h @@ -11,6 +11,7 @@ /* Helpers to read .ambdec configuration files. */ enum class AmbDecScale { + Unset, N3D, SN3D, FuMa, @@ -21,7 +22,7 @@ struct AmbDecConf { unsigned int ChanMask{0u}; unsigned int FreqBands{0u}; /* Must be 1 or 2 */ - AmbDecScale CoeffScale{}; + AmbDecScale CoeffScale{AmbDecScale::Unset}; float XOverFreq{0.0f}; float XOverRatio{0.0f}; |