Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

orxonox/trunk: works on windows too

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