diff --git a/Engine/source/sfx/openal/sfxALDevice.cpp b/Engine/source/sfx/openal/sfxALDevice.cpp index 6e75d754d..36372a58f 100644 --- a/Engine/source/sfx/openal/sfxALDevice.cpp +++ b/Engine/source/sfx/openal/sfxALDevice.cpp @@ -352,6 +352,30 @@ void SFXALDevice::printALInfo(ALCdevice* device) for (ALCint i = 0; i < profileCount; i++) Con::printf("| [%d] %s", i, alcGetStringiSOFT(device, ALC_HRTF_SPECIFIER_SOFT, i)); + + bool use_hrtf = Con::getBoolVariable("$pref::SFX::useHRTF"); + if (use_hrtf && (mCaps & CAPS_HotReconnect)) + { + ALCint attr[5]; + ALCint index = Con::getIntVariable("$pref::SFX::hrtfProfile"); + ALCint i; + + i = 0; + attr[i++] = ALC_HRTF_SOFT; + attr[i++] = ALC_TRUE; + // load the default device hrtf. + if (index >= 0 && index < profileCount) + { + attr[i++] = ALC_HRTF_ID_SOFT; + attr[i++] = index; + } + attr[i] = 0; + + if (!alcResetDeviceSOFT(mDevice, attr)) + { + Con::printf("Failed to reset device: %s", alcGetString(mDevice, alcGetError(mDevice))); + } + } } // --- EFX --- diff --git a/Engine/source/sfx/sfxDevice.cpp b/Engine/source/sfx/sfxDevice.cpp index e800ca420..0c5d2c8ee 100644 --- a/Engine/source/sfx/sfxDevice.cpp +++ b/Engine/source/sfx/sfxDevice.cpp @@ -33,6 +33,7 @@ S32 SFXDevice::smUpdateInterval = SFXInternal::DEFAULT_UPDATE_INTERVAL; S32 SFXDevice::smDeviceFrequency = 44100; S32 SFXDevice::smMaxSendsPerSource = 4; S32 SFXDevice::smMaxEffectSlots = 4; +S32 SFXDevice::smDeviceHRTFProfile = -1; S8 SFXDevice::smDeviceBitrate = 16; bool SFXDevice::smDeviceHRTF = false; @@ -51,6 +52,11 @@ void SFXDevice::initConsole() "The device uses hrtf.\n" "@ingroup SFX\n"); + Con::addVariable("$pref::SFX::hrtfProfile", TypeS32, &smDeviceHRTFProfile, + "Index of the HRTF profile to use. -1 = driver default. " + "Use sfxGetHRTFProfileCount/sfxGetHRTFProfileName to enumerate available profiles.\n" + "@ingroup SFX\n"); + Con::addVariable("$pref::SFX::updateInterval", TypeS32, &smUpdateInterval, "The update interval.\n" "@ingroup SFX\n"); diff --git a/Engine/source/sfx/sfxDevice.h b/Engine/source/sfx/sfxDevice.h index 5a7170e31..d75d6aacf 100644 --- a/Engine/source/sfx/sfxDevice.h +++ b/Engine/source/sfx/sfxDevice.h @@ -81,6 +81,8 @@ class SFXDevice static S32 smUpdateInterval; /// The device frequency, used when reading in buffers for the device. static S32 smDeviceFrequency; + /// The device hrtf profile to use. + static S32 smDeviceHRTFProfile; /// The device bitrate. static S8 smDeviceBitrate; /// Does the device use hrtf