From 2b740b33aa400028c12d146258905b037fd111d7 Mon Sep 17 00:00:00 2001 From: Nico de Poel Date: Tue, 13 Apr 2021 13:30:57 +0200 Subject: [PATCH] Give local player sounds higher-than-default priority, so its real channels won't get stolen by other entity sounds --- engine/Quake/snd_fmod.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/engine/Quake/snd_fmod.c b/engine/Quake/snd_fmod.c index eb4de56..7dcc4b9 100644 --- a/engine/Quake/snd_fmod.c +++ b/engine/Quake/snd_fmod.c @@ -276,7 +276,11 @@ void S_StartSound(int entnum, int entchannel, sfx_t *sfx, vec3_t origin, float f FMOD_Channel_SetVolume(channel, fvol); // Anything coming from the view entity will always be full volume, and entchannel -1 is used for local sounds (e.g. menu sounds) - FMOD_Channel_Set3DLevel(channel, entchannel < 0 || entnum == cl.viewentity ? 0.0f : 1.0f); + if (entchannel < 0 || entnum == cl.viewentity) + { + FMOD_Channel_Set3DLevel(channel, 0.0f); + FMOD_Channel_SetPriority(channel, 64); // Ensure local sounds always get priority over other entities + } // Use ChannelControl::setDelay and ChannelControl::getDSPClock to add a delay to move sounds out of phase if necessary