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.
34 #include <simgear/compiler.h>
46 // manages everything we need to know for an individual sound sample
50 slEnvelope *pitch_envelope;
51 slEnvelope *volume_envelope;
57 FGSimpleSound( string file );
60 inline double get_pitch() const { return pitch; }
61 inline void set_pitch( double p ) {
63 pitch_envelope->setStep( 0, 0.01, pitch );
65 inline double get_volume() const { return volume; }
66 inline void set_volume( double v ) {
68 volume_envelope->setStep( 0, 0.01, volume );
71 inline slSample *get_sample() { return sample; }
72 inline slEnvelope *get_pitch_envelope() { return pitch_envelope; }
73 inline slEnvelope *get_volume_envelope() { return volume_envelope; }
77 typedef map < string, FGSimpleSound * > sound_map;
78 typedef sound_map::iterator sound_map_iterator;
79 typedef sound_map::const_iterator const_sound_map_iterator;
84 slScheduler *audio_sched;
93 // initialize the sound manager
96 // run the audio scheduler
100 inline bool is_working() const { return !audio_sched->not_working(); }
102 // add a sound effect, return the index of the sound
103 bool add( FGSimpleSound *sound, const string& refname );
105 // tell the scheduler to play the indexed sample in a continuous
107 bool play_looped( const string& refname );
109 // tell the scheduler to play the indexed sample once
110 bool play_once( const string& refname );
114 #endif // _SOUNDMGR_HXX