summaryrefslogtreecommitdiff
path: root/src/client/snd_dma.c
diff options
context:
space:
mode:
authorZack Middleton <zturtleman@gmail.com>2013-12-07 00:07:07 -0600
committerTim Angus <tim@ngus.net>2014-06-17 17:43:37 +0100
commitd013bfd8a58bc90f7475f45942a2989306a487b7 (patch)
tree3cf18e8fec15caf7d200fc0aa8c46bc4549b1773 /src/client/snd_dma.c
parent29c845f46a4e3e6719c1f802d4850096f0cd021f (diff)
Support spatialized raw streams in base sound, e.g. for VoIP
Diffstat (limited to 'src/client/snd_dma.c')
-rw-r--r--src/client/snd_dma.c55
1 files changed, 31 insertions, 24 deletions
diff --git a/src/client/snd_dma.c b/src/client/snd_dma.c
index 9ff982c4..936590e0 100644
--- a/src/client/snd_dma.c
+++ b/src/client/snd_dma.c
@@ -998,29 +998,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 );
@@ -1038,8 +1043,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
@@ -1051,8 +1056,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;
}
}
}
@@ -1065,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 = ((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++)
{
@@ -1080,13 +1086,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++)
{
@@ -1095,8 +1102,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;
}
}