| 1 | // soundmanager.hxx -- Wraps the SimGear OpenAl sound manager class |
| 2 | // |
| 3 | // Copyright (C) 2001 Curtis L. Olson - http://www.flightgear.org/~curt |
| 4 | // |
| 5 | // This program is free software; you can redistribute it and/or |
| 6 | // modify it under the terms of the GNU General Public License as |
| 7 | // published by the Free Software Foundation; either version 2 of the |
| 8 | // License, or (at your option) any later version. |
| 9 | // |
| 10 | // This program is distributed in the hope that it will be useful, but |
| 11 | // WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 13 | // General Public License for more details. |
| 14 | // |
| 15 | // You should have received a copy of the GNU General Public License |
| 16 | // along with this program; if not, write to the Free Software |
| 17 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
| 18 | // |
| 19 | |
| 20 | #ifndef __FG_SOUNDMGR_HXX |
| 21 | #define __FG_SOUNDMGR_HXX 1 |
| 22 | |
| 23 | #include <memory> |
| 24 | #include <map> |
| 25 | #include <simgear/props/props.hxx> |
| 26 | #include <simgear/structure/subsystem_mgr.hxx> |
| 27 | #include <simgear/sound/soundmgr.hxx> |
| 28 | |
| 29 | class FGSampleQueue; |
| 30 | class SGSoundMgr; |
| 31 | class Listener; |
| 32 | class VoiceSynthesizer; |
| 33 | |
| 34 | #ifdef ENABLE_AUDIO_SUPPORT |
| 35 | class FGSoundManager : public SGSoundMgr |
| 36 | { |
| 37 | public: |
| 38 | FGSoundManager(); |
| 39 | virtual ~FGSoundManager(); |
| 40 | |
| 41 | // Subsystem API. |
| 42 | void init() override; |
| 43 | void reinit() override; |
| 44 | void shutdown() override; |
| 45 | void update(double dt) override; |
| 46 | |
| 47 | // Subsystem identification. |
| 48 | static const char* staticSubsystemClassId() { return "sound"; } |
| 49 | |
| 50 | void activate(bool State); |
| 51 | void update_device_list(); |
| 52 | |
| 53 | VoiceSynthesizer * getSynthesizer( const std::string & voice ); |
| 54 | |
| 55 | private: |
| 56 | bool stationaryView() const; |
| 57 | |
| 58 | bool playAudioSampleCommand(const SGPropertyNode * arg, SGPropertyNode * root); |
| 59 | |
| 60 | std::map<std::string,SGSharedPtr<FGSampleQueue>> _queue; |
| 61 | |
| 62 | double _active_dt; |
| 63 | bool _is_initialized, _enabled; |
| 64 | SGPropertyNode_ptr _sound_working, _sound_enabled, _volume, _device_name; |
| 65 | SGPropertyNode_ptr _velocityNorthFPS, _velocityEastFPS, _velocityDownFPS; |
| 66 | SGPropertyNode_ptr _frozen; |
| 67 | std::unique_ptr<Listener> _listener; |
| 68 | |
| 69 | std::map<std::string,VoiceSynthesizer*> _synthesizers; |
| 70 | }; |
| 71 | #else |
| 72 | #include "Main/fg_props.hxx" |
| 73 | |
| 74 | // provide a dummy sound class |
| 75 | class FGSoundManager : public SGSubsystem |
| 76 | { |
| 77 | public: |
| 78 | FGSoundManager() { fgSetBool("/sim/sound/working", false);} |
| 79 | ~FGSoundManager() {} |
| 80 | |
| 81 | // Subsystem API. |
| 82 | void update(double dt) {} override |
| 83 | |
| 84 | // Subsystem identification. |
| 85 | static const char* staticSubsystemClassId() { return "sound"; } |
| 86 | }; |
| 87 | |
| 88 | #endif // ENABLE_AUDIO_SUPPORT |
| 89 | |
| 90 | #endif // __FG_SOUNDMGR_HXX |