Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 7460 was 7460, checked in by bensch, 18 years ago

orxonox/trunk: Namespaces for sound

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