Udates from Steve.

This commit is contained in:
curt 1998-10-02 21:35:09 +00:00
parent 9ae48c2d7d
commit 11cab90ce2
5 changed files with 37 additions and 44 deletions

View File

@ -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
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

View File

@ -55,39 +55,15 @@ int main ()
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.

View File

@ -24,15 +24,14 @@ typedef unsigned short Ushort ;
#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:
@ -167,12 +166,9 @@ public:
~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 ;
}
@ -331,12 +327,9 @@ public:
~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 ;

View File

@ -336,6 +336,9 @@ void slDSP::sync ()
void slDSP::stop ()
{
if ( error )
return ;
waveOutReset( hWaveOut );
}
@ -647,6 +650,9 @@ float slDSP::secondsUsed ()
void slDSP::sync ()
{
if ( error )
return ;
/* found this in the header file - but no description
* or example for the long parameter.
*/

View File

@ -1,9 +1,10 @@
#include "sl.h"
slScheduler *slScheduler::current = NULL ;
char *__slPendingError = NULL ;
slScheduler *slScheduler::current = NULL ;
void slScheduler::init ()
{
current = this ;
@ -49,7 +50,8 @@ void slScheduler::init ()
void slScheduler::initBuffers ()
{
if ( not_working () ) return ;
if ( not_working () )
return ;
delete mixer_buffer ;
delete spare_buffer0 ;
@ -118,17 +120,17 @@ void slScheduler::mixBuffer ( slSamplePlayer *spa, slSamplePlayer *spb,
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 ] ;
@ -208,6 +210,9 @@ void slScheduler::realUpdate ( int dump_first )
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" ) ;
@ -224,6 +229,9 @@ void slScheduler::addCallBack ( slCallBack c, slSample *s, slEvent e, int m )
void slScheduler::flushCallBacks ()
{
if ( not_working () )
return ;
/*
Execute all the callbacks that we accumulated
in this iteration.