diff --git a/src/sound/i_sound.cpp b/src/sound/i_sound.cpp index 939734e2f..f80ec6865 100644 --- a/src/sound/i_sound.cpp +++ b/src/sound/i_sound.cpp @@ -66,6 +66,7 @@ EXTERN_CVAR (Float, snd_sfxvolume) CVAR (Int, snd_samplerate, 0, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) CVAR (Int, snd_buffersize, 0, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) CVAR (String, snd_output, "default", CVAR_ARCHIVE|CVAR_GLOBALCONFIG) +CVAR (Int, snd_hrtf, 0, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) #if !defined(NO_OPENAL) #define DEF_BACKEND "openal" diff --git a/src/sound/oalsound.cpp b/src/sound/oalsound.cpp index 30aa8b3e1..b1235dfdd 100644 --- a/src/sound/oalsound.cpp +++ b/src/sound/oalsound.cpp @@ -132,6 +132,7 @@ EXTERN_CVAR (Int, snd_channels) EXTERN_CVAR (Int, snd_samplerate) EXTERN_CVAR (Bool, snd_waterreverb) EXTERN_CVAR (Bool, snd_pitched) +EXTERN_CVAR (Int, snd_hrtf) #define MAKE_PTRID(x) ((void*)(uintptr_t)(x)) @@ -722,6 +723,11 @@ OpenALSoundRenderer::OpenALSoundRenderer() Device = InitDevice(); if (Device == NULL) return; + ALC.EXT_EFX = !!alcIsExtensionPresent(Device, "ALC_EXT_EFX"); + ALC.EXT_disconnect = !!alcIsExtensionPresent(Device, "ALC_EXT_disconnect"); + ALC.SOFT_HRTF = !!alcIsExtensionPresent(Device, "ALC_SOFT_HRTF"); + ALC.SOFT_pause_device = !!alcIsExtensionPresent(Device, "ALC_SOFT_pause_device"); + const ALCchar *current = NULL; if(alcIsExtensionPresent(Device, "ALC_ENUMERATE_ALL_EXT")) current = alcGetString(Device, ALC_ALL_DEVICES_SPECIFIER); @@ -747,6 +753,16 @@ OpenALSoundRenderer::OpenALSoundRenderer() attribs.Push(MAX(*snd_channels, 2) - 1); attribs.Push(ALC_STEREO_SOURCES); attribs.Push(1); + if(ALC.SOFT_HRTF) + { + attribs.Push(ALC_HRTF_SOFT); + if(*snd_hrtf < 0) + attribs.Push(ALC_FALSE); + else if(*snd_hrtf > 0) + attribs.Push(ALC_TRUE); + else + attribs.Push(ALC_DONT_CARE_SOFT); + } // Other attribs..? attribs.Push(0); @@ -768,9 +784,6 @@ OpenALSoundRenderer::OpenALSoundRenderer() DPrintf(DMSG_SPAMMY, " Version: " TEXTCOLOR_ORANGE"%s\n", alGetString(AL_VERSION)); DPrintf(DMSG_SPAMMY, " Extensions: " TEXTCOLOR_ORANGE"%s\n", alGetString(AL_EXTENSIONS)); - ALC.EXT_EFX = !!alcIsExtensionPresent(Device, "ALC_EXT_EFX"); - ALC.EXT_disconnect = !!alcIsExtensionPresent(Device, "ALC_EXT_disconnect"); - ALC.SOFT_pause_device = !!alcIsExtensionPresent(Device, "ALC_SOFT_pause_device"); AL.EXT_source_distance_model = !!alIsExtensionPresent("AL_EXT_source_distance_model"); AL.EXT_SOURCE_RADIUS = !!alIsExtensionPresent("AL_EXT_SOURCE_RADIUS"); AL.SOFT_deferred_updates = !!alIsExtensionPresent("AL_SOFT_deferred_updates"); diff --git a/src/sound/oalsound.h b/src/sound/oalsound.h index 212ba5c46..4a69028dc 100644 --- a/src/sound/oalsound.h +++ b/src/sound/oalsound.h @@ -35,6 +35,28 @@ #define ALC_CONNECTED 0x313 #endif +#ifndef ALC_SOFT_HRTF +#define ALC_SOFT_HRTF 1 +#define ALC_HRTF_SOFT 0x1992 +#define ALC_DONT_CARE_SOFT 0x0002 +#define ALC_HRTF_STATUS_SOFT 0x1993 +#define ALC_HRTF_DISABLED_SOFT 0x0000 +#define ALC_HRTF_ENABLED_SOFT 0x0001 +#define ALC_HRTF_DENIED_SOFT 0x0002 +#define ALC_HRTF_REQUIRED_SOFT 0x0003 +#define ALC_HRTF_HEADPHONES_DETECTED_SOFT 0x0004 +#define ALC_HRTF_UNSUPPORTED_FORMAT_SOFT 0x0005 +#define ALC_NUM_HRTF_SPECIFIERS_SOFT 0x1994 +#define ALC_HRTF_SPECIFIER_SOFT 0x1995 +#define ALC_HRTF_ID_SOFT 0x1996 +typedef const ALCchar* (ALC_APIENTRY*LPALCGETSTRINGISOFT)(ALCdevice *device, ALCenum paramName, ALCsizei index); +typedef ALCboolean (ALC_APIENTRY*LPALCRESETDEVICESOFT)(ALCdevice *device, const ALCint *attribs); +#ifdef AL_ALEXT_PROTOTYPES +ALC_API const ALCchar* ALC_APIENTRY alcGetStringiSOFT(ALCdevice *device, ALCenum paramName, ALCsizei index); +ALC_API ALCboolean ALC_APIENTRY alcResetDeviceSOFT(ALCdevice *device, const ALCint *attribs); +#endif +#endif + #ifndef AL_EXT_source_distance_model #define AL_EXT_source_distance_model 1 #define AL_SOURCE_DISTANCE_MODEL 0x200 @@ -142,6 +164,7 @@ private: struct { bool EXT_EFX; bool EXT_disconnect; + bool SOFT_HRTF; bool SOFT_pause_device; } ALC; struct {