diff options
-rw-r--r-- | alc/alc.cpp | 20 | ||||
-rw-r--r-- | alc/alu.cpp | 8 | ||||
-rw-r--r-- | alc/alu.h | 2 | ||||
-rw-r--r-- | alsoftrc.sample | 8 | ||||
-rw-r--r-- | docs/env-vars.txt | 9 |
5 files changed, 36 insertions, 11 deletions
diff --git a/alc/alc.cpp b/alc/alc.cpp index 4ba47aea..7300db0c 100644 --- a/alc/alc.cpp +++ b/alc/alc.cpp @@ -1121,14 +1121,20 @@ void alc_initconfig(void) AllowRTTimeLimit = *limopt; CompatFlagBitset compatflags{}; - if(auto optval = al::getenv("__ALSOFT_REVERSE_Z")) + auto checkflag = [](const char *envname, const char *optname) -> bool { - if(al::strcasecmp(optval->c_str(), "true") == 0 - || strtol(optval->c_str(), nullptr, 0) == 1) - compatflags.set(CompatFlags::ReverseZ); - } - else if(GetConfigValueBool(nullptr, "game_compat", "reverse-z", false)) - compatflags.set(CompatFlags::ReverseZ); + if(auto optval = al::getenv(envname)) + { + if(al::strcasecmp(optval->c_str(), "true") == 0 + || strtol(optval->c_str(), nullptr, 0) == 1) + return true; + return false; + } + return GetConfigValueBool(nullptr, "game_compat", optname, false); + }; + compatflags.set(CompatFlags::ReverseX, checkflag("__ALSOFT_REVERSE_X", "reverse-x")); + compatflags.set(CompatFlags::ReverseY, checkflag("__ALSOFT_REVERSE_Y", "reverse-y")); + compatflags.set(CompatFlags::ReverseZ, checkflag("__ALSOFT_REVERSE_Z", "reverse-z")); aluInit(compatflags); Voice::InitMixer(ConfigValueStr(nullptr, nullptr, "resampler")); diff --git a/alc/alu.cpp b/alc/alu.cpp index 203fd9b6..557b072d 100644 --- a/alc/alu.cpp +++ b/alc/alu.cpp @@ -128,9 +128,11 @@ float InitConeScale() /* Cone scalar */ const float ConeScale{InitConeScale()}; -/* Localized Z scalar for mono sources (initialized in aluInit, after +/* Localized scalars for mono sources (initialized in aluInit, after * configuration is loaded). */ +float XScale{1.0f}; +float YScale{1.0f}; float ZScale{1.0f}; } // namespace @@ -245,6 +247,8 @@ inline ResamplerFunc SelectResampler(Resampler resampler, uint increment) void aluInit(CompatFlagBitset flags) { MixDirectHrtf = SelectHrtfMixer(); + XScale = flags.test(CompatFlags::ReverseX) ? -1.0f : 1.0f; + YScale = flags.test(CompatFlags::ReverseY) ? -1.0f : 1.0f; ZScale = flags.test(CompatFlags::ReverseZ) ? -1.0f : 1.0f; } @@ -1516,7 +1520,7 @@ void CalcAttnSourceParams(Voice *voice, const VoiceProps *props, const ContextBa else if(Distance > 0.0f) spread = std::asin(props->Radius/Distance) * 2.0f; - CalcPanningAndFilters(voice, ToSource[0], ToSource[1], ToSource[2]*ZScale, + CalcPanningAndFilters(voice, ToSource[0]*XScale, ToSource[1]*YScale, ToSource[2]*ZScale, Distance*context->mParams.MetersPerUnit, spread, DryGain, WetGain, SendSlots, props, context->mParams, Device); } @@ -16,6 +16,8 @@ constexpr float GainMixMax{1000.0f}; /* +60dB */ enum CompatFlags : uint8_t { + ReverseX, + ReverseY, ReverseZ, Count diff --git a/alsoftrc.sample b/alsoftrc.sample index 4634586e..73338995 100644 --- a/alsoftrc.sample +++ b/alsoftrc.sample @@ -598,6 +598,14 @@ ## [game_compat] +## reverse-x: (global) +# Reverses the local X (left-right) position of 3D sound sources. +#reverse-x = false + +## reverse-y: (global) +# Reverses the local Y (up-down) position of 3D sound sources. +#reverse-y = false + ## reverse-z: (global) # Reverses the local Z (front-back) position of 3D sound sources. #reverse-z = false diff --git a/docs/env-vars.txt b/docs/env-vars.txt index fee9ffb0..77a30c58 100644 --- a/docs/env-vars.txt +++ b/docs/env-vars.txt @@ -64,8 +64,13 @@ to it before passing in 3D coordinates. Depending on how exactly this is done, it can cause correct output for stereo but incorrect Z panning for surround sound (i.e., sounds that are supposed to be behind you sound like they're in front, and vice-versa). Setting this to "true" or "1" will negate the localized -Z coordinate to attempt to fix output for apps that have incorrect front/back -panning. +Z coordinate to flip front/back panning for 3D sources. + +__ALSOFT_REVERSE_Y +Same as for __ALSOFT_REVERSE_Z, but for Y (up/down) panning. + +__ALSOFT_REVERSE_X +Same as for __ALSOFT_REVERSE_Z, but for X (left/right) panning. __ALSOFT_SUSPEND_CONTEXT Due to the OpenAL spec not being very clear about them, behavior of the |