Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/orxonox/branches/openAL/src/lib/sound/sound_engine.h @ 4204

Last change on this file since 4204 was 4204, checked in by bensch, 19 years ago

orxonox/branches/openAL: added Buffer to the ResourceManager

File size: 2.4 KB
Line 
1/*!
2    \file sound_engine.h
3    \brief Definition of the SoundEngine singleton Class
4   
5*/
6
7#ifndef _SOUND_ENGINE_H
8#define _SOUND_ENGINE_H
9
10#include "base_object.h"
11#include "alincl.h"
12
13
14#define SOUND_DOPPLER_FACTOR     0.01
15#define SOUND_DOPPLER_VELOCITY   500000000
16
17// FORWARD DEFINITION
18class PNode;
19template<class T> class tList;
20
21
22//! A class that represents a datastructure to play Sounds.
23class SoundBuffer
24{
25 public:
26  SoundBuffer(const char* fileName);
27  ~SoundBuffer(void);
28
29  inline ALuint getID(void) { return this->bufferID; }
30
31 private:
32  ALuint bufferID;              //!< The address of the Buffer.
33
34  ALsizei size;                 //!< The size of the Buffer.
35  ALboolean loop;               //!< loop information.
36};
37
38//! A class that represents a SoundSource
39class SoundSource
40{
41 public:
42  SoundSource(SoundBuffer* buffer, PNode* sourceNode = NULL);
43  ~SoundSource(void);
44
45  // user interaction
46  void play();
47  void stop();
48  void pause();
49
50  // development functions
51  /** \retruns The ID of the Source */
52  inline ALuint getID(void) { return this->sourceID; }
53  /** \returns the SourceNode of this Source */
54  inline PNode* getNode(void) { return this->sourceNode;}
55
56  void setRolloffFactor(ALfloat rolloffFactor);
57
58 private:
59  ALuint sourceID;              //!< The ID of the Source
60  SoundBuffer* buffer;          //!< The buffer to play in this source.
61  PNode* sourceNode;            //!< The SourceNode represente the position/velocity... of this source.
62};
63
64
65
66//! A class that handles audio via the openAudioLibrary
67class SoundEngine : public BaseObject {
68
69 public:
70  static SoundEngine* getInstance(void);
71  virtual ~SoundEngine(void);
72
73  SoundSource* createSource(const char* fileName, PNode* sourceNode);
74
75  void setListener(PNode* listener);
76
77  void addBuffer(SoundBuffer* buffer);
78  void removeBuffer(SoundBuffer* buffer);
79  void addSource(SoundSource* source);
80  void removeSource(SoundSource* source);
81
82
83  void update(void);
84
85
86  // error handling:
87  static void PrintALErrorString(ALenum err);
88  static void PrintALCErrorString(ALenum err);
89
90 private:
91  SoundEngine(void);
92  static SoundEngine* singletonRef;
93
94  bool initAudio(void);
95
96  PNode* listener;                 //!< The listener of the Scene
97  tList<SoundBuffer>* bufferList;  //!< A list of buffers
98  tList<SoundSource>* sourceList;  //!< A list for all the sources in the scene.
99
100};
101
102#endif /* _SOUND_ENGINE_H */
Note: See TracBrowser for help on using the repository browser.