1
0
Fork 0

Incorporated Steve's latest version of his audio library. This version

allows pitch and volume changes so we should be able tie this to the
throttle now.
This commit is contained in:
curt 1998-09-24 19:36:25 +00:00
parent 605ad52197
commit 1b99b2a25d
9 changed files with 338 additions and 322 deletions

View file

@ -9,6 +9,16 @@
* *
\**********************************************/
* 23rd Sept 1998 -- The Good News: Finally got around to
getting the pitch envelope working. (Hooray)
The Bad News: This costs quite a bit in
performance - and it was a MAJOR rewrite
of significant parts of the internals,
so we may need some bug fixes.
* 7th July 1998 -- Fixed some error checking in slSample.cxx and
a missing declaration in sl.h
* 6th July 1998 -- Fixed an initialisation problem when
slScheduler was not a static/global.

View file

@ -2,6 +2,17 @@
Building SL for SGI.
~~~~~~~~~~~~~~~~~~~~~~
There are two options, depending on whether you want to use GCC or
the standard SGI C++ compiler.
GNU G++:
% make sgigcc
% su root
% make install
SGI C++:
% make sgi
% su root
% make install
@ -11,3 +22,6 @@ Building SL for SGI.
Header files go into /usr/include/SL (analogous to /usr/include/GL for graphics)
Library file(s) go into /usr/lib
When you link, be sure to include to -laudio

View file

