1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-01-21 07:53:53 +00:00

Ensure 3D sources are spatialized

Standard OpenAL does not spatialize non-mono sounds, although the game has some
stereo sounds meant to play in 3D. The desired behavior can be achieved with
the AL_SOFT_source_spatialize extension.
This commit is contained in:
Chris Robinson 2017-09-13 03:27:48 -07:00
parent 6f57233ba1
commit 605c937572
2 changed files with 8 additions and 0 deletions

View file

@ -622,6 +622,7 @@ void OpenAL_Output::init(const std::string &devname)
} }
ALC.EXT_EFX = !!alcIsExtensionPresent(mDevice, "ALC_EXT_EFX"); ALC.EXT_EFX = !!alcIsExtensionPresent(mDevice, "ALC_EXT_EFX");
AL.SOFT_source_spatialize = !!alIsExtensionPresent("AL_SOFT_source_spatialize");
alDistanceModel(AL_INVERSE_DISTANCE_CLAMPED); alDistanceModel(AL_INVERSE_DISTANCE_CLAMPED);
throwALerror(); throwALerror();
@ -972,6 +973,8 @@ void OpenAL_Output::initCommon2D(ALuint source, const osg::Vec3f &pos, ALfloat g
alSourcef(source, AL_ROLLOFF_FACTOR, 0.0f); alSourcef(source, AL_ROLLOFF_FACTOR, 0.0f);
alSourcei(source, AL_SOURCE_RELATIVE, AL_TRUE); alSourcei(source, AL_SOURCE_RELATIVE, AL_TRUE);
alSourcei(source, AL_LOOPING, loop ? AL_TRUE : AL_FALSE); alSourcei(source, AL_LOOPING, loop ? AL_TRUE : AL_FALSE);
if(AL.SOFT_source_spatialize)
alSourcei(source, AL_SOURCE_SPATIALIZE_SOFT, AL_FALSE);
if(useenv) if(useenv)
{ {
@ -1009,6 +1012,8 @@ void OpenAL_Output::initCommon3D(ALuint source, const osg::Vec3f &pos, ALfloat m
alSourcef(source, AL_ROLLOFF_FACTOR, 1.0f); alSourcef(source, AL_ROLLOFF_FACTOR, 1.0f);
alSourcei(source, AL_SOURCE_RELATIVE, AL_FALSE); alSourcei(source, AL_SOURCE_RELATIVE, AL_FALSE);
alSourcei(source, AL_LOOPING, loop ? AL_TRUE : AL_FALSE); alSourcei(source, AL_LOOPING, loop ? AL_TRUE : AL_FALSE);
if(AL.SOFT_source_spatialize)
alSourcei(source, AL_SOURCE_SPATIALIZE_SOFT, AL_TRUE);
if((pos - mListenerPos).length2() > maxdist*maxdist) if((pos - mListenerPos).length2() > maxdist*maxdist)
gain = 0.0f; gain = 0.0f;

View file

@ -26,6 +26,9 @@ namespace MWSound
struct { struct {
int EXT_EFX : 1; int EXT_EFX : 1;
} ALC; } ALC;
struct {
int SOFT_source_spatialize : 1;
} AL;
typedef std::deque<ALuint> IDDq; typedef std::deque<ALuint> IDDq;
IDDq mFreeSources; IDDq mFreeSources;