]> git.mxchange.org Git - simgear.git/blobdiff - src/sl.h
Removed gpc from Libs since this is not "free ware" and the author has
[simgear.git] / src / sl.h
index 79b63e65f44ed42d678e577a2adc1fc9e785cce7..5cbbc2adfba1ea31b0e8b20d8ad1c39d6d5999bd 100644 (file)
--- a/src/sl.h
+++ b/src/sl.h
@@ -30,6 +30,8 @@ class slEnvelope     ;
 class slScheduler    ;
 class slDSP          ;
 
+extern char *__slPendingError ;
+
 class slDSP
 {
 private:
@@ -109,6 +111,7 @@ public:
 
   void play ( void *buffer, size_t length ) { write ( buffer, length ) ; } 
 
+  int working () { return !error ; }
   int not_working () { return error ; }
 
   int getBps   () { return bps    ; }
@@ -163,12 +166,9 @@ public:
 
  ~slSample ()
   {
-    if ( ref_count != 0 )
-    {
-      fprintf ( stderr,
-        "slSample: FATAL ERROR - Application deleted a sample while it was playing.\n" ) ;
-      exit ( 1 ) ;
-    }
+    if ( ref_count != 0 && __slPendingError == NULL )
+      __slPendingError =
+        "slSample: FATAL ERROR - Application deleted a sample while it was playing.\n" ;
 
     delete buffer ;
   }
@@ -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 ;
@@ -324,12 +327,9 @@ public:
  
  ~slEnvelope ()
   {
-    if ( ref_count != 0 )
-    {
-      fprintf ( stderr,
-        "slEnvelope: FATAL ERROR - Application deleted an envelope while it was playing.\n" ) ;
-      exit ( 1 ) ;
-    }
+    if ( ref_count != 0 && __slPendingError == NULL )
+      __slPendingError =
+      "slEnvelope: FATAL ERROR - Application deleted an envelope while it was playing.\n" ;
 
     delete time ;
     delete value ;
@@ -356,6 +356,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 +388,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 +404,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 +433,6 @@ public:
 
   ~slSamplePlayer () ;
 
-  int getAmountLeft ()
-  {
-    return lengthRemaining ;
-  }
-
   slPreemptMode getPreemptMode () { return preempt_mode ; }
 
   int getPriority ()
@@ -488,8 +487,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 +498,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 ) ;