* *
\**********************************************/
+* 28th Sept 1889 -- Fixed a bug associated with exiting the
+ program with sounds still playing.
+ Fixed a bug associated with using the
+ package in the absence of a sound card.
+ Added a new member function "working"
+ which is the opposite of "not_working",
+ (as demanded by a bunch of rabid optimists)!
+ Fixed a couple of typo's in the manual.
+
* 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.
+ This version is 0.5
* 7th July 1998 -- Fixed some error checking in slSample.cxx and
a missing declaration in sl.h
int tim = 0 ; /* My periodic event timer. */
- slEnvelope pitch_envelope ( 3, SL_SAMPLE_LOOP ) ;
- slEnvelope p_envelope ( 1, SL_SAMPLE_ONE_SHOT ) ;
- slEnvelope volume_envelope ( 3, SL_SAMPLE_LOOP ) ;
-
while ( SL_TRUE )
{
-
- tim++ ; /* Time passes */
+ tim++ ; /* Time passes */
if ( tim % 200 == 0 ) sched.playSample ( s1 ) ;
if ( tim % 180 == 0 ) sched.playSample ( s2 ) ;
if ( tim % 150 == 0 ) sched.playSample ( s3 ) ;
if ( tim % 120 == 0 ) sched.playSample ( s4 ) ;
- if ( tim == 60 ) {
- // introduce an envelope for our engine noise after 10 seconds
-
- pitch_envelope.setStep ( 0, 0.0, 1.0 ) ;
- pitch_envelope.setStep ( 1, 5.0, 2.0 ) ;
- pitch_envelope.setStep ( 2, 10.0, 1.0 ) ;
-
- p_envelope.setStep ( 0, 5.0, 2.0 ) ;
-
- volume_envelope.setStep ( 0, 0.0, 1.0 ) ;
- volume_envelope.setStep ( 1, 5.0, 2.0 ) ;
- volume_envelope.setStep ( 2, 10.0, 1.0 ) ;
-
- // scheduler -> playSample ( my_sample ) ;
- sched.addSampleEnvelope( s, 0, 0, &p_envelope, SL_PITCH_ENVELOPE );
- sched.addSampleEnvelope( s, 0, 1, &volume_envelope, SL_VOLUME_ENVELOPE);
- }
-
-
/*
For the sake of realism, I'll delay for 1/30th second to
simulate a graphics update process.
#define SL_DEFAULT_SAMPLING_RATE 11025
-/* Set if the next slScheduler::update will die */
-extern char *__slPendingError ;
-
class slSample ;
class slSamplePlayer ;
class slEnvelope ;
class slScheduler ;
class slDSP ;
+extern char *__slPendingError ;
+
class slDSP
{
private:
~slSample ()
{
- if ( ref_count != 0 )
- {
- if ( __slPendingError == NULL )
+ if ( ref_count != 0 && __slPendingError == NULL )
__slPendingError =
- "slXXXX: FATAL ERROR - Application deleted a sample while it was playing.\n" ;
- }
+ "slSample: FATAL ERROR - Application deleted a sample while it was playing.\n" ;
delete buffer ;
}
~slEnvelope ()
{
- if ( ref_count != 0 )
- {
- if ( __slPendingError == NULL )
+ if ( ref_count != 0 && __slPendingError == NULL )
__slPendingError =
- "slXXXX: FATAL ERROR - Application deleted an envelope while it was playing.\n" ;
- }
+ "slEnvelope: FATAL ERROR - Application deleted an envelope while it was playing.\n" ;
delete time ;
delete value ;
void slDSP::stop ()
{
+ if ( error )
+ return ;
+
waveOutReset( hWaveOut );
}
void slDSP::sync ()
{
+ if ( error )
+ return ;
+
/* found this in the header file - but no description
* or example for the long parameter.
*/
#include "sl.h"
-slScheduler *slScheduler::current = NULL ;
char *__slPendingError = NULL ;
+slScheduler *slScheduler::current = NULL ;
+
void slScheduler::init ()
{
current = this ;
void slScheduler::initBuffers ()
{
- if ( not_working () ) return ;
+ if ( not_working () )
+ return ;
delete mixer_buffer ;
delete spare_buffer0 ;
void slScheduler::realUpdate ( int dump_first )
{
- int i ;
-
if ( not_working () )
return ;
if ( __slPendingError != NULL )
{
- fprintf ( stderr, __slPendingError ) ;
- exit ( 1 ) ;
+ fprintf ( stderr, "%s", __slPendingError ) ;
+ exit ( 1 ) ;
}
+ int i ;
+
while ( secondsUsed() <= safety_margin )
{
slSamplePlayer *psp [ 3 ] ;
void slScheduler::addCallBack ( slCallBack c, slSample *s, slEvent e, int m )
{
+ if ( not_working () )
+ return ;
+
if ( num_pending_callbacks >= SL_MAX_CALLBACKS )
{
fprintf ( stderr, "slScheduler: Too many pending callback events!\n" ) ;
void slScheduler::flushCallBacks ()
{
+ if ( not_working () )
+ return ;
+
/*
Execute all the callbacks that we accumulated
in this iteration.