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
This commit is contained in:
Spoike 2020-01-20 18:43:46 +00:00
parent 0d01ec40ea
commit 79bd5bd8a9
2 changed files with 8 additions and 7 deletions

View file

@ -2632,7 +2632,7 @@ channel_t *SND_PickChannel(soundcardinfo_t *sc, int entnum, int entchannel)
if (oldest == -1) if (oldest == -1)
return NULL; return NULL;
if (sc->channel[oldest].sfx) //if (sc->channel[oldest].sfx)
sc->channel[oldest].sfx = NULL; sc->channel[oldest].sfx = NULL;
if (sc->total_chans <= oldest) if (sc->total_chans <= oldest)
@ -2891,11 +2891,12 @@ static void S_UpdateSoundCard(soundcardinfo_t *sc, qboolean updateonly, channel_
return; return;
} }
if (!ratemul) //rate of 0
ratemul = 1;
ratemul *= snd_playbackrate.value; ratemul *= snd_playbackrate.value;
if (!snd_ignoregamespeed.ival) if (!snd_ignoregamespeed.ival)
ratemul *= (cls.state?cl.gamespeed:1) * (cls.demoplayback?cl_demospeed.value:1); ratemul *= (cls.state?cl.gamespeed:1) * (cls.demoplayback?cl_demospeed.value:1);
if (ratemul <= 0) //in case the user set the cvars weirdly
if (ratemul <= 0)
ratemul = 1; ratemul = 1;
vol = fvol*255; vol = fvol*255;

View file

@ -554,11 +554,11 @@ static void SND_PaintChannel16_O2I1 (channel_t *ch, sfxcache_t *sc, int starttim
sfx = (signed short *)sc->data; sfx = (signed short *)sc->data;
for (i=0 ; i<count ; i++) for (i=0 ; i<count ; i++)
{ {
float frac = pos&((1<<PITCHSHIFT)-1); int frac = pos&((1<<PITCHSHIFT)-1);
data = sfx[pos>>PITCHSHIFT] * (1-frac) + sfx[(pos>>PITCHSHIFT)+1] * frac; data = sfx[pos>>PITCHSHIFT] * ((1<<PITCHSHIFT)-1-frac) + sfx[(pos>>PITCHSHIFT)+1] * frac;
pos += rate; pos += rate;
paintbuffer[starttime+i].s[0] += (leftvol * data)>>8; paintbuffer[starttime+i].s[0] += (leftvol * data)>>(PITCHSHIFT+8);
paintbuffer[starttime+i].s[1] += (rightvol * data)>>8; paintbuffer[starttime+i].s[1] += (rightvol * data)>>(PITCHSHIFT+8);
} }
} }
else else