]> git.mxchange.org Git - simgear.git/blobdiff - simgear/sound/soundmgr_openal.hxx
MINGW patch by Csaba Halasz
[simgear.git] / simgear / sound / soundmgr_openal.hxx
index 8fe1f67cce60801f4c0d865fb5d02e50ccba7c65..477386e53b249115bcb2223e0254677f802690cf 100644 (file)
@@ -5,7 +5,7 @@
 //
 // C++-ified by Curtis Olson, started March 2001.
 //
-// Copyright (C) 2001  Curtis L. Olson - curt@flightgear.org
+// Copyright (C) 2001  Curtis L. Olson - http://www.flightgear.org/~curt
 //
 // This program is free software; you can redistribute it and/or
 // modify it under the terms of the GNU General Public License as
@@ -19,7 +19,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 <map>
 
 #if defined( __APPLE__ )
 # include <OpenAL/al.h>
+# include <OpenAL/alc.h>
 #else
 # include <AL/al.h>
+# include <AL/alc.h>
 #endif
 
 #include "sample_openal.hxx"
 
-SG_USING_STD(map);
-SG_USING_STD(string);
+using std::map;
+using std::string;
 
 
-typedef map < string, SGSoundSample * > sample_map;
+typedef map < string, SGSharedPtr<SGSoundSample> > sample_map;
 typedef sample_map::iterator sample_map_iterator;
 typedef sample_map::const_iterator const_sample_map_iterator;
 
@@ -65,6 +67,9 @@ typedef sample_map::const_iterator const_sample_map_iterator;
 class SGSoundMgr
 {
 
+    ALCdevice *dev;
+    ALCcontext *context;
+
     // Position of the listener.
     ALfloat listener_pos[3];
 
@@ -173,6 +178,69 @@ public:
      * immediate stop playing the sound
      */
     bool stop( const string& refname );
+
+    /**
+     * set overall volume for the application.
+     * @param vol 1.0 is default, must be greater than 0
+     */
+    inline void set_volume( const ALfloat vol ) {
+        if ( vol > 0.0 ) {
+            alListenerf( AL_GAIN, vol );
+        }
+    }
+
+    /**
+     * set the position of the listener (in opengl coordinates)
+     */
+    inline void set_listener_pos( ALfloat *pos ) {
+        listener_pos[0] = pos[0];
+        listener_pos[1] = pos[1];
+        listener_pos[2] = pos[2];
+        alListenerfv( AL_POSITION, listener_pos );
+    }
+
+    /**
+     * set the velocity of the listener (in opengl coordinates)
+     */
+    inline void set_listener_vel( ALfloat *vel ) {
+        listener_vel[0] = vel[0];
+        listener_vel[1] = vel[1];
+        listener_vel[2] = vel[2];
+#ifdef USE_OPEN_AL_DOPPLER
+        alListenerfv( AL_VELOCITY, listener_vel );
+#endif
+    }
+
+    /**
+     * set the orientation of the listener (in opengl coordinates)
+     *
+     * Description: ORIENTATION is a pair of 3-tuples representing the
+     * 'at' direction vector and 'up' direction of the Object in
+     * Cartesian space. AL expects two vectors that are orthogonal to
+     * each other. These vectors are not expected to be normalized. If
+     * one or more vectors have zero length, implementation behavior
+     * is undefined. If the two vectors are linearly dependent,
+     * behavior is undefined.
+     */
+    inline void set_listener_orientation( ALfloat *ori ) {
+        listener_ori[0] = ori[0];
+        listener_ori[1] = ori[1];
+        listener_ori[2] = ori[2];
+        listener_ori[3] = ori[3];
+        listener_ori[4] = ori[4];
+        listener_ori[5] = ori[5];
+        alListenerfv( AL_ORIENTATION, listener_ori );
+    }
+
+    /**
+     * set the positions of all managaged sound sources 
+     */
+    void set_source_pos_all( ALfloat *pos );
+
+    /**
+     * set the velocities of all managaged sound sources 
+     */
+    void set_source_vel_all( ALfloat *pos );
 };