engine: sound: select which to buffer raw channels will be painted to, choose stream buffer for voice
This commit is contained in:
parent
1119a9ac22
commit
acd86ce490
1 changed files with 10 additions and 41 deletions
|
@ -897,43 +897,13 @@ void S_MixUpsample( int sampleCount, int filtertype )
|
||||||
ppaint->ifilter++;
|
ppaint->ifilter++;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MIX_MixStreamBuffer( int end )
|
|
||||||
{
|
|
||||||
portable_samplepair_t *pbuf;
|
|
||||||
rawchan_t *ch;
|
|
||||||
|
|
||||||
pbuf = MIX_GetPFrontFromIPaint( ISTREAMBUFFER );
|
|
||||||
ch = S_FindRawChannel( S_RAW_SOUND_BACKGROUNDTRACK, false );
|
|
||||||
|
|
||||||
// clear the paint buffer
|
|
||||||
if( s_listener.paused || !ch || ch->s_rawend < paintedtime )
|
|
||||||
{
|
|
||||||
memset( pbuf, 0, (end - paintedtime) * sizeof( portable_samplepair_t ));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
int i, stop;
|
|
||||||
|
|
||||||
// copy from the streaming sound source
|
|
||||||
stop = (end < ch->s_rawend) ? end : ch->s_rawend;
|
|
||||||
|
|
||||||
for( i = paintedtime; i < stop; i++ )
|
|
||||||
{
|
|
||||||
pbuf[i-paintedtime].left = ( ch->rawsamples[i & ( ch->max_samples - 1 )].left * ch->leftvol ) >> 8;
|
|
||||||
pbuf[i-paintedtime].right = ( ch->rawsamples[i & ( ch->max_samples - 1 )].right * ch->rightvol ) >> 8;
|
|
||||||
}
|
|
||||||
|
|
||||||
for( ; i < end; i++ )
|
|
||||||
pbuf[i-paintedtime].left = pbuf[i-paintedtime].right = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void MIX_MixRawSamplesBuffer( int end )
|
void MIX_MixRawSamplesBuffer( int end )
|
||||||
{
|
{
|
||||||
portable_samplepair_t *pbuf;
|
portable_samplepair_t *pbuf, *roombuf, *streambuf;
|
||||||
uint i, j, stop;
|
uint i, j, stop;
|
||||||
|
|
||||||
pbuf = MIX_GetCurrentPaintbufferPtr()->pbuf;
|
roombuf = MIX_GetPFrontFromIPaint( IROOMBUFFER );
|
||||||
|
streambuf = MIX_GetPFrontFromIPaint( ISTREAMBUFFER );
|
||||||
|
|
||||||
if( s_listener.paused ) return;
|
if( s_listener.paused ) return;
|
||||||
|
|
||||||
|
@ -942,15 +912,18 @@ void MIX_MixRawSamplesBuffer( int end )
|
||||||
{
|
{
|
||||||
// copy from the streaming sound source
|
// copy from the streaming sound source
|
||||||
rawchan_t *ch = raw_channels[i];
|
rawchan_t *ch = raw_channels[i];
|
||||||
|
qboolean stream;
|
||||||
|
|
||||||
// background track should be mixing into another buffer
|
if( !ch )
|
||||||
if( !ch || ch->entnum == S_RAW_SOUND_BACKGROUNDTRACK )
|
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// not audible
|
// not audible
|
||||||
if( !ch->leftvol && !ch->rightvol )
|
if( !ch->leftvol && !ch->rightvol )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
stream = ch->entnum == S_RAW_SOUND_BACKGROUNDTRACK || CL_IsPlayerIndex( ch->entnum );
|
||||||
|
pbuf = stream ? streambuf : roombuf;
|
||||||
|
|
||||||
stop = (end < ch->s_rawend) ? end : ch->s_rawend;
|
stop = (end < ch->s_rawend) ? end : ch->s_rawend;
|
||||||
|
|
||||||
for( j = paintedtime; j < stop; j++ )
|
for( j = paintedtime; j < stop; j++ )
|
||||||
|
@ -970,9 +943,6 @@ void MIX_MixRawSamplesBuffer( int end )
|
||||||
// caller also remixes all into final IPAINTBUFFER output.
|
// caller also remixes all into final IPAINTBUFFER output.
|
||||||
void MIX_UpsampleAllPaintbuffers( int end, int count )
|
void MIX_UpsampleAllPaintbuffers( int end, int count )
|
||||||
{
|
{
|
||||||
// process stream buffer
|
|
||||||
MIX_MixStreamBuffer( end );
|
|
||||||
|
|
||||||
// 11khz sounds are mixed into 3 buffers based on distance from listener, and facing direction
|
// 11khz sounds are mixed into 3 buffers based on distance from listener, and facing direction
|
||||||
// These buffers are facing, facingaway, room
|
// These buffers are facing, facingaway, room
|
||||||
// These 3 mixed buffers are then each upsampled to 22khz.
|
// These 3 mixed buffers are then each upsampled to 22khz.
|
||||||
|
@ -1014,7 +984,6 @@ void MIX_UpsampleAllPaintbuffers( int end, int count )
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// mix raw samples from the video streams
|
// mix raw samples from the video streams
|
||||||
MIX_SetCurrentPaintbuffer( IROOMBUFFER );
|
|
||||||
MIX_MixRawSamplesBuffer( end );
|
MIX_MixRawSamplesBuffer( end );
|
||||||
|
|
||||||
MIX_DeactivateAllPaintbuffers();
|
MIX_DeactivateAllPaintbuffers();
|
||||||
|
|
Loading…
Add table
Reference in a new issue