@ -64,6 +64,19 @@ int main ()
if ( tim % 150 == 0 ) sched.playSample ( s3 ) ;
if ( tim % 120 == 0 ) sched.playSample ( s4 ) ;
if ( tim == 300 ) {
// introduce an envelope for our engine noise after 10 seconds
slEnvelope my_envelope ( 2, SL_SAMPLE_LOOP ) ;
my_envelope.setStep ( 0, 0.0, 1.0 ) ;
my_envelope.setStep ( 1, 10.0, 2.0 ) ;
my_envelope.setStep ( 2, 20.0, 1.0 ) ;
// scheduler -> playSample ( my_sample ) ;
sched.addSampleEnvelope ( s, 0, 0, &my_envelope, SL_PITCH_ENVELOPE ) ;
}
/*
For the sake of realism, I'll delay for 1/30th second to
simulate a graphics update process.

View file

@ -224,9 +224,10 @@ public:
int loadAUFile ( char *fname ) ;
int loadWavFile ( char *fname ) ;
void changeRate ( int r ) ;
void changeBps ( int b ) ;
void changeStereo ( int s ) ;
void changeRate ( int r ) ;
void changeBps ( int b ) ;
void changeStereo ( int s ) ;
void changeToUnsigned () ;
void adjustVolume ( float vol ) ;
@ -285,6 +286,8 @@ typedef void (*slCallBack) ( slSample *, slEvent, int ) ;
class slEnvelope
{
public: /* SJB TESTING! */
float *time ;
float *value ;
int nsteps ;
@ -356,6 +359,8 @@ public:
float getValue ( float _time ) ;
void applyToPitch ( Uchar *dst, slSamplePlayer *src, int nframes, int start, int next_env ) ;
void applyToInvPitch ( Uchar *dst, slSamplePlayer *src, int nframes, int start, int next_env ) ;
void applyToVolume ( Uchar *dst, Uchar *src, int nframes, int start ) ;
void applyToInvVolume ( Uchar *dst, Uchar *src, int nframes, int start ) ;
} ;
@ -386,8 +391,8 @@ struct slPendingCallBack
class slSamplePlayer
{
int lengthRemaining ;
Uchar *bufferPos ;
int lengthRemaining ; /* Sample frames remaining until repeat */
Uchar *bufferPos ; /* Sample frame to replay next */
slSample *sample ;
slEnvelope *env [ SL_MAX_ENVELOPES ] ;
@ -402,6 +407,8 @@ class slSamplePlayer
slCallBack callback ;
int magic ;
void low_read ( int nframes, Uchar *dest ) ;
public:
slSamplePlayer ( slSample *s, slReplayMode rp_mode = SL_SAMPLE_ONE_SHOT,
@ -429,11 +436,6 @@ public:
~slSamplePlayer () ;
int getAmountLeft ()
{
return lengthRemaining ;
}
slPreemptMode getPreemptMode () { return preempt_mode ; }
int getPriority ()
@ -488,8 +490,8 @@ public:
int isRunning () { return status == SL_SAMPLE_RUNNING ; }
int isDone () { return status == SL_SAMPLE_DONE ; }
void skip ( int nframes ) ;
Uchar *read ( int nframes, Uchar *spare1, Uchar *spare2 ) ;
void skip ( int nframes ) ;
void read ( int nframes, Uchar *dest, int next_env = 0 ) ;
} ;
@ -499,29 +501,24 @@ class slScheduler : public slDSP
int num_pending_callbacks ;
float safety_margin ;
int mixer_buffer_size ;
Uchar *mixer_buffer ;
Uchar *mixer_buffer ;
Uchar *spare_buffer0 ;
Uchar *spare_buffer1 ;
Uchar *spare_buffer2 ;
Uchar *mixer ;
int amount_left ;
slSamplePlayer *samplePlayer [ SL_MAX_SAMPLES ] ;
Uchar *spare_buffer1 [ 3 ] ;
Uchar *spare_buffer2 [ 3 ] ;
void init () ;
Uchar *mergeBlock ( Uchar *d ) ;
Uchar *mergeBlock ( Uchar *d, slSamplePlayer *spa ) ;
Uchar *mergeBlock ( Uchar *d, slSamplePlayer *spa,
slSamplePlayer *spb ) ;
Uchar *mergeBlock ( Uchar *d, slSamplePlayer *spa,
slSamplePlayer *spb,
slSamplePlayer *spc ) ;
void mixBuffer () ;
void mixBuffer ( slSamplePlayer *a ) ;
void mixBuffer ( slSamplePlayer *a,
slSamplePlayer *b ) ;
void mixBuffer ( slSamplePlayer *a,
slSamplePlayer *b,
slSamplePlayer *c ) ;

View file

@ -46,6 +46,84 @@ int slEnvelope::getStepDelta ( float *_time, float *delta )
return nsteps - 1 ;
}
void slEnvelope::applyToPitch ( Uchar *dst, slSamplePlayer *src,
int nframes, int start, int next_env )
{
float delta ;
float _time = slScheduler::getCurrent() -> getElapsedTime ( start ) ;
int step = getStepDelta ( &_time, &delta ) ;
float _value = delta * (_time - time[step]) + value[step] ;
delta /= (float) slScheduler::getCurrent() -> getRate () ;
unsigned char tmp [ 512 ] ;
float pos = 0 ;
float npos = 0 ;
unsigned char last = 0x80 ;
while ( nframes-- )
{
npos += _value ;
_value += delta ;
int offset = (int) ( npos - pos ) ;
if ( offset > 512 )
offset = 512 ;
if ( offset < 1 )
*(dst++) = last ;
else
{
pos += offset ;
src -> read ( offset, tmp, next_env ) ;
*(dst++) = last = tmp [ offset-1 ] ;
}
}
}
void slEnvelope::applyToInvPitch ( Uchar *dst, slSamplePlayer *src,
int nframes, int start, int next_env )
{
float delta ;
float _time = slScheduler::getCurrent() -> getElapsedTime ( start ) ;
int step = getStepDelta ( &_time, &delta ) ;
float _value = delta * (_time - time[step]) + value[step] ;
delta /= (float) slScheduler::getCurrent() -> getRate () ;
unsigned char tmp [ 512 ] ;
float pos = 0 ;
float npos = 0 ;
unsigned char last = 0x80 ;
while ( nframes-- )
{
npos += 1.0 / _value ;
_value += delta ;
int offset = (int) ( npos - pos ) ;
if ( offset > 512 )
offset = 512 ;
if ( offset < 1 )
*(dst++) = last ;
else
{
pos += offset ;
src -> read ( offset, tmp, next_env ) ;
*(dst++) = last = tmp [ offset-1 ] ;
}
}
}
void slEnvelope::applyToVolume ( Uchar *dst, Uchar *src,
int nframes, int start )
{

View file

@ -71,7 +71,7 @@ void slSample::changeRate ( int r )
buffer = buffer2 ;
}
#if 0
void slSample::changeToUnsigned ()
{
if ( getBps() == 16 )
@ -89,7 +89,7 @@ void slSample::changeToUnsigned ()
(0xFF-buffer[i]) ;
}
}
#endif
void slSample::changeBps ( int b )
@ -161,7 +161,7 @@ void slSample::changeStereo ( int s )
{
Uchar *buffer2 = new Uchar [ length / 2 ] ;
for ( int i = 0 ; i < length ; i++ )
for ( int i = 0 ; i < (length-1)/2 ; i++ )
buffer2 [ i ] = ((int)buffer [ i*2 ] + (int)buffer [ i*2 + 1 ] ) / 2 ;
delete buffer ;
@ -173,13 +173,13 @@ void slSample::changeStereo ( int s )
{
Ushort *buffer2 = new Ushort [ length / 4 ] ;
for ( int i = 0 ; i < length / 4 ; i++ )
for ( int i = 0 ; i < (length-3) / 4 ; i++ )
buffer2 [ i ] = ((int)((Ushort *)buffer) [ i*2 ] +
(int)((Ushort *)buffer) [ i*2 + 1 ] ) / 2 ;
delete buffer ;
buffer = (Uchar *)buffer2 ;
length /= 2 ;
length /= 4 ;
setStereo ( SL_FALSE ) ;
}
}
@ -238,7 +238,7 @@ int slSample::loadWavFile ( char *fname )
char magic [ 8 ] ;
if ( fread ( magic, 4, 1, fd ) == -1 ||
if ( fread ( magic, 4, 1, fd ) == 0 ||
magic[0] != 'R' || magic[1] != 'I' ||
magic[2] != 'F' || magic[3] != 'F' )
{
@ -250,7 +250,7 @@ int slSample::loadWavFile ( char *fname )
int leng1 ;
if ( fread ( & leng1, sizeof(int), 1, fd ) == -1 )
if ( fread ( & leng1, sizeof(int), 1, fd ) == 0 )
{
fprintf ( stderr, "slSample: File '%s' has premature EOF in header\n", fname ) ;
fclose ( fd ) ;
@ -276,7 +276,7 @@ int slSample::loadWavFile ( char *fname )
{
found_header = SL_TRUE ;
if ( fread ( & leng1, sizeof(int), 1, fd ) == -1 )
if ( fread ( & leng1, sizeof(int), 1, fd ) == 0 )
{
fprintf ( stderr, "slSample: File '%s' has premature EOF in header\n", fname ) ;
fclose ( fd ) ;
@ -333,7 +333,7 @@ int slSample::loadWavFile ( char *fname )
return SL_FALSE ;
}
if ( fread ( & length, sizeof(int), 1, fd ) == -1 )
if ( fread ( & length, sizeof(int), 1, fd ) == 0 )
{
fprintf ( stderr, "slSample: File '%s' has premature EOF in data\n", fname ) ;
fclose ( fd ) ;
@ -382,7 +382,7 @@ int slSample::loadAUFile ( char *fname )
char magic [ 4 ] ;
if ( fread ( magic, 4, 1, fd ) == -1 ||
if ( fread ( magic, 4, 1, fd ) == 0 ||
magic[0] != '.' || magic[1] != 's' ||
magic[2] != 'n' || magic[3] != 'd' )
{
@ -398,11 +398,11 @@ int slSample::loadAUFile ( char *fname )
int irate ;
int nchans ;
if ( fread ( & hdr_length, sizeof(int), 1, fd ) == -1 ||
fread ( & dat_length, sizeof(int), 1, fd ) == -1 ||
fread ( & nbytes , sizeof(int), 1, fd ) == -1 ||
fread ( & irate , sizeof(int), 1, fd ) == -1 ||
fread ( & nchans , sizeof(int), 1, fd ) == -1 )
if ( fread ( & hdr_length, sizeof(int), 1, fd ) == 0 ||
fread ( & dat_length, sizeof(int), 1, fd ) == 0 ||
fread ( & nbytes , sizeof(int), 1, fd ) == 0 ||
fread ( & irate , sizeof(int), 1, fd ) == 0 ||
fread ( & nchans , sizeof(int), 1, fd ) == 0 )
{
fprintf ( stderr, "slSample: File '%s' has premature EOF in header\n", fname ) ;
fclose ( fd ) ;

View file

@ -68,83 +68,121 @@ void slSamplePlayer::skip ( int nframes )
}
Uchar *slSamplePlayer::read ( int nframes, Uchar *spare1, Uchar *spare2 )
void slSamplePlayer::read ( int nframes, Uchar *dst, int next_env )
{
/*
WARNING:
CO-RECURSIVE!
*/
/* Find the next envelope */
while ( next_env < SL_MAX_ENVELOPES && env [ next_env ] == NULL )
next_env++ ;
/*
If there are no fancy envelopes to process then return
the raw data.
*/
if ( next_env >= SL_MAX_ENVELOPES ) /* No fancy envelopes left */
{
low_read ( nframes, dst ) ;
return ;
}
/*
Envelope processing required...
Process the next envelope using data read recursively through
the remaining envelopes.
*/
switch ( env_type [ next_env ] )
{
/* For Volume envelopes, SRC and DST can be the same buffer */
case SL_INVERSE_VOLUME_ENVELOPE:
read ( nframes, dst, next_env+1 ) ;
env[ next_env ]->applyToInvVolume ( dst,dst,nframes,env_start_time[ next_env ] ) ;
break ;
case SL_VOLUME_ENVELOPE :
read ( nframes, dst, next_env+1 ) ;
env[ next_env ]->applyToVolume ( dst,dst,nframes,env_start_time[ next_env ] ) ;
break ;
case SL_INVERSE_PITCH_ENVELOPE :
env[ next_env ]->applyToInvPitch ( dst,this,nframes,env_start_time[ next_env ], next_env+1 ) ;
break ;
case SL_PITCH_ENVELOPE :
env[ next_env ]->applyToPitch ( dst,this,nframes,env_start_time[ next_env ], next_env+1 ) ;
break ;
case SL_INVERSE_FILTER_ENVELOPE:
case SL_FILTER_ENVELOPE :
read ( nframes, dst, next_env+1 ) ;
break ;
case SL_INVERSE_PAN_ENVELOPE :
case SL_PAN_ENVELOPE :
read ( nframes, dst, next_env+1 ) ;
break ;
case SL_INVERSE_ECHO_ENVELOPE :
case SL_ECHO_ENVELOPE :
read ( nframes, dst, next_env+1 ) ;
break ;
}
}
void slSamplePlayer::low_read ( int nframes, Uchar *dst )
{
if ( isWaiting() ) start () ;
if ( nframes > lengthRemaining ) /* This is an error */
if ( bufferPos == NULL ) /* Run out of sample & no repeats */
{
fprintf ( stderr, "slSamplePlayer: FATAL ERROR - Mixer Requested too much data.\n" ) ;
abort () ;
memset ( dst, 0x80, nframes ) ;
return ;
}
Uchar *src = bufferPos ;
Uchar *dst = spare1 ;
for ( int i = 0 ; i < SL_MAX_ENVELOPES ; i++ )
while ( SL_TRUE )
{
if ( env[i] )
/*
If we can satisfy this request in one read (with data left in
the sample buffer ready for next time around) - then we are done...
*/
if ( nframes < lengthRemaining )
{
switch ( env_type [ i ] )
{
case SL_INVERSE_PITCH_ENVELOPE :
case SL_PITCH_ENVELOPE :
memcpy ( dst, src, nframes ) /* Tricky! */ ;
break ;
case SL_INVERSE_VOLUME_ENVELOPE:
env[i]->applyToInvVolume ( dst,src,nframes,env_start_time[i] ) ;
break ;
case SL_VOLUME_ENVELOPE :
env[i]->applyToVolume ( dst,src,nframes,env_start_time[i] ) ;
break ;
case SL_INVERSE_FILTER_ENVELOPE:
case SL_FILTER_ENVELOPE :
memcpy ( dst, src, nframes ) /* Tricky! */ ;
break ;
case SL_INVERSE_PAN_ENVELOPE :
case SL_PAN_ENVELOPE :
memcpy ( dst, src, nframes ) /* Tricky! */ ;
break ;
case SL_INVERSE_ECHO_ENVELOPE :
case SL_ECHO_ENVELOPE :
memcpy ( dst, src, nframes ) /* Tricky! */ ;
break ;
}
if ( dst == spare1 )
{
src = spare1 ;
dst = spare2 ;
}
else
{
dst = spare1 ;
src = spare2 ;
}
memcpy ( dst, bufferPos, nframes ) ;
bufferPos += nframes ;
lengthRemaining -= nframes ;
return ;
}
}
if ( nframes < lengthRemaining ) /* Less data than there is left... */
{
lengthRemaining -= nframes ;
bufferPos += nframes ;
}
else /* Read it all */
{
memcpy ( dst, bufferPos, lengthRemaining ) ;
bufferPos += lengthRemaining ;
dst += lengthRemaining ;
nframes -= lengthRemaining ;
lengthRemaining = 0 ;
if ( replay_mode == SL_SAMPLE_ONE_SHOT )
{
stop () ;
memset ( dst, 0x80, nframes ) ;
return ;
}
else
{
slScheduler::getCurrent() -> addCallBack ( callback, sample, SL_EVENT_LOOPED, magic ) ;
start () ;
}
}
return src ;
}

View file

@ -37,13 +37,11 @@ void slScheduler::init ()
safety_margin = 1.0 ;
mixer = NULL ;
mixer_buffer = NULL ;
spare_buffer1 [ 0 ] = NULL ;
spare_buffer1 [ 1 ] = NULL ;
spare_buffer1 [ 2 ] = NULL ;
spare_buffer2 [ 0 ] = NULL ;
spare_buffer2 [ 1 ] = NULL ;
spare_buffer2 [ 2 ] = NULL ;
mixer_buffer = NULL ;
spare_buffer0 = NULL ;
spare_buffer1 = NULL ;
spare_buffer2 = NULL ;
initBuffers () ;
}
@ -53,25 +51,18 @@ void slScheduler::initBuffers ()
if ( not_working () ) return ;
delete mixer_buffer ;
delete spare_buffer1 [ 0 ] ;
delete spare_buffer1 [ 1 ] ;
delete spare_buffer1 [ 2 ] ;
delete spare_buffer2 [ 0 ] ;
delete spare_buffer2 [ 1 ] ;
delete spare_buffer2 [ 2 ] ;
delete spare_buffer0 ;
delete spare_buffer1 ;
delete spare_buffer2 ;
mixer_buffer_size = getDriverBufferSize () ;
mixer_buffer = new Uchar [ mixer_buffer_size ] ;
memset ( mixer_buffer, 0x80, mixer_buffer_size ) ;
spare_buffer1 [ 0 ] = new Uchar [ mixer_buffer_size ] ;
spare_buffer1 [ 1 ] = new Uchar [ mixer_buffer_size ] ;
spare_buffer1 [ 2 ] = new Uchar [ mixer_buffer_size ] ;
spare_buffer2 [ 0 ] = new Uchar [ mixer_buffer_size ] ;
spare_buffer2 [ 1 ] = new Uchar [ mixer_buffer_size ] ;
spare_buffer2 [ 2 ] = new Uchar [ mixer_buffer_size ] ;
spare_buffer0 = new Uchar [ mixer_buffer_size ] ;
spare_buffer1 = new Uchar [ mixer_buffer_size ] ;
spare_buffer2 = new Uchar [ mixer_buffer_size ] ;
}
slScheduler::~slScheduler ()
@ -81,134 +72,27 @@ slScheduler::~slScheduler ()
delete mixer_buffer ;
delete spare_buffer1 [ 0 ] ;
delete spare_buffer1 [ 1 ] ;
delete spare_buffer1 [ 2 ] ;
delete spare_buffer2 [ 0 ] ;
delete spare_buffer2 [ 1 ] ;
delete spare_buffer2 [ 2 ] ;
}
Uchar *slScheduler::mergeBlock ( Uchar *d )
{
register int l = amount_left ;
amount_left = 0 ;
memset ( d, 0x80, l ) ;
return d + l ;
delete spare_buffer0 ;
delete spare_buffer1 ;
delete spare_buffer2 ;
}
Uchar *slScheduler::mergeBlock ( Uchar *d, slSamplePlayer *spa )
{
register int l = spa -> getAmountLeft () ;
if ( l > amount_left )
l = amount_left ;
amount_left -= l ;
memcpy ( d, spa->read(l, spare_buffer1[0], spare_buffer2[0]), l ) ;
return d + l ;
}
Uchar *slScheduler::mergeBlock ( Uchar *d, slSamplePlayer *spa, slSamplePlayer *spb )
{
int la = spa -> getAmountLeft () ;
int lb = spb -> getAmountLeft () ;
register int l = ( la < lb ) ? la : lb ;
if ( l > amount_left )
l = amount_left ;
amount_left -= l ;
register Uchar *a = spa -> read ( l, spare_buffer1[0], spare_buffer2[0] ) ;
register Uchar *b = spb -> read ( l, spare_buffer1[1], spare_buffer2[1] ) ;
while ( l-- ) *d++ = mix ( *a++, *b++ ) ;
return d ;
}
Uchar *slScheduler::mergeBlock ( Uchar *d, slSamplePlayer *spa, slSamplePlayer *spb, slSamplePlayer *spc )
{
int la = spa -> getAmountLeft () ;
int lb = spb -> getAmountLeft () ;
int lc = spc -> getAmountLeft () ;
register int l = ( la < lb ) ?
(( la < lc ) ? la : lc ) :
(( lb < lc ) ? lb : lc ) ;
if ( l > amount_left )
l = amount_left ;
amount_left -= l ;
register Uchar *a = spa -> read ( l, spare_buffer1[0], spare_buffer2[0] ) ;
register Uchar *b = spb -> read ( l, spare_buffer1[1], spare_buffer2[1] ) ;
register Uchar *c = spc -> read ( l, spare_buffer1[2], spare_buffer2[2] ) ;
while ( l-- ) *d++ = mix ( *a++, *b++, *c++ ) ;
return d ;
}
void slScheduler::mixBuffer ()
{
register Uchar *d = mixer_buffer ;
amount_left = mixer_buffer_size ;
while ( amount_left > 0 )
d = mergeBlock ( d ) ;
}
void slScheduler::mixBuffer ( slSamplePlayer *spa )
{
register Uchar *d = mixer_buffer ;
amount_left = mixer_buffer_size ;
while ( amount_left > 0 )
{
int la = spa -> getAmountLeft () ;
if ( la > 0 ) /* Buffer has data left... */
d = mergeBlock ( d, spa ) ;
else /* Buffer is empty */
d = mergeBlock ( d ) ;
}
}
void slScheduler::mixBuffer ( slSamplePlayer *spa, slSamplePlayer *spb )
{
register int l = mixer_buffer_size ;
register Uchar *d = mixer_buffer ;
amount_left = mixer_buffer_size ;
while ( amount_left > 0 )
{
int la = spa -> getAmountLeft () ;
int lb = spb -> getAmountLeft () ;
register Uchar *a = spare_buffer0 ;
register Uchar *b = spare_buffer1 ;
if ( la > 0 && lb > 0 ) /* Both buffers have data left... */
d = mergeBlock ( d, spa, spb ) ;
else
if ( la > 0 && lb <= 0 ) /* Only the A buffer has data left... */
d = mergeBlock ( d, spa ) ;
else
if ( la <= 0 && lb > 0 ) /* Only the B buffer has data left... */
d = mergeBlock ( d, spb ) ;
else /* Both buffers are empty */
d = mergeBlock ( d ) ;
}
spa -> read ( l, a ) ;
spb -> read ( l, b ) ;
while ( l-- ) *d++ = mix ( *a++, *b++ ) ;
}
@ -216,43 +100,18 @@ void slScheduler::mixBuffer ( slSamplePlayer *spa, slSamplePlayer *spb )
void slScheduler::mixBuffer ( slSamplePlayer *spa, slSamplePlayer *spb,
slSamplePlayer *spc )
{
register int l = mixer_buffer_size ;
register Uchar *d = mixer_buffer ;
amount_left = mixer_buffer_size ;
register Uchar *a = spare_buffer0 ;
register Uchar *b = spare_buffer1 ;
register Uchar *c = spare_buffer2 ;
while ( amount_left > 0 )
{
int la = spa -> getAmountLeft () ;
int lb = spb -> getAmountLeft () ;
int lc = spc -> getAmountLeft () ;
spa -> read ( l, a ) ;
spb -> read ( l, b ) ;
spc -> read ( l, c ) ;
if ( lc > 0 ) /* C buffer has data left... */
{
if ( la > 0 && lb > 0 ) /* All three buffers have data left... */
d = mergeBlock ( d, spa, spb, spc ) ;
else
if ( la > 0 && lb <= 0 ) /* Only the A&C buffers have data left... */
d = mergeBlock ( d, spa, spc ) ;
else
if ( la <= 0 && lb > 0 ) /* Only the B&C buffers have data left... */
d = mergeBlock ( d, spb, spc ) ;
else /* Only the C buffer has data left */
d = mergeBlock ( d, spc ) ;
}
else
{
if ( la > 0 && lb > 0 ) /* Only the A&B buffers have data left... */
d = mergeBlock ( d, spa, spb ) ;
else
if ( la > 0 && lb <= 0 ) /* Only the A buffer has data left... */
d = mergeBlock ( d, spa ) ;
else
if ( la <= 0 && lb > 0 ) /* Only the B buffer has data left... */
d = mergeBlock ( d, spb ) ;
else /* All three buffers are empty */
d = mergeBlock ( d ) ;
}
}
while ( l-- ) *d++ = mix ( *a++, *b++, *c++ ) ;
}
@ -312,10 +171,19 @@ void slScheduler::realUpdate ( int dump_first )
}
}
if ( pri[0] < 0 ) mixBuffer () ; else
if ( pri[1] < 0 ) mixBuffer ( psp[0] ) ; else
if ( pri[2] < 0 ) mixBuffer ( psp[0], psp[1] ) ; else
mixBuffer ( psp[0], psp[1], psp[2] ) ;
if ( pri[0] < 0 )
{
memset ( mixer_buffer, 0x80, mixer_buffer_size ) ;
amount_left = 0 ;
}
else
if ( pri[1] < 0 )
psp[0] -> read ( mixer_buffer_size, mixer_buffer ) ;
else
if ( pri[2] < 0 )
mixBuffer ( psp[0], psp[1] ) ;
else
mixBuffer ( psp[0], psp[1], psp[2] ) ;
if ( dump_first )
{

View file

@ -168,8 +168,8 @@ void smMixer::open ( char *device )
void smMixer::close (){}
smMixer::smMixer () { }
smMixer::smMixer ( char *device ) { }
smMixer::smMixer () {}
smMixer::smMixer ( char * ) {}
smMixer::~smMixer () {}
int smMixer::not_working ()
@ -179,31 +179,31 @@ int smMixer::not_working ()
/* Volume controls are in integer percentages */
int smMixer::getVolume ( int channel ) { return 50 ; }
void smMixer::getVolume ( int channel, int *left, int *right )
int smMixer::getVolume ( int ) { return 50 ; }
void smMixer::getVolume ( int, int *left, int *right )
{
if ( left ) *left = 50 ;
if ( right ) *right = 50 ;
}
void smMixer::setVolume ( int channel, int volume ) {}
void smMixer::setVolume ( int channel, int left, int right ){}
void smMixer::setTreble ( int treble ) {}
void smMixer::setBass ( int bass ) {}
void smMixer::setMasterVolume ( int volume ) {}
void smMixer::setSynthVolume ( int volume ) {}
void smMixer::setPCMVolume ( int volume ) {}
void smMixer::setSpeakerVolume( int volume ) {}
void smMixer::setLineVolume ( int volume ) {}
void smMixer::setMicVolume ( int volume ) {}
void smMixer::setCDVolume ( int volume ) {}
void smMixer::setMasterVolume ( int left, int right ) {}
void smMixer::setSynthVolume ( int left, int right ) {}
void smMixer::setPCMVolume ( int left, int right ) {}
void smMixer::setSpeakerVolume( int left, int right ) {}
void smMixer::setLineVolume ( int left, int right ) {}
void smMixer::setMicVolume ( int left, int right ) {}
void smMixer::setCDVolume ( int left, int right ) {}
void smMixer::setVolume ( int , int ) {}
void smMixer::setVolume ( int , int , int ){}
void smMixer::setTreble ( int ) {}
void smMixer::setBass ( int ) {}
void smMixer::setMasterVolume ( int ) {}
void smMixer::setSynthVolume ( int ) {}
void smMixer::setPCMVolume ( int ) {}
void smMixer::setSpeakerVolume( int ) {}
void smMixer::setLineVolume ( int ) {}
void smMixer::setMicVolume ( int ) {}
void smMixer::setCDVolume ( int ) {}
void smMixer::setMasterVolume ( int, int ) {}
void smMixer::setSynthVolume ( int, int ) {}
void smMixer::setPCMVolume ( int, int ) {}
void smMixer::setSpeakerVolume( int, int ) {}
void smMixer::setLineVolume ( int, int ) {}
void smMixer::setMicVolume ( int, int ) {}
void smMixer::setCDVolume ( int, int ) {}
#else
@ -211,14 +211,12 @@ void smMixer::setCDVolume ( int left, int right ) {}
/* win32 */
/* ------------------------------------------------------------ */
void smMixer::open ( char *device )
{
}
void smMixer::open ( char * ) {}
void smMixer::close (){}
smMixer::smMixer () { }
smMixer::smMixer ( char *device ) { }
smMixer::smMixer () {}
smMixer::smMixer ( char * ) {}
smMixer::~smMixer () {}
int smMixer::not_working ()
@ -228,31 +226,31 @@ int smMixer::not_working ()
/* Volume controls are in integer percentages */
int smMixer::getVolume ( int channel ) { return 50 ; }
void smMixer::getVolume ( int channel, int *left, int *right )
int smMixer::getVolume ( int ) { return 50 ; }
void smMixer::getVolume ( int, int *left, int *right )
{
if ( left ) *left = 50 ;
if ( right ) *right = 50 ;
}
void smMixer::setVolume ( int channel, int volume ) {}
void smMixer::setVolume ( int channel, int left, int right ){}
void smMixer::setTreble ( int treble ) {}
void smMixer::setBass ( int bass ) {}
void smMixer::setMasterVolume ( int volume ) {}
void smMixer::setSynthVolume ( int volume ) {}
void smMixer::setPCMVolume ( int volume ) {}
void smMixer::setSpeakerVolume( int volume ) {}
void smMixer::setLineVolume ( int volume ) {}
void smMixer::setMicVolume ( int volume ) {}
void smMixer::setCDVolume ( int volume ) {}
void smMixer::setMasterVolume ( int left, int right ) {}
void smMixer::setSynthVolume ( int left, int right ) {}
void smMixer::setPCMVolume ( int left, int right ) {}
void smMixer::setSpeakerVolume( int left, int right ) {}
void smMixer::setLineVolume ( int left, int right ) {}
void smMixer::setMicVolume ( int left, int right ) {}
void smMixer::setCDVolume ( int left, int right ) {}
void smMixer::setVolume ( int, int ) {}
void smMixer::setVolume ( int, int, int ){}
void smMixer::setTreble ( int ) {}
void smMixer::setBass ( int ) {}
void smMixer::setMasterVolume ( int ) {}
void smMixer::setSynthVolume ( int ) {}
void smMixer::setPCMVolume ( int ) {}
void smMixer::setSpeakerVolume( int ) {}
void smMixer::setLineVolume ( int ) {}
void smMixer::setMicVolume ( int ) {}
void smMixer::setCDVolume ( int ) {}
void smMixer::setMasterVolume ( int, int ) {}
void smMixer::setSynthVolume ( int, int ) {}
void smMixer::setPCMVolume ( int, int ) {}
void smMixer::setSpeakerVolume( int, int ) {}
void smMixer::setLineVolume ( int, int ) {}
void smMixer::setMicVolume ( int, int ) {}
void smMixer::setCDVolume ( int, int ) {}
#endif