Tweaks for voicechat:

Added cl_voip_test cvar, so you can hear/test yourself.
Added potential support for opus.
audio ducking
autogain switched off by default. its nice for pure speech but shite for push-to-talk, voice activation, or indeed anything else.

git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4375 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
Spoike 2013-05-31 01:16:07 +00:00
parent 95188faec2
commit df22ebd757
3 changed files with 625 additions and 277 deletions

File diff suppressed because it is too large Load Diff

View File

@ -36,7 +36,7 @@ void S_TransferPaintBuffer(soundcardinfo_t *sc, int endtime)
unsigned int outlimit;
int *p;
int val;
int snd_vol;
// int snd_vol;
short *pbuf;
int i, numc;
@ -44,7 +44,7 @@ void S_TransferPaintBuffer(soundcardinfo_t *sc, int endtime)
count = (endtime - sc->paintedtime) * sc->sn.numchannels;
outlimit = sc->sn.samples;
out_idx = (sc->paintedtime * sc->sn.numchannels) % outlimit;
snd_vol = (volume.value*voicevolumemod)*256;
// snd_vol = (volume.value*voicevolumemod)*256;
numc = sc->sn.numchannels;
pbuf = sc->Lock(sc, &out_idx);
@ -58,7 +58,7 @@ void S_TransferPaintBuffer(soundcardinfo_t *sc, int endtime)
{
for (i = 0; i < numc; i++)
{
val = (*p * snd_vol) >> 8;
val = *p;// * snd_vol) >> 8;
p++;
if (val > 0x7fff)
val = 0x7fff;
@ -78,7 +78,7 @@ void S_TransferPaintBuffer(soundcardinfo_t *sc, int endtime)
{
for (i = 0; i < numc; i++)
{
val = (*p * snd_vol) >> 8;
val = *p;// * snd_vol) >> 8;
p++;
if (val > 0x7fff)
val = 0x7fff;
@ -289,11 +289,6 @@ void SND_PaintChannelFrom8 (channel_t *ch, sfxcache_t *sc, int count)
int i;
unsigned int pos = ch->pos-(sc->soundoffset<<PITCHSHIFT);
if (ch->vol[0] > 255)
ch->vol[0] = 255;
if (ch->vol[1] > 255)
ch->vol[1] = 255;
if (ch->rate != (1<<PITCHSHIFT))
{
sfx = (signed char *)sc->data;
@ -324,11 +319,6 @@ void SND_PaintChannelFrom8Stereo (channel_t *ch, sfxcache_t *sc, int count)
int i;
unsigned int pos = ch->pos-(sc->soundoffset<<PITCHSHIFT);
if (ch->vol[0] > 255)
ch->vol[0] = 255;
if (ch->vol[1] > 255)
ch->vol[1] = 255;
if (ch->rate != (1<<PITCHSHIFT))
{
sfx = (signed char *)sc->data;
@ -356,15 +346,6 @@ void SND_PaintChannelFrom8_4Speaker (channel_t *ch, sfxcache_t *sc, int count)
int i;
unsigned int pos = ch->pos-(sc->soundoffset<<PITCHSHIFT);
if (ch->vol[0] > 255)
ch->vol[0] = 255;
if (ch->vol[1] > 255)
ch->vol[1] = 255;
if (ch->vol[2] > 255)
ch->vol[2] = 255;
if (ch->vol[3] > 255)
ch->vol[3] = 255;
if (ch->rate != (1<<PITCHSHIFT))
{
signed char data;
@ -398,19 +379,6 @@ void SND_PaintChannelFrom8_6Speaker (channel_t *ch, sfxcache_t *sc, int count)
int i;
unsigned int pos = ch->pos-(sc->soundoffset<<PITCHSHIFT);
if (ch->vol[0] > 255)
ch->vol[0] = 255;
if (ch->vol[1] > 255)
ch->vol[1] = 255;
if (ch->vol[2] > 255)
ch->vol[2] = 255;
if (ch->vol[3] > 255)
ch->vol[3] = 255;
if (ch->vol[4] > 255)
ch->vol[4] = 255;
if (ch->vol[5] > 255)
ch->vol[5] = 255;
if (ch->rate != (1<<PITCHSHIFT))
{
signed char data;
@ -448,23 +416,6 @@ void SND_PaintChannelFrom8_8Speaker (channel_t *ch, sfxcache_t *sc, int count)
int i;
unsigned int pos = ch->pos-(sc->soundoffset<<PITCHSHIFT);
if (ch->vol[0] > 255)
ch->vol[0] = 255;
if (ch->vol[1] > 255)
ch->vol[1] = 255;
if (ch->vol[2] > 255)
ch->vol[2] = 255;
if (ch->vol[3] > 255)
ch->vol[3] = 255;
if (ch->vol[4] > 255)
ch->vol[4] = 255;
if (ch->vol[5] > 255)
ch->vol[5] = 255;
if (ch->vol[6] > 255)
ch->vol[6] = 255;
if (ch->vol[7] > 255)
ch->vol[7] = 255;
if (ch->rate != (1<<PITCHSHIFT))
{
signed char data;

View File

@ -83,14 +83,15 @@ typedef struct
#define PITCHSHIFT 6 /*max audio file length = (1<<32>>PITCHSHIFT)/KHZ*/
#define CF_ABSVOLUME 1 // ignores volume cvar.
typedef struct
{
sfx_t *sfx; // sfx number
int vol[MAXSOUNDCHANNELS]; // 0-255 volume
// int delay[MAXSOUNDCHANNELS];
int vol[MAXSOUNDCHANNELS]; // volume, .8 fixed point.
int start; // start time in global paintsamples
int pos; // sample position in sfx, <0 means delay sound start (shifted up by 8)
int rate; // 24.8 fixed point rate scaling
int flags; // cf_ flags
int looping; // where to loop, -1 = no looping
int entnum; // to allow overriding a specific sound
int entchannel; //int audio_fd
@ -180,7 +181,7 @@ void S_SetUnderWater(qboolean underwater);
void S_Restart_f (void);
//plays streaming audio
void S_RawAudio(int sourceid, qbyte *data, int speed, int samples, int channels, int width);
void S_RawAudio(int sourceid, qbyte *data, int speed, int samples, int channels, int width, float volume);
void CLVC_Poll (void);