Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

orxonox/trunk: merged the new_class_id branche back to the trunk.
merged with command:
svn merge https://svn.orxonox.net/orxonox/branches/new_class_id trunk -r9683:HEAD
no conflicts… puh..

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