Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/world_entities/src/lib/sound/sound_engine.h @ 5580

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

orxonox/trunk: renamed definition to the right term declaration…

File size: 2.4 KB
Line 
1/*!
2 * @file sound_engine.h
3 * Definition of the SoundEngine singleton Class
4 */
5
6#ifndef _SOUND_ENGINE_H
7#define _SOUND_ENGINE_H
8
9#include "base_object.h"
10#include "alincl.h"
11
12#include "sound_buffer.h"
13#include "sound_source.h"
14
15#define SOUND_DOPPLER_FACTOR       0.001          //!< A factor for the audible doppler effect
16#define SOUND_DOPPLER_VELOCITY     5000000        //!< A factor for the TravelSpeed of sound
17
18// FORWARD DECLARATION
19class PNode;
20template<class T> class tList;
21class IniParser;
22
23//! A class that handles audio via the openAudioLibrary
24class SoundEngine : public BaseObject {
25
26  public:
27    virtual ~SoundEngine();
28    /** @returns a Pointer to the only object of this Class */
29    inline static SoundEngine* getInstance() { if (!SoundEngine::singletonRef) SoundEngine::singletonRef = new SoundEngine();  return SoundEngine::singletonRef; };
30
31    void loadSettings(IniParser* iniParser);
32
33    SoundSource* createSource(const char* fileName, PNode* sourceNode = NULL);
34
35    /** @param listener the listener in the scene */
36    void setListener(PNode* listener) { this->listener = listener; };
37    void setDopplerValues(ALfloat dopplerFactor, ALfloat dopplerVelocity);
38
39
40    /** @returns the Music Volume in % */
41    inline float getMusicVolume() { return this->musicVolume; };
42    /** @returns the Effects Volume in % */
43    inline float getEffectsVolume() { return this->effectsVolume; };
44
45    void update();
46
47  // administrative
48    void addBuffer(SoundBuffer* buffer);
49    void removeBuffer(SoundBuffer* buffer);
50    void addSource(SoundSource* source);
51
52    void flushUnusedBuffers();
53    void flushAllBuffers();
54    void flushAllSources();
55    bool initAudio();
56
57  // error handling:
58    static void PrintALErrorString(ALenum err);
59  //  static void PrintALCErrorString(ALenum err);
60
61
62  private:
63    SoundEngine();
64    void listDevices();
65
66  private:
67    static SoundEngine*      singletonRef;             //!< Reference to this class
68
69    float                    musicVolume;              //!< the maximum volume of the music in % (0f,1f]
70    float                    effectsVolume;            //!< the maximum volume of sound-effects in % (0f,1f]
71    PNode*                   listener;                 //!< The listener of the Scene
72    tList<BaseObject>*       bufferList;               //!< A list of buffers
73    tList<BaseObject>*       sourceList;               //!< A list for all the sources in the scene.
74
75};
76
77#endif /* _SOUND_ENGINE_H */
Note: See TracBrowser for help on using the repository browser.