Go to the documentation of this file.00001
00002
00003 #ifndef _SOUND_MANAGER_H_
00004 #define _SOUND_MANAGER_H_
00005
00006 #include <EngineConfig.h>
00007 #include <core/Types.h>
00008 #include <core/Singleton.h>
00009 #include <engine/EngineSettings.h>
00010 #include <resource/Resource.h>
00011 #include <resource/ResourceManager.h>
00012 #include <sound/SoundDriver.h>
00013 #include <engine/Object.h>
00014
00015 #include <string>
00016 #include <list>
00017 #include <map>
00018
00019 namespace core
00020 {
00021 class vector3d;
00022 class quaternion;
00023 }
00024
00025 namespace scene
00026 {
00027 class Node;
00028 }
00029
00030 namespace sound
00031 {
00032
00033 class Sound;
00034 class SoundData;
00035 class Listener;
00036 class SoundDriver;
00037 class SoundFactory;
00038
00044 class ENGINE_PUBLIC_EXPORT SoundManager: public engine::Object, public core::Singleton<SoundManager>
00045 {
00046 friend class ResourceManager;
00047
00048 public:
00049
00050
00051 SoundManager();
00052
00053 ~SoundManager();
00054
00055 void start();
00056
00057 void stop();
00058
00060 void initializeObjects();
00061
00063 Sound* createSound(const std::string& filename, scene::Node* parent = NULL);
00064 Sound* createSound(const std::string& name, const std::string& filename, scene::Node* parent = NULL);
00065
00066 Sound* createSound(SoundData* soundData, scene::Node* parent = NULL);
00067 Sound* createSound(const std::string& name, SoundData* soundData, scene::Node* parent = NULL);
00068
00070 Sound* getSound(const u32& id);
00071
00073 u32 getNumberOfSounds() const;
00074
00076 void removeSound(Sound *sound);
00078 void removeSound(const u32& id);
00080 void removeAllSounds();
00081
00082
00084 Listener* createListener(scene::Node* parent = NULL);
00085 Listener* createListener(const std::string& name, scene::Node* parent = NULL);
00086
00088 void setActiveListener(Listener *listener);
00089
00091 Listener* getActiveListener();
00092
00094 Listener* getListener(const u32& id);
00095
00097 u32 getNumberOfListeners() const;
00098
00100 void removeListener(Listener *listener);
00102 void removeListener(const u32& id);
00103
00105 void removeAllListeners();
00106
00111 void setDopplerFactor(f32 dopplerFactor);
00113 f32 getDopplerFactor() const;
00114
00118 void setSoundSpeed(f32 soundSpeed);
00120 f32 getSoundSpeed() const;
00121
00122 void setSoundDriver(SoundDriver* driver);
00123 void removeSoundDriver();
00124
00125 void setSoundFactory(SoundFactory* factory);
00126 void removeSoundFactory();
00127
00128 static SoundManager* getInstance();
00129
00130 protected:
00131
00132 void initializeImpl();
00133 void uninitializeImpl();
00134 void updateImpl(f32 elapsedTime);
00135
00136 SoundDriver* mSoundDriver;
00137
00139 std::map<u32, Sound*> mSounds;
00140
00142 std::map<u32, Listener*> mListeners;
00143 Listener* mActiveListener;
00144
00145 SoundFactory* mSoundFactory;
00146
00147 f32 mDopplerFactor;
00148 f32 mSoundSpeed;
00149 };
00150
00151 }
00152
00153 #endif