Udates from Steve.
This commit is contained in:
parent
9ae48c2d7d
commit
11cab90ce2
5 changed files with 37 additions and 44 deletions
|
@ -9,12 +9,22 @@
|
||||||
* *
|
* *
|
||||||
\**********************************************/
|
\**********************************************/
|
||||||
|
|
||||||
|
* 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
|
* 23rd Sept 1998 -- The Good News: Finally got around to
|
||||||
getting the pitch envelope working. (Hooray)
|
getting the pitch envelope working. (Hooray)
|
||||||
The Bad News: This costs quite a bit in
|
The Bad News: This costs quite a bit in
|
||||||
performance - and it was a MAJOR rewrite
|
performance - and it was a MAJOR rewrite
|
||||||
of significant parts of the internals,
|
of significant parts of the internals,
|
||||||
so we may need some bug fixes.
|
so we may need some bug fixes.
|
||||||
|
This version is 0.5
|
||||||
|
|
||||||
* 7th July 1998 -- Fixed some error checking in slSample.cxx and
|
* 7th July 1998 -- Fixed some error checking in slSample.cxx and
|
||||||
a missing declaration in sl.h
|
a missing declaration in sl.h
|
||||||
|
|
|
@ -55,13 +55,8 @@ int main ()
|
||||||
|
|
||||||
int tim = 0 ; /* My periodic event timer. */
|
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 )
|
while ( SL_TRUE )
|
||||||
{
|
{
|
||||||
|
|
||||||
tim++ ; /* Time passes */
|
tim++ ; /* Time passes */
|
||||||
|
|
||||||
if ( tim % 200 == 0 ) sched.playSample ( s1 ) ;
|
if ( tim % 200 == 0 ) sched.playSample ( s1 ) ;
|
||||||
|
@ -69,25 +64,6 @@ int main ()
|
||||||
if ( tim % 150 == 0 ) sched.playSample ( s3 ) ;
|
if ( tim % 150 == 0 ) sched.playSample ( s3 ) ;
|
||||||
if ( tim % 120 == 0 ) sched.playSample ( s4 ) ;
|
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
|
For the sake of realism, I'll delay for 1/30th second to
|
||||||
simulate a graphics update process.
|
simulate a graphics update process.
|
||||||
|
|
19
src/sl.h
19
src/sl.h
|
@ -24,15 +24,14 @@ typedef unsigned short Ushort ;
|
||||||
|
|
||||||
#define SL_DEFAULT_SAMPLING_RATE 11025
|
#define SL_DEFAULT_SAMPLING_RATE 11025
|
||||||
|
|
||||||
/* Set if the next slScheduler::update will die */
|
|
||||||
extern char *__slPendingError ;
|
|
||||||
|
|
||||||
class slSample ;
|
class slSample ;
|
||||||
class slSamplePlayer ;
|
class slSamplePlayer ;
|
||||||
class slEnvelope ;
|
class slEnvelope ;
|
||||||
class slScheduler ;
|
class slScheduler ;
|
||||||
class slDSP ;
|
class slDSP ;
|
||||||
|
|
||||||
|
extern char *__slPendingError ;
|
||||||
|
|
||||||
class slDSP
|
class slDSP
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
|
@ -167,12 +166,9 @@ public:
|
||||||
|
|
||||||
~slSample ()
|
~slSample ()
|
||||||
{
|
{
|
||||||
if ( ref_count != 0 )
|
if ( ref_count != 0 && __slPendingError == NULL )
|
||||||
{
|
|
||||||
if ( __slPendingError == NULL )
|
|
||||||
__slPendingError =
|
__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 ;
|
delete buffer ;
|
||||||
}
|
}
|
||||||
|
@ -331,12 +327,9 @@ public:
|
||||||
|
|
||||||
~slEnvelope ()
|
~slEnvelope ()
|
||||||
{
|
{
|
||||||
if ( ref_count != 0 )
|
if ( ref_count != 0 && __slPendingError == NULL )
|
||||||
{
|
|
||||||
if ( __slPendingError == NULL )
|
|
||||||
__slPendingError =
|
__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 time ;
|
||||||
delete value ;
|
delete value ;
|
||||||
|
|
|
@ -336,6 +336,9 @@ void slDSP::sync ()
|
||||||
|
|
||||||
void slDSP::stop ()
|
void slDSP::stop ()
|
||||||
{
|
{
|
||||||
|
if ( error )
|
||||||
|
return ;
|
||||||
|
|
||||||
waveOutReset( hWaveOut );
|
waveOutReset( hWaveOut );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -647,6 +650,9 @@ float slDSP::secondsUsed ()
|
||||||
|
|
||||||
void slDSP::sync ()
|
void slDSP::sync ()
|
||||||
{
|
{
|
||||||
|
if ( error )
|
||||||
|
return ;
|
||||||
|
|
||||||
/* found this in the header file - but no description
|
/* found this in the header file - but no description
|
||||||
* or example for the long parameter.
|
* or example for the long parameter.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
|
|
||||||
#include "sl.h"
|
#include "sl.h"
|
||||||
|
|
||||||
slScheduler *slScheduler::current = NULL ;
|
|
||||||
char *__slPendingError = NULL ;
|
char *__slPendingError = NULL ;
|
||||||
|
|
||||||
|
slScheduler *slScheduler::current = NULL ;
|
||||||
|
|
||||||
void slScheduler::init ()
|
void slScheduler::init ()
|
||||||
{
|
{
|
||||||
current = this ;
|
current = this ;
|
||||||
|
@ -49,7 +50,8 @@ void slScheduler::init ()
|
||||||
|
|
||||||
void slScheduler::initBuffers ()
|
void slScheduler::initBuffers ()
|
||||||
{
|
{
|
||||||
if ( not_working () ) return ;
|
if ( not_working () )
|
||||||
|
return ;
|
||||||
|
|
||||||
delete mixer_buffer ;
|
delete mixer_buffer ;
|
||||||
delete spare_buffer0 ;
|
delete spare_buffer0 ;
|
||||||
|
@ -118,17 +120,17 @@ void slScheduler::mixBuffer ( slSamplePlayer *spa, slSamplePlayer *spb,
|
||||||
|
|
||||||
void slScheduler::realUpdate ( int dump_first )
|
void slScheduler::realUpdate ( int dump_first )
|
||||||
{
|
{
|
||||||
int i ;
|
|
||||||
|
|
||||||
if ( not_working () )
|
if ( not_working () )
|
||||||
return ;
|
return ;
|
||||||
|
|
||||||
if ( __slPendingError != NULL )
|
if ( __slPendingError != NULL )
|
||||||
{
|
{
|
||||||
fprintf ( stderr, __slPendingError ) ;
|
fprintf ( stderr, "%s", __slPendingError ) ;
|
||||||
exit ( 1 ) ;
|
exit ( 1 ) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int i ;
|
||||||
|
|
||||||
while ( secondsUsed() <= safety_margin )
|
while ( secondsUsed() <= safety_margin )
|
||||||
{
|
{
|
||||||
slSamplePlayer *psp [ 3 ] ;
|
slSamplePlayer *psp [ 3 ] ;
|
||||||
|
@ -208,6 +210,9 @@ void slScheduler::realUpdate ( int dump_first )
|
||||||
|
|
||||||
void slScheduler::addCallBack ( slCallBack c, slSample *s, slEvent e, int m )
|
void slScheduler::addCallBack ( slCallBack c, slSample *s, slEvent e, int m )
|
||||||
{
|
{
|
||||||
|
if ( not_working () )
|
||||||
|
return ;
|
||||||
|
|
||||||
if ( num_pending_callbacks >= SL_MAX_CALLBACKS )
|
if ( num_pending_callbacks >= SL_MAX_CALLBACKS )
|
||||||
{
|
{
|
||||||
fprintf ( stderr, "slScheduler: Too many pending callback events!\n" ) ;
|
fprintf ( stderr, "slScheduler: Too many pending callback events!\n" ) ;
|
||||||
|
@ -224,6 +229,9 @@ void slScheduler::addCallBack ( slCallBack c, slSample *s, slEvent e, int m )
|
||||||
|
|
||||||
void slScheduler::flushCallBacks ()
|
void slScheduler::flushCallBacks ()
|
||||||
{
|
{
|
||||||
|
if ( not_working () )
|
||||||
|
return ;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Execute all the callbacks that we accumulated
|
Execute all the callbacks that we accumulated
|
||||||
in this iteration.
|
in this iteration.
|
||||||
|
|
Loading…
Reference in a new issue