Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/orxonox/trunk/src/lib/sound/sound_engine.h @ 4836

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

orxonox/trunk: renamed all the \param → @param and so on in Doxygen tags.
Thanks a lot to the kDevelop team. this took since the last commit :)

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