]> git.mxchange.org Git - simgear.git/blobdiff - simgear/sound/sample_openal.hxx
Logging - downgrade play/stop messages to debug.
[simgear.git] / simgear / sound / sample_openal.hxx
index 905ce8a106b49ba427dce11dc57b85be04b4b0cd..1131981bf70a61a17ed8acd65dfe5b4282c308d7 100644 (file)
@@ -16,7 +16,7 @@
 //
 // You should have received a copy of the GNU General Public License
 // along with this program; if not, write to the Free Software
-// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 //
 // $Id$
 
 
 #include <simgear/compiler.h>
 
-#include STL_STRING
+#include <string>
 
 #include <simgear/debug/logstream.hxx>
+#include <simgear/structure/SGReferenced.hxx>
+#include <simgear/structure/SGSharedPtr.hxx>
 
 #include <plib/sg.h>
 
 # include <AL/alut.h>
 #endif
 
-SG_USING_STD(string);
+#ifndef HAVE_WINDOWS_H
+ #ifdef AL_VERSION_1_2
+  #define USE_OPEN_AL_DOPPLER should work
+ #else
+  #define USE_OPEN_AL_DOPPLER_WITH_FIXED_LISTENER better than nothing
+ #endif
+#else
+ // the Open_AL Doppler calculation seems to be buggy on windows
+ #define USE_SOFTWARE_DOPPLER seem to be necessary
+#endif
+
+using std::string;
 
 /**
  * manages everything we need to know for an individual sound sample
  */
 
-class SGSoundSample {
+class SGSoundSample : public SGReferenced {
 
 private:
 
@@ -88,12 +101,17 @@ private:
 
     double pitch;
     double volume;
+#ifdef USE_SOFTWARE_DOPPLER
+    double doppler_pitch_factor;
+    double doppler_volume_factor;
+#endif
     double reference_dist;
     double max_dist;
     ALboolean loop;
 
     bool playing;
     bool bind_source();
+    bool no_Doppler_effect;
 
 public:
 
@@ -110,24 +128,25 @@ public:
        should usually be true unless you want to manipulate the data
        later.)
      */
-    SGSoundSample( const char *path, const char *file );
+    SGSoundSample( const char *path, const char *file, bool no_Doppler_effect = true );
 
     /**
      * Constructor.
      * @param _data Pointer to a memory buffer containing the sample data
+       the application is responsible for freeing the buffer data.
      * @param len Byte length of array
      * @param _freq Frequency of the provided data (bytes per second)
        should usually be true unless you want to manipulate the data
        later.)
      */
-    SGSoundSample( unsigned char *_data, int len, int _freq );
+    SGSoundSample( unsigned char *_data, int len, int _freq, bool no_Doppler_effect = true );
 
     ~SGSoundSample();
 
     /**
      * Start playing this sample.
      *
-     * @param _loop Define wether the sound should be played in a loop.
+     * @param _loop Define whether the sound should be played in a loop.
      */
     void play( bool _loop );
 
@@ -151,7 +170,7 @@ public:
     inline void play_looped() { play(true); }
 
     /**
-     * Test if a sample is curretnly playing.
+     * Test if a sample is currently playing.
      * @return true if is is playing, false otherwise.
      */
     bool is_playing( );
@@ -205,7 +224,7 @@ public:
     /**
      * Set velocity of sound source (uses same coordinate system as opengl)
      */
-    void set_source_vel( ALfloat *vel );
+    void set_source_vel( ALfloat *vel, ALfloat *listener_vel );
 
 
     /**
@@ -216,7 +235,7 @@ public:
 
 
     /**
-     * Set maximume distance of sound (the distance where the sound is
+     * Set maximum distance of sound (the distance where the sound is
      * no longer audible.
      */
     void set_max_dist( ALfloat dist );