mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-10 23:02:08 +00:00
Don't downmix sounds when AL_SOFT_source_spatialize is available
This commit is contained in:
parent
7af11b1963
commit
e1fc33c38f
2 changed files with 26 additions and 3 deletions
|
@ -285,6 +285,8 @@ class OpenALSoundStream : public SoundStream
|
||||||
}
|
}
|
||||||
if(Renderer->AL.EXT_SOURCE_RADIUS)
|
if(Renderer->AL.EXT_SOURCE_RADIUS)
|
||||||
alSourcef(Source, AL_SOURCE_RADIUS, 0.f);
|
alSourcef(Source, AL_SOURCE_RADIUS, 0.f);
|
||||||
|
if(Renderer->AL.SOFT_source_spatialize)
|
||||||
|
alSourcei(Source, AL_SOURCE_SPATIALIZE_SOFT, AL_AUTO_SOFT);
|
||||||
|
|
||||||
alGenBuffers(BufferCount, Buffers);
|
alGenBuffers(BufferCount, Buffers);
|
||||||
return (getALError() == AL_NO_ERROR);
|
return (getALError() == AL_NO_ERROR);
|
||||||
|
@ -816,6 +818,7 @@ OpenALSoundRenderer::OpenALSoundRenderer()
|
||||||
AL.SOFT_deferred_updates = !!alIsExtensionPresent("AL_SOFT_deferred_updates");
|
AL.SOFT_deferred_updates = !!alIsExtensionPresent("AL_SOFT_deferred_updates");
|
||||||
AL.SOFT_loop_points = !!alIsExtensionPresent("AL_SOFT_loop_points");
|
AL.SOFT_loop_points = !!alIsExtensionPresent("AL_SOFT_loop_points");
|
||||||
AL.SOFT_source_resampler = !!alIsExtensionPresent("AL_SOFT_source_resampler");
|
AL.SOFT_source_resampler = !!alIsExtensionPresent("AL_SOFT_source_resampler");
|
||||||
|
AL.SOFT_source_spatialize = !!alIsExtensionPresent("AL_SOFT_source_spatialize");
|
||||||
|
|
||||||
alDopplerFactor(0.5f);
|
alDopplerFactor(0.5f);
|
||||||
alSpeedOfSound(343.3f * 96.0f);
|
alSpeedOfSound(343.3f * 96.0f);
|
||||||
|
@ -1177,6 +1180,9 @@ std::pair<SoundHandle,bool> OpenALSoundRenderer::LoadSoundRaw(uint8_t *sfxdata,
|
||||||
|
|
||||||
if(length == 0) return std::make_pair(retval, true);
|
if(length == 0) return std::make_pair(retval, true);
|
||||||
|
|
||||||
|
/* Only downmix to mono if we can't spatialize multi-channel sounds. */
|
||||||
|
monoize = monoize && !AL.SOFT_source_spatialize;
|
||||||
|
|
||||||
if(bits == -8)
|
if(bits == -8)
|
||||||
{
|
{
|
||||||
// Simple signed->unsigned conversion
|
// Simple signed->unsigned conversion
|
||||||
|
@ -1264,7 +1270,7 @@ std::pair<SoundHandle,bool> OpenALSoundRenderer::LoadSoundRaw(uint8_t *sfxdata,
|
||||||
}
|
}
|
||||||
|
|
||||||
retval.data = MAKE_PTRID(buffer);
|
retval.data = MAKE_PTRID(buffer);
|
||||||
return std::make_pair(retval, channels==1);
|
return std::make_pair(retval, AL.SOFT_source_spatialize || channels==1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FindLoopTags(FileReader *fr, uint32_t *start, bool *startass, uint32_t *end, bool *endass);
|
void FindLoopTags(FileReader *fr, uint32_t *start, bool *startass, uint32_t *end, bool *endass);
|
||||||
|
@ -1280,6 +1286,9 @@ std::pair<SoundHandle,bool> OpenALSoundRenderer::LoadSound(uint8_t *sfxdata, int
|
||||||
uint32_t loop_start = 0, loop_end = ~0u;
|
uint32_t loop_start = 0, loop_end = ~0u;
|
||||||
bool startass = false, endass = false;
|
bool startass = false, endass = false;
|
||||||
|
|
||||||
|
/* Only downmix to mono if we can't spatialize multi-channel sounds. */
|
||||||
|
monoize = monoize && !AL.SOFT_source_spatialize;
|
||||||
|
|
||||||
if (!memcmp(sfxdata, "OggS", 4) || !memcmp(sfxdata, "FLAC", 4))
|
if (!memcmp(sfxdata, "OggS", 4) || !memcmp(sfxdata, "FLAC", 4))
|
||||||
{
|
{
|
||||||
MemoryReader mr((char*)sfxdata, length);
|
MemoryReader mr((char*)sfxdata, length);
|
||||||
|
@ -1377,7 +1386,7 @@ std::pair<SoundHandle,bool> OpenALSoundRenderer::LoadSound(uint8_t *sfxdata, int
|
||||||
pBuffer->type = type;
|
pBuffer->type = type;
|
||||||
pBuffer->srate = srate;
|
pBuffer->srate = srate;
|
||||||
}
|
}
|
||||||
return std::make_pair(retval, (chans == ChannelConfig_Mono || monoize));
|
return std::make_pair(retval, AL.SOFT_source_spatialize || chans == ChannelConfig_Mono || monoize);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::pair<SoundHandle, bool> OpenALSoundRenderer::LoadSoundBuffered(FSoundLoadBuffer *pBuffer, bool monoize)
|
std::pair<SoundHandle, bool> OpenALSoundRenderer::LoadSoundBuffered(FSoundLoadBuffer *pBuffer, bool monoize)
|
||||||
|
@ -1389,6 +1398,9 @@ std::pair<SoundHandle, bool> OpenALSoundRenderer::LoadSoundBuffered(FSoundLoadBu
|
||||||
auto chans = pBuffer->chans;
|
auto chans = pBuffer->chans;
|
||||||
uint32_t loop_start = pBuffer->loop_start, loop_end = pBuffer->loop_end;
|
uint32_t loop_start = pBuffer->loop_start, loop_end = pBuffer->loop_end;
|
||||||
|
|
||||||
|
/* Only downmix to mono if we can't spatialize multi-channel sounds. */
|
||||||
|
monoize = monoize && !AL.SOFT_source_spatialize;
|
||||||
|
|
||||||
if (chans == ChannelConfig_Mono || monoize)
|
if (chans == ChannelConfig_Mono || monoize)
|
||||||
{
|
{
|
||||||
if (type == SampleType_UInt8) format = AL_FORMAT_MONO8;
|
if (type == SampleType_UInt8) format = AL_FORMAT_MONO8;
|
||||||
|
@ -1461,7 +1473,7 @@ std::pair<SoundHandle, bool> OpenALSoundRenderer::LoadSoundBuffered(FSoundLoadBu
|
||||||
}
|
}
|
||||||
|
|
||||||
retval.data = MAKE_PTRID(buffer);
|
retval.data = MAKE_PTRID(buffer);
|
||||||
return std::make_pair(retval, (chans == ChannelConfig_Mono || monoize));
|
return std::make_pair(retval, AL.SOFT_source_spatialize || chans == ChannelConfig_Mono || monoize);
|
||||||
}
|
}
|
||||||
|
|
||||||
void OpenALSoundRenderer::UnloadSound(SoundHandle sfx)
|
void OpenALSoundRenderer::UnloadSound(SoundHandle sfx)
|
||||||
|
@ -1560,6 +1572,8 @@ FISoundChannel *OpenALSoundRenderer::StartSound(SoundHandle sfx, float vol, int
|
||||||
alSourcef(source, AL_GAIN, SfxVolume*vol);
|
alSourcef(source, AL_GAIN, SfxVolume*vol);
|
||||||
if(AL.EXT_SOURCE_RADIUS)
|
if(AL.EXT_SOURCE_RADIUS)
|
||||||
alSourcef(source, AL_SOURCE_RADIUS, 0.f);
|
alSourcef(source, AL_SOURCE_RADIUS, 0.f);
|
||||||
|
if(AL.SOFT_source_spatialize)
|
||||||
|
alSourcei(source, AL_SOURCE_SPATIALIZE_SOFT, AL_AUTO_SOFT);
|
||||||
|
|
||||||
if(EnvSlot)
|
if(EnvSlot)
|
||||||
{
|
{
|
||||||
|
@ -1768,6 +1782,8 @@ FISoundChannel *OpenALSoundRenderer::StartSound3D(SoundHandle sfx, SoundListener
|
||||||
|
|
||||||
alSourcef(source, AL_MAX_GAIN, SfxVolume);
|
alSourcef(source, AL_MAX_GAIN, SfxVolume);
|
||||||
alSourcef(source, AL_GAIN, SfxVolume*vol);
|
alSourcef(source, AL_GAIN, SfxVolume*vol);
|
||||||
|
if(AL.SOFT_source_spatialize)
|
||||||
|
alSourcei(source, AL_SOURCE_SPATIALIZE_SOFT, AL_TRUE);
|
||||||
|
|
||||||
if(EnvSlot)
|
if(EnvSlot)
|
||||||
{
|
{
|
||||||
|
|
|
@ -109,6 +109,12 @@ AL_API const ALchar* AL_APIENTRY alGetStringiSOFT(ALenum pname, ALsizei index);
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef AL_SOFT_source_spatialize
|
||||||
|
#define AL_SOFT_source_spatialize
|
||||||
|
#define AL_SOURCE_SPATIALIZE_SOFT 0x1214
|
||||||
|
#define AL_AUTO_SOFT 0x0002
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
class OpenALSoundStream;
|
class OpenALSoundStream;
|
||||||
|
|
||||||
|
@ -184,6 +190,7 @@ private:
|
||||||
bool SOFT_deferred_updates;
|
bool SOFT_deferred_updates;
|
||||||
bool SOFT_loop_points;
|
bool SOFT_loop_points;
|
||||||
bool SOFT_source_resampler;
|
bool SOFT_source_resampler;
|
||||||
|
bool SOFT_source_spatialize;
|
||||||
} AL;
|
} AL;
|
||||||
|
|
||||||
// EFX Extension function pointer variables. Loaded after context creation
|
// EFX Extension function pointer variables. Loaded after context creation
|
||||||
|
|
Loading…
Reference in a new issue