Planeshift
soundctrl.h
Go to the documentation of this file.
1 /*
2 * soundctrl.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 
25 #ifndef _SOUND_CONTROL_H_
26 #define _SOUND_CONTROL_H_
27 
28 
29 //====================================================================================
30 // Crystal Space Includes
31 //====================================================================================
32 #include <cssysdef.h>
33 #include <csutil/set.h>
34 
35 //====================================================================================
36 // Project Includes
37 //====================================================================================
38 #include <isoundctrl.h>
39 
40 //------------------------------------------------------------------------------------
41 // Forward Declarations
42 //------------------------------------------------------------------------------------
43 class SoundControl;
44 
45 
50 {
55  virtual void OnSoundChange(SoundControl* sndCtrl) = 0;
56 };
57 
58 
71 class SoundControl: public iSoundControl
72 {
73 public:
74 
79  SoundControl(int ID);
80 
84  virtual ~SoundControl();
85 
90  void Subscribe(iSoundControlListener* listener);
91 
96  void Unsubscribe(iSoundControlListener* listener);
97 
101  virtual int GetID() const;
102 
108  virtual void VolumeDampening(float damp);
109 
114  virtual bool IsDampened() const;
115 
119  virtual float GetVolume() const;
120 
125  virtual void SetVolume(float vol);
126 
130  virtual void Unmute();
131 
135  virtual void Mute();
136 
141  virtual bool GetToggle() const;
142 
147  virtual void SetToggle(bool value);
148 
153  virtual void DeactivateToggle();
154 
159  virtual void ActivateToggle();
160 
161 private:
162  int id;
163  bool isEnabled;
164  bool isMuted;
165  bool isDampened;
166  float volume;
167  float volumeDamp;
168 
169  csSet<iSoundControlListener*> listeners;
170 
174  void CallListeners();
175 
176 };
177 
178 #endif /*_SOUND_CONTROL_H_*/
virtual void OnSoundChange(SoundControl *sndCtrl)=0
This function is called everytime the volume or the toggle change.
Interface to implement to handle SoundControl&#39;s events.
Definition: soundctrl.h:49
A Volume and Sound control class.
Definition: control.h:40