Mercurial > fife-parpg
comparison engine/core/audio/soundmanager.h @ 0:4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
author | mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222 |
---|---|
date | Sun, 29 Jun 2008 18:44:17 +0000 |
parents | |
children | 90005975cdbb |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:4a0efb7baf70 |
---|---|
1 /*************************************************************************** | |
2 * Copyright (C) 2005-2008 by the FIFE Team * | |
3 * http://www.fifengine.de * | |
4 * This file is part of FIFE. * | |
5 * * | |
6 * FIFE is free software; you can redistribute it and/or modify * | |
7 * it under the terms of the GNU General Public License as published by * | |
8 * the Free Software Foundation; either version 2 of the License, or * | |
9 * (at your option) any later version. * | |
10 * * | |
11 * This program is distributed in the hope that it will be useful, * | |
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of * | |
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * | |
14 * GNU General Public License for more details. * | |
15 * * | |
16 * You should have received a copy of the GNU General Public License * | |
17 * along with this program; if not, write to the * | |
18 * Free Software Foundation, Inc., * | |
19 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * | |
20 ***************************************************************************/ | |
21 | |
22 #ifndef FIFE_SOUNDMANAGER_H | |
23 #define FIFE_SOUNDMANAGER_H | |
24 | |
25 // Standard C++ library includes | |
26 | |
27 // Platform specific includes | |
28 | |
29 // 3rd party library includes | |
30 | |
31 // FIFE includes | |
32 // These includes are split up in two parts, separated by one empty line | |
33 // First block: files included from the FIFE root src directory | |
34 // Second block: files included from the same folder | |
35 #include "fife_openal.h" | |
36 | |
37 namespace FIFE { | |
38 class SoundEmitter; | |
39 class SoundClipPool; | |
40 | |
41 class SoundManager { | |
42 public: | |
43 | |
44 SoundManager(SoundClipPool* pool); | |
45 | |
46 ~SoundManager(); | |
47 | |
48 /** Initializes the audio system | |
49 */ | |
50 void init(); | |
51 | |
52 /** Returns a pointer to an emitter-instance given by emitterid | |
53 * | |
54 * @param emitterid The id of the Emitter | |
55 * | |
56 */ | |
57 SoundEmitter* getEmitter(unsigned int emitterid); | |
58 | |
59 /** Returns a pointer to an allocated emitter-instance | |
60 */ | |
61 SoundEmitter* createEmitter(); | |
62 | |
63 /** Release an emitter-instance given by emitter-id | |
64 */ | |
65 void releaseEmitter(unsigned int emitterid); | |
66 | |
67 /** Returns an openAL context | |
68 */ | |
69 ALCcontext* getContext() { | |
70 return m_context; | |
71 } | |
72 | |
73 /** Sets the Master Volume | |
74 * | |
75 * @param vol The volume value. 0=silence ... 1.0=normal loudness. | |
76 */ | |
77 void setVolume(float vol) { | |
78 if (m_device == NULL) { | |
79 m_volume = vol; | |
80 } | |
81 alListenerf(AL_GAIN, vol); | |
82 } | |
83 | |
84 /** Mute | |
85 */ | |
86 void mute() { | |
87 alGetListenerf(AL_GAIN, &m_mutevol); | |
88 alListenerf(AL_GAIN, 0); | |
89 } | |
90 | |
91 /** Unmutes to volume before mute() was called. | |
92 */ | |
93 void unmute() { | |
94 alListenerf(AL_GAIN, m_mutevol); | |
95 } | |
96 | |
97 /** Sets the position of the listener (alter ego). | |
98 */ | |
99 void setListenerPosition(float x, float y, float z) { | |
100 alListener3f(AL_POSITION, x, y, z); | |
101 } | |
102 | |
103 /** Sets the orientation of the listener (alter ego). | |
104 */ | |
105 void setListenerOrientation(float x, float y, float z) { | |
106 ALfloat vec[6] = { x, y, z, 0.0, 0.0, 1.0}; | |
107 alListenerfv(AL_ORIENTATION, vec); | |
108 } | |
109 | |
110 /** Sets the velocity of the listener (alter ego). | |
111 */ | |
112 void setListenerVelocity(float x, float y, float z); | |
113 | |
114 /** Returns true if audio module is active | |
115 */ | |
116 bool isActive() { | |
117 return m_device != NULL; | |
118 } | |
119 | |
120 private: | |
121 | |
122 std::vector<SoundEmitter*> m_emittervec; // emitter-vector | |
123 ALCcontext* m_context; // OpenAL context | |
124 ALCdevice* m_device; // OpenAL device | |
125 SoundClipPool* m_pool; | |
126 float m_mutevol; // volume before mute() was called | |
127 float m_volume; // volume to support setVolume-calls before initialization | |
128 }; | |
129 } | |
130 #endif |