2004-08-23 00:15:46 +00:00
|
|
|
/*
|
|
|
|
Copyright (C) 1996-1997 Id Software, Inc.
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU General Public License
|
|
|
|
as published by the Free Software Foundation; either version 2
|
|
|
|
of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2011-05-29 04:26:29 +00:00
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
2004-08-23 00:15:46 +00:00
|
|
|
|
|
|
|
See the GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
|
|
|
|
*/
|
|
|
|
// snd_mix.c -- portable code to mix sounds for snd_dma.c
|
|
|
|
|
|
|
|
#include "quakedef.h"
|
|
|
|
|
2017-05-23 07:03:07 +00:00
|
|
|
#ifdef HAVE_MIXER
|
|
|
|
|
2004-08-23 00:15:46 +00:00
|
|
|
#define PAINTBUFFER_SIZE 2048
|
2006-05-09 07:26:14 +00:00
|
|
|
|
2016-07-12 00:40:13 +00:00
|
|
|
portable_samplegroup_t paintbuffer[PAINTBUFFER_SIZE]; //FIXME: we really ought to be using SSE and floats or something.
|
2006-05-09 07:26:14 +00:00
|
|
|
|
2004-08-23 00:15:46 +00:00
|
|
|
int *snd_p, snd_vol;
|
|
|
|
short *snd_out;
|
|
|
|
|
|
|
|
void S_TransferPaintBuffer(soundcardinfo_t *sc, int endtime)
|
|
|
|
{
|
2012-04-09 19:12:12 +00:00
|
|
|
unsigned int out_idx;
|
2007-10-03 09:09:08 +00:00
|
|
|
unsigned int count;
|
|
|
|
unsigned int outlimit;
|
|
|
|
int *p;
|
|
|
|
int val;
|
2013-05-31 01:16:07 +00:00
|
|
|
// int snd_vol;
|
2007-10-03 09:09:08 +00:00
|
|
|
short *pbuf;
|
2011-07-06 05:53:25 +00:00
|
|
|
int i, numc;
|
2004-08-23 00:15:46 +00:00
|
|
|
|
|
|
|
p = (int *) paintbuffer;
|
|
|
|
count = (endtime - sc->paintedtime) * sc->sn.numchannels;
|
2011-05-29 04:26:29 +00:00
|
|
|
outlimit = sc->sn.samples;
|
2012-04-09 19:12:12 +00:00
|
|
|
out_idx = (sc->paintedtime * sc->sn.numchannels) % outlimit;
|
2013-05-31 01:16:07 +00:00
|
|
|
// snd_vol = (volume.value*voicevolumemod)*256;
|
2011-07-06 05:53:25 +00:00
|
|
|
numc = sc->sn.numchannels;
|
2004-08-23 00:15:46 +00:00
|
|
|
|
2012-04-09 19:12:12 +00:00
|
|
|
pbuf = sc->Lock(sc, &out_idx);
|
2005-06-14 04:52:10 +00:00
|
|
|
if (!pbuf)
|
|
|
|
return;
|
2004-08-23 00:15:46 +00:00
|
|
|
|
2017-09-20 11:27:13 +00:00
|
|
|
switch(sc->sn.sampleformat)
|
2004-08-23 00:15:46 +00:00
|
|
|
{
|
2017-09-20 11:27:13 +00:00
|
|
|
case QSF_INVALID: //erk...
|
|
|
|
case QSF_EXTERNALMIXER: //shouldn't reach this.
|
|
|
|
break;
|
|
|
|
case QSF_U8:
|
2004-08-23 00:15:46 +00:00
|
|
|
{
|
2017-09-20 11:27:13 +00:00
|
|
|
unsigned char *out = (unsigned char *) pbuf;
|
|
|
|
while (count)
|
2011-07-06 05:53:25 +00:00
|
|
|
{
|
2017-09-20 11:27:13 +00:00
|
|
|
for (i = 0; i < numc; i++)
|
|
|
|
{
|
|
|
|
val = *p++;// * snd_vol) >> 8;
|
|
|
|
if (val > 0x7fff)
|
|
|
|
val = 0x7fff;
|
|
|
|
else if (val < (short)0x8000)
|
|
|
|
val = (short)0x8000;
|
|
|
|
out[out_idx] = (val>>8) + 128;
|
|
|
|
out_idx = (out_idx + 1) % outlimit;
|
|
|
|
}
|
|
|
|
p += MAXSOUNDCHANNELS - numc;
|
|
|
|
count -= numc;
|
2011-07-06 05:53:25 +00:00
|
|
|
}
|
2006-05-09 07:26:14 +00:00
|
|
|
}
|
2017-09-20 11:27:13 +00:00
|
|
|
break;
|
|
|
|
case QSF_S8:
|
2004-08-23 00:15:46 +00:00
|
|
|
{
|
2017-09-20 11:27:13 +00:00
|
|
|
char *out = (char *) pbuf;
|
|
|
|
while (count)
|
2011-07-06 05:53:25 +00:00
|
|
|
{
|
2017-09-20 11:27:13 +00:00
|
|
|
for (i = 0; i < numc; i++)
|
|
|
|
{
|
|
|
|
val = *p++;// * snd_vol) >> 8;
|
|
|
|
if (val > 0x7fff)
|
|
|
|
val = 0x7fff;
|
|
|
|
else if (val < (short)0x8000)
|
|
|
|
val = (short)0x8000;
|
|
|
|
out[out_idx] = (val>>8);
|
|
|
|
out_idx = (out_idx + 1) % outlimit;
|
|
|
|
}
|
|
|
|
p += MAXSOUNDCHANNELS - numc;
|
|
|
|
count -= numc;
|
2011-07-06 05:53:25 +00:00
|
|
|
}
|
2004-08-23 00:15:46 +00:00
|
|
|
}
|
2017-09-20 11:27:13 +00:00
|
|
|
break;
|
|
|
|
case QSF_S16:
|
|
|
|
{
|
|
|
|
short *out = (short *) pbuf;
|
|
|
|
while (count)
|
|
|
|
{
|
|
|
|
for (i = 0; i < numc; i++)
|
|
|
|
{
|
|
|
|
val = *p++;// * snd_vol) >> 8;
|
|
|
|
if (val > 0x7fff)
|
|
|
|
val = 0x7fff;
|
|
|
|
else if (val < (short)0x8000)
|
|
|
|
val = (short)0x8000;
|
|
|
|
out[out_idx] = val;
|
|
|
|
out_idx = (out_idx + 1) % outlimit;
|
|
|
|
}
|
|
|
|
p += MAXSOUNDCHANNELS - numc;
|
|
|
|
count -= numc;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case QSF_F32:
|
2016-07-12 00:40:13 +00:00
|
|
|
{
|
2017-09-20 11:27:13 +00:00
|
|
|
float *out = (float *) pbuf;
|
|
|
|
while (count)
|
2016-07-12 00:40:13 +00:00
|
|
|
{
|
2017-09-20 11:27:13 +00:00
|
|
|
for (i = 0; i < numc; i++)
|
|
|
|
{
|
|
|
|
out[out_idx] = *p++ * (1.0 / 32768);
|
|
|
|
out_idx = (out_idx + 1) % outlimit;
|
|
|
|
}
|
|
|
|
p += MAXSOUNDCHANNELS - numc;
|
|
|
|
count -= numc;
|
2016-07-12 00:40:13 +00:00
|
|
|
}
|
|
|
|
}
|
2017-09-20 11:27:13 +00:00
|
|
|
break;
|
2016-07-12 00:40:13 +00:00
|
|
|
}
|
2004-08-23 00:15:46 +00:00
|
|
|
|
2005-06-14 04:52:10 +00:00
|
|
|
sc->Unlock(sc, pbuf);
|
2004-08-23 00:15:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
===============================================================================
|
|
|
|
|
|
|
|
CHANNEL MIXING
|
|
|
|
|
|
|
|
===============================================================================
|
|
|
|
*/
|
|
|
|
|
2014-02-07 08:38:40 +00:00
|
|
|
static void SND_PaintChannel8_O2I1 (channel_t *ch, sfxcache_t *sc, int starttime, int count);
|
|
|
|
static void SND_PaintChannel16_O2I1 (channel_t *ch, sfxcache_t *sc, int starttime, int count);
|
|
|
|
static void SND_PaintChannel8_O4I1 (channel_t *ch, sfxcache_t *sc, int count);
|
|
|
|
static void SND_PaintChannel16_O4I1 (channel_t *ch, sfxcache_t *sc, int count);
|
|
|
|
static void SND_PaintChannel8_O6I1 (channel_t *ch, sfxcache_t *sc, int count);
|
|
|
|
static void SND_PaintChannel16_O6I1 (channel_t *ch, sfxcache_t *sc, int count);
|
|
|
|
static void SND_PaintChannel8_O8I1 (channel_t *ch, sfxcache_t *sc, int count);
|
|
|
|
static void SND_PaintChannel16_O8I1 (channel_t *ch, sfxcache_t *sc, int count);
|
|
|
|
static void SND_PaintChannel8_O2I2 (channel_t *ch, sfxcache_t *sc, int starttime, int count);
|
|
|
|
static void SND_PaintChannel16_O2I2 (channel_t *ch, sfxcache_t *sc, int starttime, int count);
|
2004-08-23 00:15:46 +00:00
|
|
|
|
2012-09-30 05:52:03 +00:00
|
|
|
//NOTE: MAY NOT CALL SYS_ERROR
|
2004-08-23 00:15:46 +00:00
|
|
|
void S_PaintChannels(soundcardinfo_t *sc, int endtime)
|
|
|
|
{
|
2012-02-27 12:23:15 +00:00
|
|
|
int i;
|
2004-08-23 00:15:46 +00:00
|
|
|
int end;
|
|
|
|
channel_t *ch;
|
2012-02-27 12:23:15 +00:00
|
|
|
sfxcache_t scachebuf;
|
2004-08-23 00:15:46 +00:00
|
|
|
sfxcache_t *scache;
|
|
|
|
sfx_t *s;
|
|
|
|
int ltime, count;
|
2012-02-27 12:23:15 +00:00
|
|
|
int avail;
|
|
|
|
unsigned int maxlen = ruleset_allow_overlongsounds.ival?0xffffffffu>>PITCHSHIFT:snd_speed*20;
|
2004-08-23 00:15:46 +00:00
|
|
|
|
|
|
|
while (sc->paintedtime < endtime)
|
|
|
|
{
|
|
|
|
// if paintbuffer is smaller than DMA buffer
|
|
|
|
end = endtime;
|
|
|
|
if (endtime - sc->paintedtime > PAINTBUFFER_SIZE)
|
|
|
|
end = sc->paintedtime + PAINTBUFFER_SIZE;
|
|
|
|
|
|
|
|
// clear the paint buffer
|
|
|
|
Q_memset(paintbuffer, 0, (end - sc->paintedtime) * sizeof(portable_samplegroup_t));
|
|
|
|
|
|
|
|
// paint in the channels.
|
|
|
|
ch = sc->channel;
|
|
|
|
for (i=0; i<sc->total_chans ; i++, ch++)
|
|
|
|
{
|
2012-02-27 12:23:15 +00:00
|
|
|
s = ch->sfx;
|
2014-10-05 20:04:11 +00:00
|
|
|
if (!s || s->loadstate == SLS_LOADING)
|
2004-08-23 00:15:46 +00:00
|
|
|
continue;
|
|
|
|
if (!ch->vol[0] && !ch->vol[1] && !ch->vol[2] && !ch->vol[3] && !ch->vol[4] && !ch->vol[5])
|
2013-03-12 22:53:23 +00:00
|
|
|
{
|
|
|
|
//does it still make a sound if it cannot be heard?...
|
|
|
|
//technically no...
|
|
|
|
//this code is hacky.
|
2018-03-05 11:34:20 +00:00
|
|
|
if (s->decoder.querydata)
|
|
|
|
s->decoder.querydata(s, scache=&scachebuf, NULL, 0);
|
|
|
|
else if (s->decoder.decodedata)
|
2017-11-05 13:15:08 +00:00
|
|
|
scache = s->decoder.decodedata(s, &scachebuf, ch->pos>>PITCHSHIFT, 0); /*1 for luck - balances audio termination below*/
|
|
|
|
else
|
2013-03-12 22:53:23 +00:00
|
|
|
scache = s->decoder.buf;
|
2017-11-05 13:15:08 +00:00
|
|
|
ch->pos += (end-sc->paintedtime)*ch->rate;
|
|
|
|
if (!scache || (ch->pos>>PITCHSHIFT) > scache->soundoffset+scache->length)
|
|
|
|
{
|
|
|
|
ch->pos = 0;
|
|
|
|
if (s->loopstart != -1)
|
|
|
|
ch->pos = s->loopstart<<PITCHSHIFT;
|
|
|
|
else if (!(ch->flags & CF_FORCELOOP))
|
2013-03-12 22:53:23 +00:00
|
|
|
{
|
2017-11-05 13:15:08 +00:00
|
|
|
ch->sfx = NULL;
|
|
|
|
if (s->decoder.ended)
|
2013-03-12 22:53:23 +00:00
|
|
|
{
|
2017-11-05 13:15:08 +00:00
|
|
|
if (!S_IsPlayingSomewhere(s))
|
|
|
|
s->decoder.ended(s);
|
2013-03-12 22:53:23 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2004-08-23 00:15:46 +00:00
|
|
|
continue;
|
2013-03-12 22:53:23 +00:00
|
|
|
}
|
2004-10-04 07:25:05 +00:00
|
|
|
|
2004-08-23 00:15:46 +00:00
|
|
|
ltime = sc->paintedtime;
|
2012-02-27 12:23:15 +00:00
|
|
|
while (ltime < end)
|
2004-08-23 00:15:46 +00:00
|
|
|
{
|
playdemo accepts https urls now. will start playing before the file has finished downloading, to avoid unnecessary delays.
reworked network addresses to separate address family and connection type. this should make banning people more reliable, as well as simplifying a whole load of logic (no need to check for ipv4 AND ipv6).
tcpconnect will keep trying to connect even if the connection wasn't instant, instead of giving up instantly.
rewrote tcp connections quite a bit. sv_port_tcp now handles qtv+qizmo+http+ws+rtcbroker+tls equivalents.
qtv_streamport is now a legacy cvar and now acts equivalently to sv_port_tcp (but still separate).
rewrote screenshot and video capture code to use strides. this solves image-is-upside down issues with vulkan.
ignore alt key in browser port. oh no! no more red text! oh no! no more alt-being-wrongly-down-and-being-unable-to-type-anything-without-forcing-alt-released!
reworked audio decoder interface. now has clearly defined success/unavailable/end-of-file results. this should solve a whole load of issues with audio streaming.
fixed various openal audio streaming issues too. openal also got some workarounds for emscripten's poor emulation.
fixed ogg decoder to retain sync properly if seeked.
updated menu_media a bit. now reads vorbis comments/id3v1 tags to get proper track names. also saves the playlist so you don't have to manually repopulate the list so it might actually be usable now (after how many years?)
r_stains now defaults to 0, and is no longer enabled by presets. use decals if you want that sort of thing.
added fs_noreexec cvar, so configs will not be reexeced on gamedir change. this also means defaults won't be reapplied, etc.
added 'nvvk' renderer on windows, using nvidia's vulkan-inside-opengl gl extension. mostly just to see how much slower it is.
fixed up the ftp server quite a lot. more complete, more compliant, and should do ipv6 properly to-boot. file transfers also threaded.
fixed potential crash inside runclientphys.
experimental sv_antilag=3 setting. totally untested. the aim is to avoid missing due to lagged knockbacks. may be expensive for the server.
browser port's websockets support fixed. experimental support for webrtc ('works for me', requires a broker server).
updated avplug(renamed to ffmpeg so people know what it is) to use ffmpeg 3.2.4 properly, with its new encoder api. should be much more robust... also added experimental audio decoder for game music etc (currently doesn't resample, so playback rates are screwed, disabled by cvar).
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5097 fc73d0e0-1445-4013-8a0c-d673dee63da5
2017-05-10 02:08:58 +00:00
|
|
|
ssamplepos_t spos = ch->pos>>PITCHSHIFT;
|
2012-02-27 12:23:15 +00:00
|
|
|
if (s->decoder.decodedata)
|
playdemo accepts https urls now. will start playing before the file has finished downloading, to avoid unnecessary delays.
reworked network addresses to separate address family and connection type. this should make banning people more reliable, as well as simplifying a whole load of logic (no need to check for ipv4 AND ipv6).
tcpconnect will keep trying to connect even if the connection wasn't instant, instead of giving up instantly.
rewrote tcp connections quite a bit. sv_port_tcp now handles qtv+qizmo+http+ws+rtcbroker+tls equivalents.
qtv_streamport is now a legacy cvar and now acts equivalently to sv_port_tcp (but still separate).
rewrote screenshot and video capture code to use strides. this solves image-is-upside down issues with vulkan.
ignore alt key in browser port. oh no! no more red text! oh no! no more alt-being-wrongly-down-and-being-unable-to-type-anything-without-forcing-alt-released!
reworked audio decoder interface. now has clearly defined success/unavailable/end-of-file results. this should solve a whole load of issues with audio streaming.
fixed various openal audio streaming issues too. openal also got some workarounds for emscripten's poor emulation.
fixed ogg decoder to retain sync properly if seeked.
updated menu_media a bit. now reads vorbis comments/id3v1 tags to get proper track names. also saves the playlist so you don't have to manually repopulate the list so it might actually be usable now (after how many years?)
r_stains now defaults to 0, and is no longer enabled by presets. use decals if you want that sort of thing.
added fs_noreexec cvar, so configs will not be reexeced on gamedir change. this also means defaults won't be reapplied, etc.
added 'nvvk' renderer on windows, using nvidia's vulkan-inside-opengl gl extension. mostly just to see how much slower it is.
fixed up the ftp server quite a lot. more complete, more compliant, and should do ipv6 properly to-boot. file transfers also threaded.
fixed potential crash inside runclientphys.
experimental sv_antilag=3 setting. totally untested. the aim is to avoid missing due to lagged knockbacks. may be expensive for the server.
browser port's websockets support fixed. experimental support for webrtc ('works for me', requires a broker server).
updated avplug(renamed to ffmpeg so people know what it is) to use ffmpeg 3.2.4 properly, with its new encoder api. should be much more robust... also added experimental audio decoder for game music etc (currently doesn't resample, so playback rates are screwed, disabled by cvar).
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5097 fc73d0e0-1445-4013-8a0c-d673dee63da5
2017-05-10 02:08:58 +00:00
|
|
|
scache = s->decoder.decodedata(s, &scachebuf, spos, 1 + (((end - ltime) * ch->rate)>>PITCHSHIFT)); /*1 for luck - balances audio termination below*/
|
|
|
|
else if (s->decoder.buf)
|
2004-08-23 00:15:46 +00:00
|
|
|
{
|
playdemo accepts https urls now. will start playing before the file has finished downloading, to avoid unnecessary delays.
reworked network addresses to separate address family and connection type. this should make banning people more reliable, as well as simplifying a whole load of logic (no need to check for ipv4 AND ipv6).
tcpconnect will keep trying to connect even if the connection wasn't instant, instead of giving up instantly.
rewrote tcp connections quite a bit. sv_port_tcp now handles qtv+qizmo+http+ws+rtcbroker+tls equivalents.
qtv_streamport is now a legacy cvar and now acts equivalently to sv_port_tcp (but still separate).
rewrote screenshot and video capture code to use strides. this solves image-is-upside down issues with vulkan.
ignore alt key in browser port. oh no! no more red text! oh no! no more alt-being-wrongly-down-and-being-unable-to-type-anything-without-forcing-alt-released!
reworked audio decoder interface. now has clearly defined success/unavailable/end-of-file results. this should solve a whole load of issues with audio streaming.
fixed various openal audio streaming issues too. openal also got some workarounds for emscripten's poor emulation.
fixed ogg decoder to retain sync properly if seeked.
updated menu_media a bit. now reads vorbis comments/id3v1 tags to get proper track names. also saves the playlist so you don't have to manually repopulate the list so it might actually be usable now (after how many years?)
r_stains now defaults to 0, and is no longer enabled by presets. use decals if you want that sort of thing.
added fs_noreexec cvar, so configs will not be reexeced on gamedir change. this also means defaults won't be reapplied, etc.
added 'nvvk' renderer on windows, using nvidia's vulkan-inside-opengl gl extension. mostly just to see how much slower it is.
fixed up the ftp server quite a lot. more complete, more compliant, and should do ipv6 properly to-boot. file transfers also threaded.
fixed potential crash inside runclientphys.
experimental sv_antilag=3 setting. totally untested. the aim is to avoid missing due to lagged knockbacks. may be expensive for the server.
browser port's websockets support fixed. experimental support for webrtc ('works for me', requires a broker server).
updated avplug(renamed to ffmpeg so people know what it is) to use ffmpeg 3.2.4 properly, with its new encoder api. should be much more robust... also added experimental audio decoder for game music etc (currently doesn't resample, so playback rates are screwed, disabled by cvar).
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5097 fc73d0e0-1445-4013-8a0c-d673dee63da5
2017-05-10 02:08:58 +00:00
|
|
|
scache = s->decoder.buf;
|
|
|
|
if (spos >= scache->length)
|
|
|
|
scache = NULL; //EOF
|
2004-08-23 00:15:46 +00:00
|
|
|
}
|
playdemo accepts https urls now. will start playing before the file has finished downloading, to avoid unnecessary delays.
reworked network addresses to separate address family and connection type. this should make banning people more reliable, as well as simplifying a whole load of logic (no need to check for ipv4 AND ipv6).
tcpconnect will keep trying to connect even if the connection wasn't instant, instead of giving up instantly.
rewrote tcp connections quite a bit. sv_port_tcp now handles qtv+qizmo+http+ws+rtcbroker+tls equivalents.
qtv_streamport is now a legacy cvar and now acts equivalently to sv_port_tcp (but still separate).
rewrote screenshot and video capture code to use strides. this solves image-is-upside down issues with vulkan.
ignore alt key in browser port. oh no! no more red text! oh no! no more alt-being-wrongly-down-and-being-unable-to-type-anything-without-forcing-alt-released!
reworked audio decoder interface. now has clearly defined success/unavailable/end-of-file results. this should solve a whole load of issues with audio streaming.
fixed various openal audio streaming issues too. openal also got some workarounds for emscripten's poor emulation.
fixed ogg decoder to retain sync properly if seeked.
updated menu_media a bit. now reads vorbis comments/id3v1 tags to get proper track names. also saves the playlist so you don't have to manually repopulate the list so it might actually be usable now (after how many years?)
r_stains now defaults to 0, and is no longer enabled by presets. use decals if you want that sort of thing.
added fs_noreexec cvar, so configs will not be reexeced on gamedir change. this also means defaults won't be reapplied, etc.
added 'nvvk' renderer on windows, using nvidia's vulkan-inside-opengl gl extension. mostly just to see how much slower it is.
fixed up the ftp server quite a lot. more complete, more compliant, and should do ipv6 properly to-boot. file transfers also threaded.
fixed potential crash inside runclientphys.
experimental sv_antilag=3 setting. totally untested. the aim is to avoid missing due to lagged knockbacks. may be expensive for the server.
browser port's websockets support fixed. experimental support for webrtc ('works for me', requires a broker server).
updated avplug(renamed to ffmpeg so people know what it is) to use ffmpeg 3.2.4 properly, with its new encoder api. should be much more robust... also added experimental audio decoder for game music etc (currently doesn't resample, so playback rates are screwed, disabled by cvar).
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5097 fc73d0e0-1445-4013-8a0c-d673dee63da5
2017-05-10 02:08:58 +00:00
|
|
|
else
|
|
|
|
scache = NULL;
|
2004-08-23 00:15:46 +00:00
|
|
|
|
playdemo accepts https urls now. will start playing before the file has finished downloading, to avoid unnecessary delays.
reworked network addresses to separate address family and connection type. this should make banning people more reliable, as well as simplifying a whole load of logic (no need to check for ipv4 AND ipv6).
tcpconnect will keep trying to connect even if the connection wasn't instant, instead of giving up instantly.
rewrote tcp connections quite a bit. sv_port_tcp now handles qtv+qizmo+http+ws+rtcbroker+tls equivalents.
qtv_streamport is now a legacy cvar and now acts equivalently to sv_port_tcp (but still separate).
rewrote screenshot and video capture code to use strides. this solves image-is-upside down issues with vulkan.
ignore alt key in browser port. oh no! no more red text! oh no! no more alt-being-wrongly-down-and-being-unable-to-type-anything-without-forcing-alt-released!
reworked audio decoder interface. now has clearly defined success/unavailable/end-of-file results. this should solve a whole load of issues with audio streaming.
fixed various openal audio streaming issues too. openal also got some workarounds for emscripten's poor emulation.
fixed ogg decoder to retain sync properly if seeked.
updated menu_media a bit. now reads vorbis comments/id3v1 tags to get proper track names. also saves the playlist so you don't have to manually repopulate the list so it might actually be usable now (after how many years?)
r_stains now defaults to 0, and is no longer enabled by presets. use decals if you want that sort of thing.
added fs_noreexec cvar, so configs will not be reexeced on gamedir change. this also means defaults won't be reapplied, etc.
added 'nvvk' renderer on windows, using nvidia's vulkan-inside-opengl gl extension. mostly just to see how much slower it is.
fixed up the ftp server quite a lot. more complete, more compliant, and should do ipv6 properly to-boot. file transfers also threaded.
fixed potential crash inside runclientphys.
experimental sv_antilag=3 setting. totally untested. the aim is to avoid missing due to lagged knockbacks. may be expensive for the server.
browser port's websockets support fixed. experimental support for webrtc ('works for me', requires a broker server).
updated avplug(renamed to ffmpeg so people know what it is) to use ffmpeg 3.2.4 properly, with its new encoder api. should be much more robust... also added experimental audio decoder for game music etc (currently doesn't resample, so playback rates are screwed, disabled by cvar).
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5097 fc73d0e0-1445-4013-8a0c-d673dee63da5
2017-05-10 02:08:58 +00:00
|
|
|
if (!scache)
|
|
|
|
{ //hit eof, loop it or stop it
|
|
|
|
if (s->loopstart != -1) /*some wavs contain a loop offset directly in the sound file, such samples loop even if a non-looping builtin was used*/
|
|
|
|
{
|
2018-06-18 16:44:29 +00:00
|
|
|
ch->pos &= ~((~0u)<<PITCHSHIFT); /*clear out all but the subsample offset*/
|
playdemo accepts https urls now. will start playing before the file has finished downloading, to avoid unnecessary delays.
reworked network addresses to separate address family and connection type. this should make banning people more reliable, as well as simplifying a whole load of logic (no need to check for ipv4 AND ipv6).
tcpconnect will keep trying to connect even if the connection wasn't instant, instead of giving up instantly.
rewrote tcp connections quite a bit. sv_port_tcp now handles qtv+qizmo+http+ws+rtcbroker+tls equivalents.
qtv_streamport is now a legacy cvar and now acts equivalently to sv_port_tcp (but still separate).
rewrote screenshot and video capture code to use strides. this solves image-is-upside down issues with vulkan.
ignore alt key in browser port. oh no! no more red text! oh no! no more alt-being-wrongly-down-and-being-unable-to-type-anything-without-forcing-alt-released!
reworked audio decoder interface. now has clearly defined success/unavailable/end-of-file results. this should solve a whole load of issues with audio streaming.
fixed various openal audio streaming issues too. openal also got some workarounds for emscripten's poor emulation.
fixed ogg decoder to retain sync properly if seeked.
updated menu_media a bit. now reads vorbis comments/id3v1 tags to get proper track names. also saves the playlist so you don't have to manually repopulate the list so it might actually be usable now (after how many years?)
r_stains now defaults to 0, and is no longer enabled by presets. use decals if you want that sort of thing.
added fs_noreexec cvar, so configs will not be reexeced on gamedir change. this also means defaults won't be reapplied, etc.
added 'nvvk' renderer on windows, using nvidia's vulkan-inside-opengl gl extension. mostly just to see how much slower it is.
fixed up the ftp server quite a lot. more complete, more compliant, and should do ipv6 properly to-boot. file transfers also threaded.
fixed potential crash inside runclientphys.
experimental sv_antilag=3 setting. totally untested. the aim is to avoid missing due to lagged knockbacks. may be expensive for the server.
browser port's websockets support fixed. experimental support for webrtc ('works for me', requires a broker server).
updated avplug(renamed to ffmpeg so people know what it is) to use ffmpeg 3.2.4 properly, with its new encoder api. should be much more robust... also added experimental audio decoder for game music etc (currently doesn't resample, so playback rates are screwed, disabled by cvar).
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5097 fc73d0e0-1445-4013-8a0c-d673dee63da5
2017-05-10 02:08:58 +00:00
|
|
|
ch->pos += s->loopstart<<PITCHSHIFT; //ignore the offset if its off the end of the file
|
|
|
|
}
|
|
|
|
else if (ch->flags & CF_FORCELOOP) /*(static)channels which are explicitly looping always loop from the start*/
|
|
|
|
{
|
|
|
|
/*restart it*/
|
|
|
|
ch->pos = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{ // channel just stopped
|
|
|
|
ch->sfx = NULL;
|
|
|
|
if (s->decoder.ended)
|
|
|
|
{
|
|
|
|
if (!S_IsPlayingSomewhere(s))
|
|
|
|
s->decoder.ended(s);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
//retry at that new offset (continue here could give an infinite loop)
|
|
|
|
spos = ch->pos>>PITCHSHIFT;
|
|
|
|
if (s->decoder.decodedata)
|
|
|
|
scache = s->decoder.decodedata(s, &scachebuf, spos, 1 + (((end - ltime) * ch->rate)>>PITCHSHIFT)); /*1 for luck - balances audio termination below*/
|
|
|
|
else if (s->decoder.buf)
|
|
|
|
{
|
|
|
|
scache = s->decoder.buf;
|
|
|
|
if (spos >= scache->length)
|
|
|
|
scache = NULL; //EOF
|
|
|
|
}
|
|
|
|
else
|
|
|
|
scache = NULL;
|
2004-08-23 00:15:46 +00:00
|
|
|
|
playdemo accepts https urls now. will start playing before the file has finished downloading, to avoid unnecessary delays.
reworked network addresses to separate address family and connection type. this should make banning people more reliable, as well as simplifying a whole load of logic (no need to check for ipv4 AND ipv6).
tcpconnect will keep trying to connect even if the connection wasn't instant, instead of giving up instantly.
rewrote tcp connections quite a bit. sv_port_tcp now handles qtv+qizmo+http+ws+rtcbroker+tls equivalents.
qtv_streamport is now a legacy cvar and now acts equivalently to sv_port_tcp (but still separate).
rewrote screenshot and video capture code to use strides. this solves image-is-upside down issues with vulkan.
ignore alt key in browser port. oh no! no more red text! oh no! no more alt-being-wrongly-down-and-being-unable-to-type-anything-without-forcing-alt-released!
reworked audio decoder interface. now has clearly defined success/unavailable/end-of-file results. this should solve a whole load of issues with audio streaming.
fixed various openal audio streaming issues too. openal also got some workarounds for emscripten's poor emulation.
fixed ogg decoder to retain sync properly if seeked.
updated menu_media a bit. now reads vorbis comments/id3v1 tags to get proper track names. also saves the playlist so you don't have to manually repopulate the list so it might actually be usable now (after how many years?)
r_stains now defaults to 0, and is no longer enabled by presets. use decals if you want that sort of thing.
added fs_noreexec cvar, so configs will not be reexeced on gamedir change. this also means defaults won't be reapplied, etc.
added 'nvvk' renderer on windows, using nvidia's vulkan-inside-opengl gl extension. mostly just to see how much slower it is.
fixed up the ftp server quite a lot. more complete, more compliant, and should do ipv6 properly to-boot. file transfers also threaded.
fixed potential crash inside runclientphys.
experimental sv_antilag=3 setting. totally untested. the aim is to avoid missing due to lagged knockbacks. may be expensive for the server.
browser port's websockets support fixed. experimental support for webrtc ('works for me', requires a broker server).
updated avplug(renamed to ffmpeg so people know what it is) to use ffmpeg 3.2.4 properly, with its new encoder api. should be much more robust... also added experimental audio decoder for game music etc (currently doesn't resample, so playback rates are screwed, disabled by cvar).
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5097 fc73d0e0-1445-4013-8a0c-d673dee63da5
2017-05-10 02:08:58 +00:00
|
|
|
if (!scache)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (spos < scache->soundoffset || spos > scache->soundoffset+scache->length)
|
|
|
|
avail = 0; //urm, we would be trying to read outside of the buffer. let mixing slip when there's no data available yet.
|
|
|
|
else
|
2012-02-27 12:23:15 +00:00
|
|
|
{
|
playdemo accepts https urls now. will start playing before the file has finished downloading, to avoid unnecessary delays.
reworked network addresses to separate address family and connection type. this should make banning people more reliable, as well as simplifying a whole load of logic (no need to check for ipv4 AND ipv6).
tcpconnect will keep trying to connect even if the connection wasn't instant, instead of giving up instantly.
rewrote tcp connections quite a bit. sv_port_tcp now handles qtv+qizmo+http+ws+rtcbroker+tls equivalents.
qtv_streamport is now a legacy cvar and now acts equivalently to sv_port_tcp (but still separate).
rewrote screenshot and video capture code to use strides. this solves image-is-upside down issues with vulkan.
ignore alt key in browser port. oh no! no more red text! oh no! no more alt-being-wrongly-down-and-being-unable-to-type-anything-without-forcing-alt-released!
reworked audio decoder interface. now has clearly defined success/unavailable/end-of-file results. this should solve a whole load of issues with audio streaming.
fixed various openal audio streaming issues too. openal also got some workarounds for emscripten's poor emulation.
fixed ogg decoder to retain sync properly if seeked.
updated menu_media a bit. now reads vorbis comments/id3v1 tags to get proper track names. also saves the playlist so you don't have to manually repopulate the list so it might actually be usable now (after how many years?)
r_stains now defaults to 0, and is no longer enabled by presets. use decals if you want that sort of thing.
added fs_noreexec cvar, so configs will not be reexeced on gamedir change. this also means defaults won't be reapplied, etc.
added 'nvvk' renderer on windows, using nvidia's vulkan-inside-opengl gl extension. mostly just to see how much slower it is.
fixed up the ftp server quite a lot. more complete, more compliant, and should do ipv6 properly to-boot. file transfers also threaded.
fixed potential crash inside runclientphys.
experimental sv_antilag=3 setting. totally untested. the aim is to avoid missing due to lagged knockbacks. may be expensive for the server.
browser port's websockets support fixed. experimental support for webrtc ('works for me', requires a broker server).
updated avplug(renamed to ffmpeg so people know what it is) to use ffmpeg 3.2.4 properly, with its new encoder api. should be much more robust... also added experimental audio decoder for game music etc (currently doesn't resample, so playback rates are screwed, disabled by cvar).
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5097 fc73d0e0-1445-4013-8a0c-d673dee63da5
2017-05-10 02:08:58 +00:00
|
|
|
// find how many samples till the sample ends (clamp max length)
|
|
|
|
avail = scache->length;
|
|
|
|
if (avail > maxlen)
|
|
|
|
avail = snd_speed*10;
|
2017-12-03 03:03:02 +00:00
|
|
|
avail = (((int)(scache->soundoffset + avail)<<PITCHSHIFT) - ch->pos + (ch->rate-1)) / ch->rate;
|
2012-02-27 12:23:15 +00:00
|
|
|
}
|
playdemo accepts https urls now. will start playing before the file has finished downloading, to avoid unnecessary delays.
reworked network addresses to separate address family and connection type. this should make banning people more reliable, as well as simplifying a whole load of logic (no need to check for ipv4 AND ipv6).
tcpconnect will keep trying to connect even if the connection wasn't instant, instead of giving up instantly.
rewrote tcp connections quite a bit. sv_port_tcp now handles qtv+qizmo+http+ws+rtcbroker+tls equivalents.
qtv_streamport is now a legacy cvar and now acts equivalently to sv_port_tcp (but still separate).
rewrote screenshot and video capture code to use strides. this solves image-is-upside down issues with vulkan.
ignore alt key in browser port. oh no! no more red text! oh no! no more alt-being-wrongly-down-and-being-unable-to-type-anything-without-forcing-alt-released!
reworked audio decoder interface. now has clearly defined success/unavailable/end-of-file results. this should solve a whole load of issues with audio streaming.
fixed various openal audio streaming issues too. openal also got some workarounds for emscripten's poor emulation.
fixed ogg decoder to retain sync properly if seeked.
updated menu_media a bit. now reads vorbis comments/id3v1 tags to get proper track names. also saves the playlist so you don't have to manually repopulate the list so it might actually be usable now (after how many years?)
r_stains now defaults to 0, and is no longer enabled by presets. use decals if you want that sort of thing.
added fs_noreexec cvar, so configs will not be reexeced on gamedir change. this also means defaults won't be reapplied, etc.
added 'nvvk' renderer on windows, using nvidia's vulkan-inside-opengl gl extension. mostly just to see how much slower it is.
fixed up the ftp server quite a lot. more complete, more compliant, and should do ipv6 properly to-boot. file transfers also threaded.
fixed potential crash inside runclientphys.
experimental sv_antilag=3 setting. totally untested. the aim is to avoid missing due to lagged knockbacks. may be expensive for the server.
browser port's websockets support fixed. experimental support for webrtc ('works for me', requires a broker server).
updated avplug(renamed to ffmpeg so people know what it is) to use ffmpeg 3.2.4 properly, with its new encoder api. should be much more robust... also added experimental audio decoder for game music etc (currently doesn't resample, so playback rates are screwed, disabled by cvar).
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5097 fc73d0e0-1445-4013-8a0c-d673dee63da5
2017-05-10 02:08:58 +00:00
|
|
|
// mix the smaller of how much is available or the time left
|
|
|
|
count = min(avail, end - ltime);
|
2010-11-06 23:05:29 +00:00
|
|
|
|
2004-08-23 00:15:46 +00:00
|
|
|
if (count > 0)
|
2011-05-29 04:26:29 +00:00
|
|
|
{
|
2012-02-27 12:23:15 +00:00
|
|
|
if (ch->pos < 0) //sounds with a pos of 0 are delay-start sounds
|
2004-08-23 00:15:46 +00:00
|
|
|
{
|
2012-02-27 12:23:15 +00:00
|
|
|
//don't progress past 0, so it actually starts properly at the right time with no clicks or anything
|
|
|
|
if (count > (-ch->pos+255)>>PITCHSHIFT)
|
|
|
|
count = ((-ch->pos+255)>>PITCHSHIFT);
|
2004-08-23 00:15:46 +00:00
|
|
|
ltime += count;
|
2010-11-06 23:05:29 +00:00
|
|
|
ch->pos += count*ch->rate;
|
2004-08-23 00:15:46 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2006-05-08 21:02:39 +00:00
|
|
|
if (scache->width == 1)
|
2011-05-29 04:26:29 +00:00
|
|
|
{
|
2006-05-08 21:02:39 +00:00
|
|
|
if (scache->numchannels==2)
|
2014-02-07 08:38:40 +00:00
|
|
|
SND_PaintChannel8_O2I2(ch, scache, ltime-sc->paintedtime, count);
|
|
|
|
else if (sc->sn.numchannels <= 2)
|
|
|
|
SND_PaintChannel8_O2I1(ch, scache, ltime-sc->paintedtime, count);
|
|
|
|
else if (sc->sn.numchannels <= 4)
|
|
|
|
SND_PaintChannel8_O4I1(ch, scache, count);
|
|
|
|
else if (sc->sn.numchannels <= 6)
|
|
|
|
SND_PaintChannel8_O6I1(ch, scache, count);
|
2011-05-29 04:26:29 +00:00
|
|
|
else
|
2014-02-07 08:38:40 +00:00
|
|
|
SND_PaintChannel8_O8I1(ch, scache, count);
|
2006-05-08 21:02:39 +00:00
|
|
|
}
|
2015-04-21 04:12:00 +00:00
|
|
|
else if (scache->width == 2)
|
2004-08-23 00:15:46 +00:00
|
|
|
{
|
2006-05-08 21:02:39 +00:00
|
|
|
if (scache->numchannels==2)
|
2014-02-07 08:38:40 +00:00
|
|
|
SND_PaintChannel16_O2I2(ch, scache, ltime-sc->paintedtime, count);
|
|
|
|
else if (sc->sn.numchannels <= 2)
|
|
|
|
SND_PaintChannel16_O2I1(ch, scache, ltime-sc->paintedtime, count);
|
|
|
|
else if (sc->sn.numchannels <= 4)
|
|
|
|
SND_PaintChannel16_O4I1(ch, scache, count);
|
|
|
|
else if (sc->sn.numchannels <= 6)
|
|
|
|
SND_PaintChannel16_O6I1(ch, scache, count);
|
2004-08-23 00:15:46 +00:00
|
|
|
else
|
2014-02-07 08:38:40 +00:00
|
|
|
SND_PaintChannel16_O8I1(ch, scache, count);
|
2004-08-23 00:15:46 +00:00
|
|
|
}
|
|
|
|
ltime += count;
|
2012-02-27 12:23:15 +00:00
|
|
|
ch->pos += ch->rate * count;
|
2004-08-23 00:15:46 +00:00
|
|
|
}
|
playdemo accepts https urls now. will start playing before the file has finished downloading, to avoid unnecessary delays.
reworked network addresses to separate address family and connection type. this should make banning people more reliable, as well as simplifying a whole load of logic (no need to check for ipv4 AND ipv6).
tcpconnect will keep trying to connect even if the connection wasn't instant, instead of giving up instantly.
rewrote tcp connections quite a bit. sv_port_tcp now handles qtv+qizmo+http+ws+rtcbroker+tls equivalents.
qtv_streamport is now a legacy cvar and now acts equivalently to sv_port_tcp (but still separate).
rewrote screenshot and video capture code to use strides. this solves image-is-upside down issues with vulkan.
ignore alt key in browser port. oh no! no more red text! oh no! no more alt-being-wrongly-down-and-being-unable-to-type-anything-without-forcing-alt-released!
reworked audio decoder interface. now has clearly defined success/unavailable/end-of-file results. this should solve a whole load of issues with audio streaming.
fixed various openal audio streaming issues too. openal also got some workarounds for emscripten's poor emulation.
fixed ogg decoder to retain sync properly if seeked.
updated menu_media a bit. now reads vorbis comments/id3v1 tags to get proper track names. also saves the playlist so you don't have to manually repopulate the list so it might actually be usable now (after how many years?)
r_stains now defaults to 0, and is no longer enabled by presets. use decals if you want that sort of thing.
added fs_noreexec cvar, so configs will not be reexeced on gamedir change. this also means defaults won't be reapplied, etc.
added 'nvvk' renderer on windows, using nvidia's vulkan-inside-opengl gl extension. mostly just to see how much slower it is.
fixed up the ftp server quite a lot. more complete, more compliant, and should do ipv6 properly to-boot. file transfers also threaded.
fixed potential crash inside runclientphys.
experimental sv_antilag=3 setting. totally untested. the aim is to avoid missing due to lagged knockbacks. may be expensive for the server.
browser port's websockets support fixed. experimental support for webrtc ('works for me', requires a broker server).
updated avplug(renamed to ffmpeg so people know what it is) to use ffmpeg 3.2.4 properly, with its new encoder api. should be much more robust... also added experimental audio decoder for game music etc (currently doesn't resample, so playback rates are screwed, disabled by cvar).
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5097 fc73d0e0-1445-4013-8a0c-d673dee63da5
2017-05-10 02:08:58 +00:00
|
|
|
else
|
|
|
|
break;
|
2011-05-29 04:26:29 +00:00
|
|
|
}
|
2004-08-23 00:15:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// transfer out according to DMA format
|
|
|
|
S_TransferPaintBuffer(sc, end);
|
|
|
|
sc->paintedtime = end;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-02-07 08:38:40 +00:00
|
|
|
static void SND_PaintChannel8_O2I1 (channel_t *ch, sfxcache_t *sc, int starttime, int count)
|
2004-08-23 00:15:46 +00:00
|
|
|
{
|
|
|
|
int data;
|
2006-05-08 21:02:39 +00:00
|
|
|
signed char *sfx;
|
2004-08-23 00:15:46 +00:00
|
|
|
int i;
|
2012-02-27 12:23:15 +00:00
|
|
|
unsigned int pos = ch->pos-(sc->soundoffset<<PITCHSHIFT);
|
2004-08-23 00:15:46 +00:00
|
|
|
|
2010-11-06 23:05:29 +00:00
|
|
|
if (ch->rate != (1<<PITCHSHIFT))
|
2004-08-23 00:15:46 +00:00
|
|
|
{
|
2010-11-06 23:05:29 +00:00
|
|
|
sfx = (signed char *)sc->data;
|
|
|
|
for (i=0 ; i<count ; i++)
|
|
|
|
{
|
2012-02-27 12:23:15 +00:00
|
|
|
data = sfx[pos>>PITCHSHIFT];
|
|
|
|
pos += ch->rate;
|
2014-02-07 08:38:40 +00:00
|
|
|
paintbuffer[starttime+i].s[0] += ch->vol[0] * data;
|
|
|
|
paintbuffer[starttime+i].s[1] += ch->vol[1] * data;
|
2010-11-06 23:05:29 +00:00
|
|
|
}
|
2004-08-23 00:15:46 +00:00
|
|
|
}
|
2010-11-06 23:05:29 +00:00
|
|
|
else
|
2004-08-23 00:15:46 +00:00
|
|
|
{
|
2012-02-27 12:23:15 +00:00
|
|
|
sfx = (signed char *)sc->data + (pos>>PITCHSHIFT);
|
2010-11-06 23:05:29 +00:00
|
|
|
for (i=0 ; i<count ; i++)
|
|
|
|
{
|
|
|
|
data = sfx[i];
|
2014-02-07 08:38:40 +00:00
|
|
|
paintbuffer[starttime+i].s[0] += ch->vol[0] * data;
|
|
|
|
paintbuffer[starttime+i].s[1] += ch->vol[1] * data;
|
2010-11-06 23:05:29 +00:00
|
|
|
}
|
2004-08-23 00:15:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-02-07 08:38:40 +00:00
|
|
|
static void SND_PaintChannel8_O2I2 (channel_t *ch, sfxcache_t *sc, int starttime, int count)
|
2004-08-23 00:15:46 +00:00
|
|
|
{
|
|
|
|
// int data;
|
2006-05-08 21:02:39 +00:00
|
|
|
signed char *sfx;
|
2004-08-23 00:15:46 +00:00
|
|
|
int i;
|
2012-02-27 12:23:15 +00:00
|
|
|
unsigned int pos = ch->pos-(sc->soundoffset<<PITCHSHIFT);
|
2004-08-23 00:15:46 +00:00
|
|
|
|
2010-11-06 23:05:29 +00:00
|
|
|
if (ch->rate != (1<<PITCHSHIFT))
|
|
|
|
{
|
|
|
|
sfx = (signed char *)sc->data;
|
|
|
|
for (i=0 ; i<count ; i++)
|
|
|
|
{
|
2014-02-07 08:38:40 +00:00
|
|
|
paintbuffer[starttime+i].s[0] += ch->vol[0] * sfx[(pos>>(PITCHSHIFT-1))&~1];
|
|
|
|
paintbuffer[starttime+i].s[1] += ch->vol[1] * sfx[(pos>>(PITCHSHIFT-1))|1];
|
2012-02-27 12:23:15 +00:00
|
|
|
pos += ch->rate;
|
2010-11-06 23:05:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-02-27 12:23:15 +00:00
|
|
|
sfx = (signed char *)sc->data + (pos>>PITCHSHIFT)*2;
|
2010-11-06 23:05:29 +00:00
|
|
|
for (i=0 ; i<count ; i++)
|
2011-05-29 04:26:29 +00:00
|
|
|
{
|
2014-02-07 08:38:40 +00:00
|
|
|
paintbuffer[starttime+i].s[0] += ch->vol[0] * sfx[(i<<1)];
|
|
|
|
paintbuffer[starttime+i].s[1] += ch->vol[1] * sfx[(i<<1)+1];
|
2010-11-06 23:05:29 +00:00
|
|
|
}
|
2004-08-23 00:15:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-02-07 08:38:40 +00:00
|
|
|
static void SND_PaintChannel8_O4I1 (channel_t *ch, sfxcache_t *sc, int count)
|
2004-08-23 00:15:46 +00:00
|
|
|
{
|
2006-05-08 21:02:39 +00:00
|
|
|
signed char *sfx;
|
2004-08-23 00:15:46 +00:00
|
|
|
int i;
|
2012-02-27 12:23:15 +00:00
|
|
|
unsigned int pos = ch->pos-(sc->soundoffset<<PITCHSHIFT);
|
2004-08-23 00:15:46 +00:00
|
|
|
|
2010-11-06 23:05:29 +00:00
|
|
|
if (ch->rate != (1<<PITCHSHIFT))
|
2004-08-23 00:15:46 +00:00
|
|
|
{
|
2010-11-06 23:05:29 +00:00
|
|
|
signed char data;
|
|
|
|
sfx = (signed char *)sc->data;
|
|
|
|
for (i=0 ; i<count ; i++)
|
|
|
|
{
|
2012-02-27 12:23:15 +00:00
|
|
|
data = sfx[pos>>PITCHSHIFT];
|
|
|
|
pos += ch->rate;
|
2010-11-06 23:05:29 +00:00
|
|
|
paintbuffer[i].s[0] += ch->vol[0] * data;
|
|
|
|
paintbuffer[i].s[1] += ch->vol[1] * data;
|
|
|
|
paintbuffer[i].s[2] += ch->vol[2] * data;
|
|
|
|
paintbuffer[i].s[3] += ch->vol[3] * data;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-02-27 12:23:15 +00:00
|
|
|
sfx = (signed char *)sc->data + (pos>>PITCHSHIFT);
|
2010-11-06 23:05:29 +00:00
|
|
|
for (i=0 ; i<count ; i++)
|
|
|
|
{
|
|
|
|
paintbuffer[i].s[0] += ch->vol[0] * sfx[i];
|
|
|
|
paintbuffer[i].s[1] += ch->vol[1] * sfx[i];
|
|
|
|
paintbuffer[i].s[2] += ch->vol[2] * sfx[i];
|
|
|
|
paintbuffer[i].s[3] += ch->vol[3] * sfx[i];
|
|
|
|
}
|
2004-08-23 00:15:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-02-07 08:38:40 +00:00
|
|
|
static void SND_PaintChannel8_O6I1 (channel_t *ch, sfxcache_t *sc, int count)
|
2004-08-23 00:15:46 +00:00
|
|
|
{
|
2006-05-08 21:02:39 +00:00
|
|
|
signed char *sfx;
|
2004-08-23 00:15:46 +00:00
|
|
|
int i;
|
2012-02-27 12:23:15 +00:00
|
|
|
unsigned int pos = ch->pos-(sc->soundoffset<<PITCHSHIFT);
|
2004-08-23 00:15:46 +00:00
|
|
|
|
2010-11-06 23:05:29 +00:00
|
|
|
if (ch->rate != (1<<PITCHSHIFT))
|
|
|
|
{
|
|
|
|
signed char data;
|
|
|
|
sfx = (signed char *)sc->data;
|
|
|
|
for (i=0 ; i<count ; i++)
|
|
|
|
{
|
2012-02-27 12:23:15 +00:00
|
|
|
data = sfx[pos>>PITCHSHIFT];
|
|
|
|
pos += ch->rate;
|
2010-11-06 23:05:29 +00:00
|
|
|
paintbuffer[i].s[0] += ch->vol[0] * data;
|
|
|
|
paintbuffer[i].s[1] += ch->vol[1] * data;
|
|
|
|
paintbuffer[i].s[2] += ch->vol[2] * data;
|
|
|
|
paintbuffer[i].s[3] += ch->vol[3] * data;
|
|
|
|
paintbuffer[i].s[4] += ch->vol[4] * data;
|
|
|
|
paintbuffer[i].s[5] += ch->vol[5] * data;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-02-27 12:23:15 +00:00
|
|
|
sfx = (signed char *)sc->data + (pos>>PITCHSHIFT);
|
2010-11-06 23:05:29 +00:00
|
|
|
for (i=0 ; i<count ; i++)
|
2011-05-29 04:26:29 +00:00
|
|
|
{
|
2010-11-06 23:05:29 +00:00
|
|
|
paintbuffer[i].s[0] += ch->vol[0] * sfx[i];
|
|
|
|
paintbuffer[i].s[1] += ch->vol[1] * sfx[i];
|
2011-05-29 04:26:29 +00:00
|
|
|
paintbuffer[i].s[2] += ch->vol[2] * sfx[i];
|
2010-11-06 23:05:29 +00:00
|
|
|
paintbuffer[i].s[3] += ch->vol[3] * sfx[i];
|
2011-05-29 04:26:29 +00:00
|
|
|
paintbuffer[i].s[4] += ch->vol[4] * sfx[i];
|
2010-11-06 23:05:29 +00:00
|
|
|
paintbuffer[i].s[5] += ch->vol[5] * sfx[i];
|
|
|
|
}
|
2004-08-23 00:15:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-02-07 08:38:40 +00:00
|
|
|
static void SND_PaintChannel8_O8I1 (channel_t *ch, sfxcache_t *sc, int count)
|
2011-07-06 05:53:25 +00:00
|
|
|
{
|
|
|
|
signed char *sfx;
|
|
|
|
int i;
|
2012-02-27 12:23:15 +00:00
|
|
|
unsigned int pos = ch->pos-(sc->soundoffset<<PITCHSHIFT);
|
2011-07-06 05:53:25 +00:00
|
|
|
|
|
|
|
if (ch->rate != (1<<PITCHSHIFT))
|
|
|
|
{
|
|
|
|
signed char data;
|
|
|
|
sfx = (signed char *)sc->data;
|
|
|
|
for (i=0 ; i<count ; i++)
|
|
|
|
{
|
2012-02-27 12:23:15 +00:00
|
|
|
data = sfx[pos>>PITCHSHIFT];
|
|
|
|
pos += ch->rate;
|
2011-07-06 05:53:25 +00:00
|
|
|
paintbuffer[i].s[0] += ch->vol[0] * data;
|
|
|
|
paintbuffer[i].s[1] += ch->vol[1] * data;
|
|
|
|
paintbuffer[i].s[2] += ch->vol[2] * data;
|
|
|
|
paintbuffer[i].s[3] += ch->vol[3] * data;
|
|
|
|
paintbuffer[i].s[4] += ch->vol[4] * data;
|
|
|
|
paintbuffer[i].s[5] += ch->vol[5] * data;
|
|
|
|
paintbuffer[i].s[6] += ch->vol[6] * data;
|
|
|
|
paintbuffer[i].s[7] += ch->vol[7] * data;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-02-27 12:23:15 +00:00
|
|
|
sfx = (signed char *)sc->data + (pos>>PITCHSHIFT);
|
2011-07-06 05:53:25 +00:00
|
|
|
for (i=0 ; i<count ; i++)
|
|
|
|
{
|
|
|
|
paintbuffer[i].s[0] += ch->vol[0] * sfx[i];
|
|
|
|
paintbuffer[i].s[1] += ch->vol[1] * sfx[i];
|
|
|
|
paintbuffer[i].s[2] += ch->vol[2] * sfx[i];
|
|
|
|
paintbuffer[i].s[3] += ch->vol[3] * sfx[i];
|
|
|
|
paintbuffer[i].s[4] += ch->vol[4] * sfx[i];
|
|
|
|
paintbuffer[i].s[5] += ch->vol[5] * sfx[i];
|
|
|
|
paintbuffer[i].s[6] += ch->vol[6] * sfx[i];
|
|
|
|
paintbuffer[i].s[7] += ch->vol[7] * sfx[i];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2004-08-23 00:15:46 +00:00
|
|
|
|
|
|
|
|
2014-02-07 08:38:40 +00:00
|
|
|
static void SND_PaintChannel16_O2I1 (channel_t *ch, sfxcache_t *sc, int starttime, int count)
|
2004-08-23 00:15:46 +00:00
|
|
|
{
|
|
|
|
int data;
|
|
|
|
int left, right;
|
|
|
|
int leftvol, rightvol;
|
|
|
|
signed short *sfx;
|
|
|
|
int i;
|
2012-02-27 12:23:15 +00:00
|
|
|
unsigned int pos = ch->pos-(sc->soundoffset<<PITCHSHIFT);
|
2004-08-23 00:15:46 +00:00
|
|
|
|
|
|
|
leftvol = ch->vol[0];
|
|
|
|
rightvol = ch->vol[1];
|
|
|
|
|
2010-11-06 23:05:29 +00:00
|
|
|
if (ch->rate != (1<<PITCHSHIFT))
|
2004-08-23 00:15:46 +00:00
|
|
|
{
|
2010-11-06 23:05:29 +00:00
|
|
|
signed short data;
|
|
|
|
sfx = (signed short *)sc->data;
|
|
|
|
for (i=0 ; i<count ; i++)
|
|
|
|
{
|
2016-07-12 00:40:13 +00:00
|
|
|
float frac = pos&((1<<PITCHSHIFT)-1);
|
|
|
|
data = sfx[pos>>PITCHSHIFT] * (1-frac) + sfx[(pos>>PITCHSHIFT)+1] * frac;
|
2012-02-27 12:23:15 +00:00
|
|
|
pos += ch->rate;
|
2014-02-07 08:38:40 +00:00
|
|
|
paintbuffer[starttime+i].s[0] += (leftvol * data)>>8;
|
|
|
|
paintbuffer[starttime+i].s[1] += (rightvol * data)>>8;
|
2010-11-06 23:05:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-02-27 12:23:15 +00:00
|
|
|
sfx = (signed short *)sc->data + (pos>>PITCHSHIFT);
|
2010-11-06 23:05:29 +00:00
|
|
|
for (i=0 ; i<count ; i++)
|
|
|
|
{
|
|
|
|
data = sfx[i];
|
|
|
|
left = (data * leftvol) >> 8;
|
|
|
|
right = (data * rightvol) >> 8;
|
2014-02-07 08:38:40 +00:00
|
|
|
paintbuffer[starttime+i].s[0] += left;
|
|
|
|
paintbuffer[starttime+i].s[1] += right;
|
2010-11-06 23:05:29 +00:00
|
|
|
}
|
2004-08-23 00:15:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-02-07 08:38:40 +00:00
|
|
|
static void SND_PaintChannel16_O2I2 (channel_t *ch, sfxcache_t *sc, int starttime, int count)
|
2004-08-23 00:15:46 +00:00
|
|
|
{
|
|
|
|
int leftvol, rightvol;
|
|
|
|
signed short *sfx;
|
|
|
|
int i;
|
2012-02-27 12:23:15 +00:00
|
|
|
unsigned int pos = ch->pos-(sc->soundoffset<<PITCHSHIFT);
|
2004-08-23 00:15:46 +00:00
|
|
|
|
|
|
|
leftvol = ch->vol[0];
|
|
|
|
rightvol = ch->vol[1];
|
|
|
|
|
2010-11-06 23:05:29 +00:00
|
|
|
if (ch->rate != (1<<PITCHSHIFT))
|
2004-08-23 00:15:46 +00:00
|
|
|
{
|
2010-11-06 23:05:29 +00:00
|
|
|
signed short l, r;
|
|
|
|
sfx = (signed short *)sc->data;
|
|
|
|
for (i=0 ; i<count ; i++)
|
|
|
|
{
|
2012-02-27 12:23:15 +00:00
|
|
|
l = sfx[(pos>>(PITCHSHIFT-1))&~1];
|
|
|
|
r = sfx[(pos>>(PITCHSHIFT-1))|1];
|
|
|
|
pos += ch->rate;
|
2014-02-07 08:38:40 +00:00
|
|
|
paintbuffer[starttime+i].s[0] += (ch->vol[0] * l)>>8;
|
|
|
|
paintbuffer[starttime+i].s[1] += (ch->vol[1] * r)>>8;
|
2010-11-06 23:05:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-02-27 12:23:15 +00:00
|
|
|
sfx = (signed short *)sc->data + (pos>>PITCHSHIFT)*2;
|
2010-11-06 23:05:29 +00:00
|
|
|
for (i=0 ; i<count ; i++)
|
|
|
|
{
|
2014-02-07 08:38:40 +00:00
|
|
|
paintbuffer[starttime+i].s[0] += (*sfx++ * leftvol) >> 8;
|
|
|
|
paintbuffer[starttime+i].s[1] += (*sfx++ * rightvol) >> 8;
|
2010-11-06 23:05:29 +00:00
|
|
|
}
|
2004-08-23 00:15:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-02-07 08:38:40 +00:00
|
|
|
static void SND_PaintChannel16_O4I1 (channel_t *ch, sfxcache_t *sc, int count)
|
2011-07-06 05:53:25 +00:00
|
|
|
{
|
|
|
|
int vol[4];
|
|
|
|
signed short *sfx;
|
|
|
|
int i;
|
2012-02-27 12:23:15 +00:00
|
|
|
unsigned int pos = ch->pos-(sc->soundoffset<<PITCHSHIFT);
|
2011-07-06 05:53:25 +00:00
|
|
|
|
|
|
|
vol[0] = ch->vol[0];
|
|
|
|
vol[1] = ch->vol[1];
|
|
|
|
vol[2] = ch->vol[2];
|
|
|
|
vol[3] = ch->vol[3];
|
|
|
|
|
|
|
|
if (ch->rate != (1<<PITCHSHIFT))
|
|
|
|
{
|
|
|
|
signed short data;
|
|
|
|
sfx = (signed short *)sc->data;
|
|
|
|
for (i=0 ; i<count ; i++)
|
|
|
|
{
|
2012-02-27 12:23:15 +00:00
|
|
|
data = sfx[pos>>PITCHSHIFT];
|
|
|
|
pos += ch->rate;
|
2011-07-06 05:53:25 +00:00
|
|
|
paintbuffer[i].s[0] += (vol[0] * data)>>8;
|
|
|
|
paintbuffer[i].s[1] += (vol[1] * data)>>8;
|
|
|
|
paintbuffer[i].s[2] += (vol[2] * data)>>8;
|
|
|
|
paintbuffer[i].s[3] += (vol[3] * data)>>8;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-02-27 12:23:15 +00:00
|
|
|
sfx = (signed short *)sc->data + pos;
|
2011-07-06 05:53:25 +00:00
|
|
|
for (i=0 ; i<count ; i++)
|
|
|
|
{
|
|
|
|
paintbuffer[i].s[0] += (sfx[i] * vol[0]) >> 8;
|
|
|
|
paintbuffer[i].s[1] += (sfx[i] * vol[1]) >> 8;
|
|
|
|
paintbuffer[i].s[2] += (sfx[i] * vol[2]) >> 8;
|
|
|
|
paintbuffer[i].s[3] += (sfx[i] * vol[3]) >> 8;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-02-07 08:38:40 +00:00
|
|
|
static void SND_PaintChannel16_O6I1 (channel_t *ch, sfxcache_t *sc, int count)
|
2004-08-23 00:15:46 +00:00
|
|
|
{
|
|
|
|
int vol[6];
|
|
|
|
signed short *sfx;
|
|
|
|
int i;
|
2012-02-27 12:23:15 +00:00
|
|
|
unsigned int pos = ch->pos-(sc->soundoffset<<PITCHSHIFT);
|
2004-08-23 00:15:46 +00:00
|
|
|
|
|
|
|
vol[0] = ch->vol[0];
|
|
|
|
vol[1] = ch->vol[1];
|
|
|
|
vol[2] = ch->vol[2];
|
|
|
|
vol[3] = ch->vol[3];
|
|
|
|
vol[4] = ch->vol[4];
|
|
|
|
vol[5] = ch->vol[5];
|
|
|
|
|
2010-11-06 23:05:29 +00:00
|
|
|
if (ch->rate != (1<<PITCHSHIFT))
|
|
|
|
{
|
|
|
|
signed short data;
|
|
|
|
sfx = (signed short *)sc->data;
|
|
|
|
for (i=0 ; i<count ; i++)
|
|
|
|
{
|
2012-02-27 12:23:15 +00:00
|
|
|
data = sfx[pos>>PITCHSHIFT];
|
|
|
|
pos += ch->rate;
|
2010-11-06 23:05:29 +00:00
|
|
|
paintbuffer[i].s[0] += (vol[0] * data)>>8;
|
|
|
|
paintbuffer[i].s[1] += (vol[1] * data)>>8;
|
|
|
|
paintbuffer[i].s[2] += (vol[2] * data)>>8;
|
|
|
|
paintbuffer[i].s[3] += (vol[3] * data)>>8;
|
|
|
|
paintbuffer[i].s[4] += (vol[4] * data)>>8;
|
|
|
|
paintbuffer[i].s[5] += (vol[5] * data)>>8;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
2004-08-23 00:15:46 +00:00
|
|
|
{
|
2012-02-27 12:23:15 +00:00
|
|
|
sfx = (signed short *)sc->data + (pos>>PITCHSHIFT);
|
2010-11-06 23:05:29 +00:00
|
|
|
for (i=0 ; i<count ; i++)
|
|
|
|
{
|
|
|
|
paintbuffer[i].s[0] += (sfx[i] * vol[0]) >> 8;
|
|
|
|
paintbuffer[i].s[1] += (sfx[i] * vol[1]) >> 8;
|
|
|
|
paintbuffer[i].s[2] += (sfx[i] * vol[2]) >> 8;
|
|
|
|
paintbuffer[i].s[3] += (sfx[i] * vol[3]) >> 8;
|
|
|
|
paintbuffer[i].s[4] += (sfx[i] * vol[4]) >> 8;
|
|
|
|
paintbuffer[i].s[5] += (sfx[i] * vol[5]) >> 8;
|
|
|
|
}
|
2004-08-23 00:15:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-02-07 08:38:40 +00:00
|
|
|
static void SND_PaintChannel16_O8I1 (channel_t *ch, sfxcache_t *sc, int count)
|
2004-08-23 00:15:46 +00:00
|
|
|
{
|
2011-07-06 05:53:25 +00:00
|
|
|
int vol[8];
|
2004-08-23 00:15:46 +00:00
|
|
|
signed short *sfx;
|
|
|
|
int i;
|
2012-02-27 12:23:15 +00:00
|
|
|
unsigned int pos = ch->pos-(sc->soundoffset<<PITCHSHIFT);
|
2004-08-23 00:15:46 +00:00
|
|
|
|
|
|
|
vol[0] = ch->vol[0];
|
|
|
|
vol[1] = ch->vol[1];
|
|
|
|
vol[2] = ch->vol[2];
|
|
|
|
vol[3] = ch->vol[3];
|
2011-07-06 05:53:25 +00:00
|
|
|
vol[4] = ch->vol[4];
|
|
|
|
vol[5] = ch->vol[5];
|
|
|
|
vol[6] = ch->vol[6];
|
|
|
|
vol[7] = ch->vol[7];
|
2004-08-23 00:15:46 +00:00
|
|
|
|
2010-11-06 23:05:29 +00:00
|
|
|
if (ch->rate != (1<<PITCHSHIFT))
|
|
|
|
{
|
|
|
|
signed short data;
|
|
|
|
sfx = (signed short *)sc->data;
|
|
|
|
for (i=0 ; i<count ; i++)
|
|
|
|
{
|
2012-02-27 12:23:15 +00:00
|
|
|
data = sfx[pos>>PITCHSHIFT];
|
|
|
|
pos += ch->rate;
|
2010-11-06 23:05:29 +00:00
|
|
|
paintbuffer[i].s[0] += (vol[0] * data)>>8;
|
|
|
|
paintbuffer[i].s[1] += (vol[1] * data)>>8;
|
|
|
|
paintbuffer[i].s[2] += (vol[2] * data)>>8;
|
|
|
|
paintbuffer[i].s[3] += (vol[3] * data)>>8;
|
2011-07-06 05:53:25 +00:00
|
|
|
paintbuffer[i].s[4] += (vol[4] * data)>>8;
|
|
|
|
paintbuffer[i].s[5] += (vol[5] * data)>>8;
|
|
|
|
paintbuffer[i].s[6] += (vol[6] * data)>>8;
|
|
|
|
paintbuffer[i].s[7] += (vol[7] * data)>>8;
|
2010-11-06 23:05:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
2004-08-23 00:15:46 +00:00
|
|
|
{
|
2012-02-27 12:23:15 +00:00
|
|
|
sfx = (signed short *)sc->data + (pos>>PITCHSHIFT);
|
2010-11-06 23:05:29 +00:00
|
|
|
for (i=0 ; i<count ; i++)
|
|
|
|
{
|
|
|
|
paintbuffer[i].s[0] += (sfx[i] * vol[0]) >> 8;
|
|
|
|
paintbuffer[i].s[1] += (sfx[i] * vol[1]) >> 8;
|
|
|
|
paintbuffer[i].s[2] += (sfx[i] * vol[2]) >> 8;
|
|
|
|
paintbuffer[i].s[3] += (sfx[i] * vol[3]) >> 8;
|
2011-07-06 05:53:25 +00:00
|
|
|
paintbuffer[i].s[4] += (sfx[i] * vol[4]) >> 8;
|
|
|
|
paintbuffer[i].s[5] += (sfx[i] * vol[5]) >> 8;
|
|
|
|
paintbuffer[i].s[6] += (sfx[i] * vol[6]) >> 8;
|
|
|
|
paintbuffer[i].s[7] += (sfx[i] * vol[7]) >> 8;
|
2010-11-06 23:05:29 +00:00
|
|
|
}
|
2004-08-23 00:15:46 +00:00
|
|
|
}
|
|
|
|
}
|
2017-05-23 07:03:07 +00:00
|
|
|
#endif
|