Planeshift
handle.h
Go to the documentation of this file.
1 /*
2  * handle.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_HANDLE_H_
25 #define _SOUND_HANDLE_H_
26 
27 #include <isndsys.h>
28 #include <csutil/csstring.h>
29 
30 class SoundControl;
31 class SoundSystemManager;
32 
33 enum
34 {
35  FADE_DOWN = 0,
36  FADE_UP = 1,
37  FADE_STOP = -1
38 };
39 
41 {
42  public:
43  csString name;
45  float preset_volume;
46  int fade;
47  float fade_volume;
48  bool fade_stop;
49  bool autoremove;
50 
51  csRef<iSndSysData> snddata;
52  csRef<iSndSysStream> sndstream;
53  csRef<iSndSysSource> sndsource;
54  csRef<iSndSysSource3D> sndsource3d;
55  csRef<iSndSysSource3DDirectionalSimple> sndsourcedir;
56 
58  ~SoundHandle ();
59 
65  void Fade (float volume, int time, int direction);
75  bool Init (const char *resname, bool loop,
76  float volume_preset, int type,
77  SoundControl* &ctrl);
78 
89  void ConvertTo3D (float mindist, float maxdist,
90  csVector3 pos, csVector3 dir,
91  float rad);
92 
99  void SetAutoRemove (bool toggle);
103  bool GetAutoRemove ();
104 
110  void SetCallback(void (*object), void (*function) (void *));
114  void RemoveCallback();
115 
116  private:
117  SoundSystemManager* manager;
118  bool hasCallback;
119  void (*callbackobject);
120  void (*callbackfunction) (void *);
121 
126  void Callback ();
127 
128 };
129 
130 #endif /*_SOUND_HANDLE_H_*/
bool GetAutoRemove()
Returns state of AutoRemove.
bool fade_stop
pause this sound after fading down true / false
Definition: handle.h:48
csRef< iSndSysSource3D > sndsource3d
sndsource if 3D
Definition: handle.h:54
void SetCallback(void(*object), void(*function)(void *))
Sets a Callback to a object function.
int fade
>0 is number of steps up <0 is number of steps down, 0 is nothing
Definition: handle.h:46
void Fade(float volume, int time, int direction)
Does fading calculation for this Handle.
csRef< iSndSysSource3DDirectionalSimple > sndsourcedir
additional source if 3D and directional
Definition: handle.h:55
csRef< iSndSysStream > sndstream
sound stream
Definition: handle.h:52
float preset_volume
the volume all calculations are based upon
Definition: handle.h:45
bool autoremove
remove this handle when pause?
Definition: handle.h:49
void RemoveCallback()
Remove the callback.
float fade_volume
volume we add or remove in each step (during fading)
Definition: handle.h:47
Definition: handle.h:36
SoundControl * sndCtrl
Definition: handle.h:44
csString name
name of the resource or the file - not unique
Definition: handle.h:43
A Volume and Sound control class.
Definition: control.h:40
csRef< iSndSysData > snddata
pointer to sound data
Definition: handle.h:51
void ConvertTo3D(float mindist, float maxdist, csVector3 pos, csVector3 dir, float rad)
Converts this Handle to a 3D Handle.
~SoundHandle()
destructor
bool Init(const char *resname, bool loop, float volume_preset, int type, SoundControl *&ctrl)
Initialize this Handle.
SoundHandle()
constructor
csRef< iSndSysSource > sndsource
sndsource if 2D
Definition: handle.h:53
This Manager Object is used to play all sounds.
Definition: manager.h:62
void SetAutoRemove(bool toggle)
Whether to remove this Sound/Handle on pause.