Planeshift
manager.h
Go to the documentation of this file.
1 /*
2  * manager.h
3  *
4  * Copyright (C) 2001-2010 Atomic Blue (info@planeshift.it, http://www.planeshift.it)
5  *
6  * Credits : Saul Leite <leite@engineer.com>
7  * Mathias 'AgY' Voeroes <agy@operswithoutlife.net>
8  * and all past and present planeshift coders
9  *
10  * This program is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU General Public License
12  * as published by the Free Software Foundation (version 2 of the License.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21  *
22  */
23 
24 #ifndef _SOUND_MANAGER_H_
25 #define _SOUND_MANAGER_H_
26 
27 #include <cssysdef.h>
28 #include <iutil/objreg.h>
29 #include <csgeom/vector3.h>
30 #include <csutil/parray.h>
31 
32 class SoundSystem;
33 class SoundData;
34 class SoundHandle;
35 class SoundControl;
36 
37 enum
38 {
39  LOOP = true,
40  DONT_LOOP = false
41 };
42 
43 
44 #define VOLUME_ZERO 0.0f
45 #define VOLUME_MIN 0.0f
46 #define VOLUME_NORM 1.0f
47 #define VOLUME_MAX 2.0f
48 
63 {
64  public:
65  bool Initialised;
69 
78  SoundSystemManager (iObjectRegistry* objectReg);
86 
90  void UpdateSound ();
91 
102  bool Play2DSound (const char *name, bool loop, size_t loopstart,
103  size_t loopend, float volume_preset,
104  SoundControl* &sndCtrl, SoundHandle * &handle);
105 
122  bool Play3DSound (const char *name, bool loop, size_t loopstart,
123  size_t loopend, float volume_preset,
124  SoundControl* &sndCtrl, csVector3 pos, csVector3 dir,
125  float mindist, float maxdist, float rad, int type3d,
126  SoundHandle * &handle);
127 
133  void StopSound (SoundHandle *handle);
134 
141  void UpdateListener (csVector3 v, csVector3 f, csVector3 t);
142 
148  void Update ();
156 
157  SoundSystem* GetSoundSystem() { return soundSystem; }
158  SoundData* GetSoundData() { return soundData; }
159 
160  private:
161  SoundSystem *soundSystem;
162  SoundData *soundData;
163  csPDelArray<SoundControl> soundController;
164 
165  csPDelArray<SoundHandle> soundHandles;
166 
167  csTicks SndTime;
168  csTicks LastUpdateTime;
169 };
170 
171 #endif /*_SOUND_MANAGER_H_*/
SoundData is the datakeeper of.
Definition: data.h:141
Definition: manager.h:39
SoundControl * guiSndCtrl
sound control for paws / gui
Definition: manager.h:67
~SoundSystemManager()
Destructor will remove everything this SoundManager created.
SoundControl * effectSndCtrl
sound control for effects / actions
Definition: manager.h:68
bool Play3DSound(const char *name, bool loop, size_t loopstart, size_t loopend, float volume_preset, SoundControl *&sndCtrl, csVector3 pos, csVector3 dir, float mindist, float maxdist, float rad, int type3d, SoundHandle *&handle)
Plays a 3D sound.
SoundData * GetSoundData()
Definition: manager.h:158
SoundSystemManager()
Constructor.
void StopSound(SoundHandle *handle)
Stops and removes a SoundHandle.
bool Play2DSound(const char *name, bool loop, size_t loopstart, size_t loopend, float volume_preset, SoundControl *&sndCtrl, SoundHandle *&handle)
Plays a 2D sound (Cannot be converted to 3D).
void UpdateSound()
Checks all SoundHandles alters Volume, does fading and removes them if Unmanaged (Autoremove true)...
SoundSystem * GetSoundSystem()
Definition: manager.h:157
void UpdateListener(csVector3 v, csVector3 f, csVector3 t)
Update listener position.
A Volume and Sound control class.
Definition: control.h:40
void Update()
Updates this SoundManager and everything its driving.
SoundControl * GetSoundControl()
Returns a NEW SoundControl.
SoundControl * mainSndCtrl
sound control for this manager
Definition: manager.h:66
bool Initialised
is initialized ?
Definition: manager.h:65
This Manager Object is used to play all sounds.
Definition: manager.h:62
This is an Interface Class to the Crystalspace Soundrenderer.
Definition: system.h:37