Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

trunk: alc-stuff

File size: 3.1 KB
RevLine 
[4597]1/*!
[4959]2 * @file sound_engine.h
3 * Definition of the SoundEngine singleton Class
4 */
[4504]5
6#ifndef _SOUND_ENGINE_H
7#define _SOUND_ENGINE_H
8
9#include "base_object.h"
10#include "alincl.h"
11
[5386]12#include "sound_buffer.h"
13#include "sound_source.h"
14
[5779]15#include <list>
[5917]16#include <stack>
[5779]17
[4506]18#define SOUND_DOPPLER_FACTOR       0.001          //!< A factor for the audible doppler effect
[6840]19#define SOUND_DOPPLER_VELOCITY     500            //!< A factor for the TravelSpeed of sound
[4504]20
[5405]21// FORWARD DECLARATION
[4504]22class PNode;
[4985]23class IniParser;
[4504]24
[5917]25
[4504]26//! A class that handles audio via the openAudioLibrary
27class SoundEngine : public BaseObject {
[4959]28  public:
29    virtual ~SoundEngine();
30    /** @returns a Pointer to the only object of this Class */
[5216]31    inline static SoundEngine* getInstance() { if (!SoundEngine::singletonRef) SoundEngine::singletonRef = new SoundEngine();  return SoundEngine::singletonRef; };
[4504]32
[4985]33    void loadSettings(IniParser* iniParser);
34
[4959]35    SoundSource* createSource(const char* fileName, PNode* sourceNode = NULL);
[4504]36
[4961]37    /** @param listener the listener in the scene */
38    void setListener(PNode* listener) { this->listener = listener; };
[4959]39    void setDopplerValues(ALfloat dopplerFactor, ALfloat dopplerVelocity);
[4504]40
41
[4985]42    /** @returns the Music Volume in % */
43    inline float getMusicVolume() { return this->musicVolume; };
44    /** @returns the Effects Volume in % */
45    inline float getEffectsVolume() { return this->effectsVolume; };
46
[4961]47    void update();
48
49  // administrative
[5930]50    void popALSource(ALuint& source);
51    void pushALSource(ALuint& source) { if (source != 0) this->ALSources.push(source); };
[4504]52
[4959]53    void flushUnusedBuffers();
54    void flushAllBuffers();
55    void flushAllSources();
[5917]56
[5930]57    bool initAudio();
[5917]58    bool allocateSources(unsigned int count);
[4504]59
60  // error handling:
[6836]61    static bool checkError(const char* error, unsigned int line);
[6849]62    bool checkALCError(const char* error, unsigned int line);
[5930]63    static const char* getALErrorString(ALenum err);
[6847]64    static const char* getALCErrorString(ALenum err);
[4504]65
[4959]66  private:
67    SoundEngine();
[5930]68
[4959]69    void listDevices();
[4504]70
[4959]71  private:
[5885]72    static SoundEngine*            singletonRef;             //!< Reference to this class
[4504]73
[5885]74    ALCdevice*                     device;                   //!< the used audio-device.
75    ALCcontext*                    context;                  //!< the context, currently in use.
[5819]76
[5885]77    float                          musicVolume;              //!< the maximum volume of the music in % (0f,1f]
78    float                          effectsVolume;            //!< the maximum volume of sound-effects in % (0f,1f]
79    PNode*                         listener;                 //!< The listener of the Scene
[5819]80
[5885]81    const std::list<BaseObject*>*  bufferList;               //!< A list of buffers
82    const std::list<BaseObject*>*  sourceList;               //!< A list for all the sources in the scene.
[4959]83
[5917]84    unsigned int                   maxSourceCount;           //!< How many Sources is the Maximum
85    std::stack<ALuint>             ALSources;                //!< A list of real openAL-Sources, the engine allocates, and stores for reuse.
[4504]86};
87
88#endif /* _SOUND_ENGINE_H */
Note: See TracBrowser for help on using the repository browser.