Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

orxonox/trunk: merged branches world_entities to trunk again
merged with command
svn merge -r5795:HEAD branches/world_entities/ trunk/
no conflicts (what a wonder)

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