From 79bd5bd8a9c1d0a387ff48c4aa4710d1d2ace085 Mon Sep 17 00:00:00 2001 From: Spoike Date: Mon, 20 Jan 2020 18:43:46 +0000 Subject: [PATCH] Try to fix noise with certain sounds with rate scaling active. Fix snd_playbackrate cvar not applying to csqc's sounds. (Both issues reported by GoaLitiuM) git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5609 fc73d0e0-1445-4013-8a0c-d673dee63da5 --- engine/client/snd_dma.c | 7 ++++--- engine/client/snd_mix.c | 8 ++++---- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/engine/client/snd_dma.c b/engine/client/snd_dma.c index f8060461e..a15980f3e 100644 --- a/engine/client/snd_dma.c +++ b/engine/client/snd_dma.c @@ -2632,7 +2632,7 @@ channel_t *SND_PickChannel(soundcardinfo_t *sc, int entnum, int entchannel) if (oldest == -1) return NULL; - if (sc->channel[oldest].sfx) + //if (sc->channel[oldest].sfx) sc->channel[oldest].sfx = NULL; if (sc->total_chans <= oldest) @@ -2891,11 +2891,12 @@ static void S_UpdateSoundCard(soundcardinfo_t *sc, qboolean updateonly, channel_ return; } + if (!ratemul) //rate of 0 + ratemul = 1; ratemul *= snd_playbackrate.value; if (!snd_ignoregamespeed.ival) ratemul *= (cls.state?cl.gamespeed:1) * (cls.demoplayback?cl_demospeed.value:1); - - if (ratemul <= 0) + if (ratemul <= 0) //in case the user set the cvars weirdly ratemul = 1; vol = fvol*255; diff --git a/engine/client/snd_mix.c b/engine/client/snd_mix.c index 9dabf3438..64187f546 100644 --- a/engine/client/snd_mix.c +++ b/engine/client/snd_mix.c @@ -554,11 +554,11 @@ static void SND_PaintChannel16_O2I1 (channel_t *ch, sfxcache_t *sc, int starttim sfx = (signed short *)sc->data; for (i=0 ; i>PITCHSHIFT] * (1-frac) + sfx[(pos>>PITCHSHIFT)+1] * frac; + int frac = pos&((1<>PITCHSHIFT] * ((1<>PITCHSHIFT)+1] * frac; pos += rate; - paintbuffer[starttime+i].s[0] += (leftvol * data)>>8; - paintbuffer[starttime+i].s[1] += (rightvol * data)>>8; + paintbuffer[starttime+i].s[0] += (leftvol * data)>>(PITCHSHIFT+8); + paintbuffer[starttime+i].s[1] += (rightvol * data)>>(PITCHSHIFT+8); } } else