* *
\**********************************************/
+* 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.
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
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
+
+
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.
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 ) ;
class slEnvelope
{
+public: /* SJB TESTING! */
+
float *time ;
float *value ;
int nsteps ;
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 ) ;
} ;
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 ] ;
slCallBack callback ;
int magic ;
+ void low_read ( int nframes, Uchar *dest ) ;
+
public:
slSamplePlayer ( slSample *s, slReplayMode rp_mode = SL_SAMPLE_ONE_SHOT,
~slSamplePlayer () ;
- int getAmountLeft ()
- {
- return lengthRemaining ;
- }
-
slPreemptMode getPreemptMode () { return preempt_mode ; }
int getPriority ()
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 ) ;
} ;
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 ) ;
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 )
{
buffer = buffer2 ;
}
-#if 0
+
void slSample::changeToUnsigned ()
{
if ( getBps() == 16 )
(0xFF-buffer[i]) ;
}
}
-#endif
+
void slSample::changeBps ( int b )
{
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 ;
{
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 ) ;
}
}
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' )
{
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 ) ;
{
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 ) ;
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 ) ;
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' )
{
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 ) ;
}
-Uchar *slSamplePlayer::read ( int nframes, Uchar *spare1, Uchar *spare2 )
+void slSamplePlayer::read ( int nframes, Uchar *dst, int next_env )
{
- if ( isWaiting() ) start () ;
+ /*
+ WARNING:
+
+ CO-RECURSIVE!
+ */
+
+ /* Find the next envelope */
+
+ while ( next_env < SL_MAX_ENVELOPES && env [ next_env ] == NULL )
+ next_env++ ;
- if ( nframes > lengthRemaining ) /* This is an error */
+ /*
+ If there are no fancy envelopes to process then return
+ the raw data.
+ */
+
+ if ( next_env >= SL_MAX_ENVELOPES ) /* No fancy envelopes left */
{
- fprintf ( stderr, "slSamplePlayer: FATAL ERROR - Mixer Requested too much data.\n" ) ;
- abort () ;
+ low_read ( nframes, dst ) ;
+ return ;
}
- Uchar *src = bufferPos ;
- Uchar *dst = spare1 ;
+ /*
+ Envelope processing required...
+
+ Process the next envelope using data read recursively through
+ the remaining envelopes.
+ */
- for ( int i = 0 ; i < SL_MAX_ENVELOPES ; i++ )
+ switch ( env_type [ next_env ] )
{
- if ( env[i] )
- {
- 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 ;
- }
- }
+ /* 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 ;
}
-
- if ( nframes < lengthRemaining ) /* Less data than there is left... */
+}
+
+
+void slSamplePlayer::low_read ( int nframes, Uchar *dst )
+{
+ if ( isWaiting() ) start () ;
+
+ if ( bufferPos == NULL ) /* Run out of sample & no repeats */
{
- lengthRemaining -= nframes ;
- bufferPos += nframes ;
+ memset ( dst, 0x80, nframes ) ;
+ return ;
}
- else /* Read it all */
+
+ while ( SL_TRUE )
{
+ /*
+ 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 )
+ {
+ memcpy ( dst, bufferPos, nframes ) ;
+ bufferPos += nframes ;
+ lengthRemaining -= nframes ;
+ return ;
+ }
+
+ 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 ;
}
+
+
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 () ;
}
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 ()
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 ;
-}
-
-
-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 ;
+ delete spare_buffer0 ;
+ delete spare_buffer1 ;
+ delete spare_buffer2 ;
}
-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++ ) ;
}
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++ ) ;
}
}
}
- 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 )
{
void smMixer::close (){}
-smMixer::smMixer () { }
-smMixer::smMixer ( char *device ) { }
+smMixer::smMixer () {}
+smMixer::smMixer ( char * ) {}
smMixer::~smMixer () {}
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
/* 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 ()
/* 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