libmoldeo (Moldeo 1.0 Core)  1.0
libmoldeo is the group of objects and functions that executes the basic operations of Moldeo 1.0 Platform.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
moSoundManager.h
Go to the documentation of this file.
1 /*******************************************************************************
2 
3  moSoundManager.h
4 
5  ****************************************************************************
6  * *
7  * This source is free software; you can redistribute it and/or modify *
8  * it under the terms of the GNU General Public License as published by *
9  * the Free Software Foundation; either version 2 of the License, or *
10  * (at your option) any later version. *
11  * *
12  * This code is distributed in the hope that it will be useful, but *
13  * WITHOUT ANY WARRANTY; without even the implied warranty of *
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
15  * General Public License for more details. *
16  * *
17  * A copy of the GNU General Public License is available on the World *
18  * Wide Web at <http://www.gnu.org/copyleft/gpl.html>. You can also *
19  * obtain it by writing to the Free Software Foundation, *
20  * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
21  * *
22  ****************************************************************************
23 
24  Copyright(C) 2006 Fabricio Costa
25 
26  Authors:
27  Fabricio Costa
28 
29 *******************************************************************************/
30 
31 #ifndef _MO_SOUNDMANAGER
32 #define _MO_SOUNDMANAGER
33 
34 #include <moTypes.h>
35 #include <moText.h>
36 #include <moConfig.h>
37 #include <moResourceManager.h>
38 #include <moFileManager.h>
39 #include <moDataManager.h>
40 #include <moGsGraph.h>
41 
42 #define NUMBUFFERS (4)
43 #define SERVICE_UPDATE_PERIOD (20)
44 #define MO_SOUNDERROR -1
45 
47 
56 };
57 
62 };
63 
65 
69  moWord wFormatTag;
70  moWord nChannels;
71  moDWord nSamplesPerSec;
72  moDWord nAvgBytesPerSec;
73  moWord nBlockAlign;
75  moWord cbSize;
76 };
77 
79 {
80  0,
81  0,
82  0,
83  0,
84  0,
85  0,
86  0
87 };
88 
90 {
97  MO_UNDEFINED
98 };
99 
101 
105 
106  public:
107  moSoundEffect() { m_EffectId=0; }
108  virtual ~moSoundEffect() {}
109 
111 
112  void SetParameterF( MOint param, MOfloat flValue );
113  void GetParameterF( MOint param, MOfloat* pflValue );
114 
115 };
116 
117 
118 moDeclareExportedDynamicArray( moSoundEffect*, moSoundEffectArray);
119 
121 
125 
126  public:
128  virtual ~moSoundBuffer() {}
129 
130 
131 };
132 
133 moDeclareExportedDynamicArray( moSoundBuffer*, moSoundBufferArray);
134 
135 
137 
141 
142  public:
143  moSound();
144  virtual ~moSound();
145 
146  virtual MOboolean Init();
147  virtual MOboolean Finish();
148 
149  virtual moText GetName();
150  virtual void SetName( moText name );
151 
152  virtual moText GetFileName();
153  virtual void SetFileName( moText filename );
154 
155  moSoundType GetType();
156 
157  MOboolean LoadFromFile( moText filename );
158 
159  MOboolean SupportedFile(moText p_filename);
160 
161  virtual void Play();
162  virtual void Stop();
163  virtual void Pause();
164  virtual void Rewind();
165  virtual moStreamState State();
166  virtual bool IsPlaying();
167  virtual void Update();
168  virtual MOulong GetPosition();
169  virtual MOulong GetDuration();
170  virtual MOulong GetSampleCount();
171  virtual void Seek( int position, float rate = 1.0);
172  virtual bool IsEOS();
173 
174  virtual void SetVolume( float gain );
175  virtual float GetVolume();
176  virtual void SetPitch( float pitch );
177  virtual float GetPitch();
178  virtual void SetBalance( float balance );
179  virtual float GetBalance();
180 
181  virtual void SetEchoDelay( float delay );
182  virtual float GetEchoDelay();
183  virtual void SetEchoIntensity( float intensity );
184  virtual float GetEchoIntensity();
185  virtual void SetEchoFeedback( float feedback );
186  virtual float GetEchoFeedback();
187 
188  moAudioFormat& GetAudioFormat() { return m_AudioFormat; }
189  MOint GetBufferSize() { return m_BufferSize; }
190  virtual void PlaySample( MOint sampleid );
191  MOint GetActualSample() { return m_ActualSample; }
192 
193  protected:
194 
198 
200 
203 
204  float m_Position;
205  float m_Volume;
206  float m_Pitch;
207  float m_Balance;
208 
209  float m_EchoDelay;
212 
217 
218 
219 };
220 
221 
223 
227  public:
228 
229  moSound3D();
230  virtual ~moSound3D();
231 
232  virtual MOboolean Init();
233  virtual MOboolean Finish();
234 
239  virtual void Play() = 0;
240  virtual void Stop() = 0;
241  virtual void Pause() = 0;
242  virtual void Rewind() = 0;
243  virtual moStreamState State() = 0;
244  virtual void Update() = 0;
245  virtual void SetVolume( float gain ) = 0;
246  virtual float GetVolume() = 0;
247  virtual void SetPitch( float pitch ) = 0;
248  virtual float GetPitch() = 0;
249 
254  virtual MOboolean BuildEmpty( MOuint p_size ) = 0;
255  virtual MOboolean BuildFromBuffer( MOuint p_size, GLvoid* p_buffer ) = 0;
256  virtual MOboolean BuildFromFile( const moText& p_filename ) = 0;
257 
258  MOint GetSourceId() { return m_SourceId; }
259  MOuint GetBufferId() { return m_BufferId; }
260  virtual void Final() = 0;
261  virtual void Frame(int frame) = 0;
262  virtual void Repeat(int repeat) = 0;
263 
264  void SetPosition( float x, float y, float z );
265  void SetVelocity( float x, float y, float z );
266  void SetDirection( float x, float y, float z );
267 
268 
269 
270  public:
271 
275 
278 
279 
280  /*AL_GAIN
281  AL_MIN_GAIN
282  AL_MAX_GAIN
283  AL_MAX_DISTANCE
284  AL_ROLLOFF_FACTOR
285  AL_CONE_OUTER_GAIN
286  AL_CONE_INNER_ANGLE
287  AL_CONE_OUTER_ANGLE
288  AL_REFERENCE_DISTANCE*/
289 
290 };
291 
292 
293 moDeclareExportedDynamicArray( moSound*, moSoundArray);
294 
295 
297 
301  public:
302 
303  moSoundManager();
304  virtual ~moSoundManager();
305 
306  MOboolean Init();
307  MOboolean Finish();
308 
309  moSound* GetSound( moText p_name, bool create=true );
310  int GetSoundId( moText p_name, bool create=true );
311  int AddSound( moSound* p_Sound );
312 
313  int GetSoundCount();
314  moSound* GetSound( int id);
315 
316  moSoundType GetTypeForFile( moText p_name );
317  moSoundEffectArray* GetEffects();
318 
319  protected:
320 
321  moSound* CreateSound( moText p_name );
322 
323  moSoundArray m_sounds_array;
324 
325  moSoundEffectArray m_effects_array;
326 
327 };
328 
329 
330 #endif
331 
virtual void Rewind()
Manejador de archivos.
moWord nChannels
moText m_FileName
moDeclareExportedDynamicArray(moSoundEffect *, moSoundEffectArray)
#define MOulong
Definition: moTypes.h:392
Parámetros de sonido.
MOuint m_SourceId
Recurso ( objeto para cargar y manipular objetos físicos de datos de imágenes, audio, video, 3d, 2d, fuentes, shaders y de cualquier otro tipo extendible por un plugin )
virtual MOboolean Finish()
Finaliza el objeto, libera recursos.
Definition: moAbstract.cpp:147
moAudioFormat m_AudioFormat
float m_EchoFeedback
moSoundType m_SoundType
#define MO_UNDEFINED
Definition: moTypes.h:379
virtual void Play()
#define MOboolean
Definition: moTypes.h:385
virtual ~moSoundBuffer()
Administrador de sonidos.
Clase base abstracta de donde deben derivar los objetos [virtual pura].
Definition: moAbstract.h:191
moFileManager * m_pFileMan
moSoundEffectArray m_effects_array
virtual MOboolean Init()
Inicializa el objeto.
Definition: moAbstract.cpp:141
virtual float GetVolume()
MOint GetActualSample()
virtual MOboolean Finish()
Finaliza el objeto, libera recursos.
virtual ~moSoundEffect()
#define LIBMOLDEO_API
Definition: moTypes.h:180
MOint m_ActualSample
#define MOfloat
Definition: moTypes.h:403
moText m_SoundName
virtual MOboolean Init()
clase de para manejar textos
Definition: moText.h:75
Formato de audio.
Definition: moVideoGraph.h:223
float m_Balance
moGsGraph * m_pAudioGraph
Efecto de sonido.
virtual void Stop()
MOint GetBufferSize()
moWord wBitsPerSample
moStreamState
Definition: moVideoGraph.h:140
float m_EchoDelay
panorama
MOint GetSourceId()
GStreamer Graph Class.
Definition: moGsGraph.h:151
MOint m_OldSample
#define MOint
Definition: moTypes.h:388
virtual void SetPitch(float pitch)
moAudioFormat & GetAudioFormat()
MOuint m_BufferId
Buffer de sonido.
virtual float GetPitch()
virtual void Pause()
Clase base de sonido.
moDWord nSamplesPerSec
moSoundState
virtual MOboolean Finish()
moFile * m_pFile
moSoundParam m_SoundParam
moWord wFormatTag
bool m_bIsPlaying
moSoundType
Tipo de sonido.
virtual moStreamState State()
Clase base de sonido.
moDataManager * m_pDataMan
virtual MOboolean Init()
Inicializa el objeto.
#define MOuint
Definition: moTypes.h:387
MOint m_BufferSize
const moSoundParam MOUndefinedSound
moSoundArray m_sounds_array
float m_Position
float m_Pitch
moWord nBlockAlign
float m_EchoIntensity
const moSoundParam MODefSoundParams
moDWord nAvgBytesPerSec
float m_Volume
virtual void SetVolume(float gain)
MOuint GetBufferId()
virtual void Update()