1 // soundmgr.hxx -- Sound effect management class
3 // Sound manager initially written by David Findlay
4 // <david_j_findlay@yahoo.com.au> 2001
6 // C++-ified by Curtis Olson, started March 2001.
8 // Copyright (C) 2001 Curtis L. Olson - curt@flightgear.org
10 // This program is free software; you can redistribute it and/or
11 // modify it under the terms of the GNU General Public License as
12 // published by the Free Software Foundation; either version 2 of the
13 // License, or (at your option) any later version.
15 // This program is distributed in the hope that it will be useful, but
16 // WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 // General Public License for more details.
20 // You should have received a copy of the GNU General Public License
21 // along with this program; if not, write to the Free Software
22 // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
28 * Provides a sound manager class to keep track of
29 * multiple sounds and manage playing them with different effects and
33 #ifndef _SG_SOUNDMGR_OPENAL_HXX
34 #define _SG_SOUNDMGR_OPENAL_HXX 1
37 # error This library requires C++
40 #include <simgear/compiler.h>
47 #include "sample_openal.hxx"
53 typedef map < string, SGSoundSample * > sample_map;
54 typedef sample_map::iterator sample_map_iterator;
55 typedef sample_map::const_iterator const_sample_map_iterator;
59 * Manage a collection of SGSoundSample instances
64 // Position of the listener.
65 ALfloat listener_pos[3];
67 // Velocity of the listener.
68 ALfloat listener_vel[3];
70 // Orientation of the listener. (first 3 elements are "at", second
72 ALfloat listener_ori[6];
86 * (re) initialize the sound manager.
92 * Bind properties for the sound manager.
98 * Unbind properties for the sound manager.
104 * Run the audio scheduler.
106 void update(double dt);
124 inline bool is_working() const { return working; }
127 * reinitialize the sound manager
129 inline void reinit() { init(); }
132 * add a sound effect, return true if successful
134 bool add( SGSoundSample *sound, const string& refname);
137 * remove a sound effect, return true if successful
139 bool remove( const string& refname );
142 * return true of the specified sound exists in the sound manager system
144 bool exists( const string& refname );
147 * return a pointer to the SGSoundSample if the specified sound
148 * exists in the sound manager system, otherwise return NULL
150 SGSoundSample *find( const string& refname );
153 * tell the scheduler to play the indexed sample in a continuous
156 bool play_looped( const string& refname );
159 * tell the scheduler to play the indexed sample once
161 bool play_once( const string& refname );
164 * return true of the specified sound is currently being played
166 bool is_playing( const string& refname );
169 * immediate stop playing the sound
171 bool stop( const string& refname );
175 #endif // _SG_SOUNDMGR_OPENAL_HXX