Support spatialized raw streams in base sound, e.g. for VoIP

This commit is contained in:
Zack Middleton 2013-12-07 00:07:07 -06:00
parent 7c0491d7fd
commit fa9fd1b1fc

View file

@ -982,29 +982,34 @@ void S_Base_RawSamples( int stream, int samples, int rate, int width, int s_chan
int i;
int src, dst;
float scale;
int intVolume;
int intVolumeLeft, intVolumeRight;
portable_samplepair_t *rawsamples;
if ( !s_soundStarted || s_soundMuted ) {
return;
}
if(entityNum >= 0)
{
// FIXME: support spatialized raw streams, e.g. for VoIP
return;
}
if ( (stream < 0) || (stream >= MAX_RAW_STREAMS) ) {
return;
}
rawsamples = s_rawsamples[stream];
if(s_muted->integer)
intVolume = 0;
else
intVolume = 256 * volume * s_volume->value;
if ( s_muted->integer ) {
intVolumeLeft = intVolumeRight = 0;
} else {
int leftvol, rightvol;
if ( entityNum >= 0 && entityNum < MAX_GENTITIES ) {
// support spatialized raw streams, e.g. for VoIP
S_SpatializeOrigin( loopSounds[ entityNum ].origin, 256, &leftvol, &rightvol );
} else {
leftvol = rightvol = 256;
}
intVolumeLeft = leftvol * volume * s_volume->value;
intVolumeRight = rightvol * volume * s_volume->value;
}
if ( s_rawend[stream] < s_soundtime ) {
Com_DPrintf( "S_Base_RawSamples: resetting minimum: %i < %i\n", s_rawend[stream], s_soundtime );
@ -1022,8 +1027,8 @@ void S_Base_RawSamples( int stream, int samples, int rate, int width, int s_chan
{
dst = s_rawend[stream]&(MAX_RAW_SAMPLES-1);
s_rawend[stream]++;
rawsamples[dst].left = ((short *)data)[i*2] * intVolume;
rawsamples[dst].right = ((short *)data)[i*2+1] * intVolume;
rawsamples[dst].left = ((short *)data)[i*2] * intVolumeLeft;
rawsamples[dst].right = ((short *)data)[i*2+1] * intVolumeRight;
}
}
else
@ -1035,8 +1040,8 @@ void S_Base_RawSamples( int stream, int samples, int rate, int width, int s_chan
break;
dst = s_rawend[stream]&(MAX_RAW_SAMPLES-1);
s_rawend[stream]++;
rawsamples[dst].left = ((short *)data)[src*2] * intVolume;
rawsamples[dst].right = ((short *)data)[src*2+1] * intVolume;
rawsamples[dst].left = ((short *)data)[src*2] * intVolumeLeft;
rawsamples[dst].right = ((short *)data)[src*2+1] * intVolumeRight;
}
}
}
@ -1049,13 +1054,14 @@ void S_Base_RawSamples( int stream, int samples, int rate, int width, int s_chan
break;
dst = s_rawend[stream]&(MAX_RAW_SAMPLES-1);
s_rawend[stream]++;
rawsamples[dst].left = ((short *)data)[src] * intVolume;
rawsamples[dst].right = ((short *)data)[src] * intVolume;
rawsamples[dst].left = ((short *)data)[src] * intVolumeLeft;
rawsamples[dst].right = ((short *)data)[src] * intVolumeRight;
}
}
else if (s_channels == 2 && width == 1)
{
intVolume *= 256;
intVolumeLeft *= 256;
intVolumeRight *= 256;
for (i=0 ; ; i++)
{
@ -1064,13 +1070,14 @@ void S_Base_RawSamples( int stream, int samples, int rate, int width, int s_chan
break;
dst = s_rawend[stream]&(MAX_RAW_SAMPLES-1);
s_rawend[stream]++;
rawsamples[dst].left = ((char *)data)[src*2] * intVolume;
rawsamples[dst].right = ((char *)data)[src*2+1] * intVolume;
rawsamples[dst].left = ((char *)data)[src*2] * intVolumeLeft;
rawsamples[dst].right = ((char *)data)[src*2+1] * intVolumeRight;
}
}
else if (s_channels == 1 && width == 1)
{
intVolume *= 256;
intVolumeLeft *= 256;
intVolumeRight *= 256;
for (i=0 ; ; i++)
{
@ -1079,8 +1086,8 @@ void S_Base_RawSamples( int stream, int samples, int rate, int width, int s_chan
break;
dst = s_rawend[stream]&(MAX_RAW_SAMPLES-1);
s_rawend[stream]++;
rawsamples[dst].left = (((byte *)data)[src]-128) * intVolume;
rawsamples[dst].right = (((byte *)data)[src]-128) * intVolume;
rawsamples[dst].left = (((byte *)data)[src]-128) * intVolumeLeft;
rawsamples[dst].right = (((byte *)data)[src]-128) * intVolumeRight;
}
}