Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

orxonox/branches/openAL: doxygen-Tags

File size: 2.5 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          //!< A factor for the audible doppler effect
15#define SOUND_DOPPLER_VELOCITY   500000000     //!< A factor for the TravelSpeed of sound
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  /** \returns the ID of the buffer */
30  inline ALuint getID(void) { return this->bufferID; }
31
32 private:
33  ALuint bufferID;              //!< The address of the Buffer.
34
35  ALsizei size;                 //!< The size of the Buffer.
36  ALboolean loop;               //!< loop information.
37};
38
39//! A class that represents a SoundSource
40class SoundSource
41{
42 public:
43  SoundSource(SoundBuffer* buffer, PNode* sourceNode = NULL);
44  ~SoundSource(void);
45
46  // user interaction
47  void play();
48  void stop();
49  void pause();
50  void rewind();
51
52  // development functions
53  /** \returns The ID of the Source */
54  inline ALuint getID(void) { return this->sourceID; }
55  /** \returns the SourceNode of this Source */
56  inline PNode* getNode(void) { return this->sourceNode;}
57
58  void setRolloffFactor(ALfloat rolloffFactor);
59
60 private:
61  ALuint sourceID;              //!< The ID of the Source
62  SoundBuffer* buffer;          //!< The buffer to play in this source.
63  PNode* sourceNode;            //!< The SourceNode represente the position/velocity... of this source.
64};
65
66
67
68//! A class that handles audio via the openAudioLibrary
69class SoundEngine : public BaseObject {
70
71 public:
72  static SoundEngine* getInstance(void);
73  virtual ~SoundEngine(void);
74
75  SoundSource* createSource(const char* fileName, PNode* sourceNode = NULL);
76
77  void setListener(PNode* listener);
78
79  void addBuffer(SoundBuffer* buffer);
80  void removeBuffer(SoundBuffer* buffer);
81  void addSource(SoundSource* source);
82  void removeSource(SoundSource* source);
83
84
85  void update(void);
86
87
88  // error handling:
89  static void PrintALErrorString(ALenum err);
90  //  static void PrintALCErrorString(ALenum err);
91
92 private:
93  SoundEngine(void);
94  static SoundEngine* singletonRef;
95
96  bool initAudio(void);
97
98  PNode* listener;                 //!< The listener of the Scene
99  tList<SoundBuffer>* bufferList;  //!< A list of buffers
100  tList<SoundSource>* sourceList;  //!< A list for all the sources in the scene.
101
102};
103
104#endif /* _SOUND_ENGINE_H */
Note: See TracBrowser for help on using the repository browser.