]> git.mxchange.org Git - simgear.git/blobdiff - simgear/sound/sample_openal.hxx
math: Move lerp function into SGMisc.
[simgear.git] / simgear / sound / sample_openal.hxx
index 362915b0929d3808391b0f6df9148665d74f03b1..a231f6633a6dc3afe91c9a08f6a393026e031d4c 100644 (file)
@@ -35,6 +35,7 @@
 #endif
 
 #include <string>
+#include <cstdlib>
 
 #include <simgear/compiler.h>
 #include <simgear/debug/logstream.hxx>
@@ -42,6 +43,7 @@
 #include <simgear/structure/SGSharedPtr.hxx>
 #include <simgear/math/SGMath.hxx>
 
+class SGPath;
 
 /**
  * manages everything we need to know for an individual audio sample
@@ -58,11 +60,10 @@ public:
 
     /**
      * Constructor
-     * @param path Path name to sound
      * @param file File name of sound
        Buffer data is freed by the sample group
      */
-    SGSoundSample( const char *path, const char *file );
+    SGSoundSample(const char *file, const SGPath& currentDir);
 
     /**
      * Constructor.
@@ -81,14 +82,16 @@ public:
     /**
      * Destructor
      */
-    ~SGSoundSample ();
+    virtual ~SGSoundSample ();
 
     /**
-     * Detect wheter this audio sample holds the information of a sound file.
+     * Detect whether this audio sample holds the information of a sound file.
      * @return Return true if this audio sample is to be constructed from a file.
      */
     inline bool is_file() const { return _is_file; }
 
+    SGPath file_path() const;
+
     /**
      * Test if this audio sample configuration has changed since the last call.
      * Calling this function will reset the flag so calling it a second
@@ -100,7 +103,7 @@ public:
     }
 
     /**
-     * Test if static dataa of audio sample configuration has changed.
+     * Test if static data of audio sample configuration has changed.
      * Calling this function will reset the flag so calling it a second
      * time in a row will return false.
      * @return Return true is the static data has changed in the mean time.
@@ -115,7 +118,7 @@ public:
      * @param _loop Define whether this sound should be played in a loop.
      */
     void play( bool loop = false ) {
-        _playing = true; _loop = loop; _changed = true;
+        _playing = true; _loop = loop; _changed = true; _static_changed = true;
     }
 
     /**
@@ -149,6 +152,22 @@ public:
      */
     inline bool is_playing() { return _playing; }
 
+
+    /**
+     * Set this sample to out-of-range (or not) and
+     * Schedule this audio sample to stop (or start) playing.
+     */
+    inline void set_out_of_range(bool oor = true) {
+        _out_of_range = oor; _playing = (!oor && _loop); _changed = true;
+    }
+
+    /**
+     * Test if this sample to out-of-range or not.
+     */
+    inline bool test_out_of_range() {
+        return _out_of_range;
+    }
+
     /**
      * Set the data associated with this audio sample
      * @param data Pointer to a memory block containg this audio sample data.
@@ -492,6 +511,7 @@ private:
     bool _playing;
     bool _changed;
     bool _static_changed;
+    bool _out_of_range;
     bool _is_file;
 
     string random_string();