Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/presentation2/src/orxonox/sound/SoundManager.h @ 6237

Last change on this file since 6237 was 6237, checked in by rgrieder, 15 years ago

Removed (commented) everything related to ALC (OpenAL library part).
This should fix the freeze problems when shutting down orxonox.

  • Property svn:eol-style set to native
File size: 4.0 KB
RevLine 
[3060]1/*
2 *   ORXONOX - the hottest 3D action shooter ever to exist
3 *                    > www.orxonox.net <
4 *
5 *
6 *   License notice:
7 *
8 *   This program is free software; you can redistribute it and/or
9 *   modify it under the terms of the GNU General Public License
10 *   as published by the Free Software Foundation; either version 2
11 *   of the License, or (at your option) any later version.
12 *
13 *   This program is distributed in the hope that it will be useful,
14 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
15 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 *   GNU General Public License for more details.
17 *
18 *   You should have received a copy of the GNU General Public License
19 *   along with this program; if not, write to the Free Software
20 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
21 *
22 *   Author:
23 *       Erwin 'vaiursch' Herrsche
[6117]24 *       Kevin Young
[3060]25 *   Co-authors:
26 *      ...
27 */
[6117]28
[3196]29#ifndef _SoundManager_H__
30#define _SoundManager_H__
[3060]31
32#include "OrxonoxPrereqs.h"
33
[3196]34#include <list>
[6203]35#include <map>
[6117]36#include <string>
[6203]37#include <boost/weak_ptr.hpp>
38
[3370]39#include "util/Singleton.h"
[6184]40#include "core/OrxonoxClass.h"
[3196]41
[6184]42// tolua_begin
[3060]43namespace orxonox
44{
[6203]45    // forward declaration
46    class SoundBuffer;
[6186]47   
48    //! Enum for the sound type.
49    namespace SoundType
50    {
51        enum Value
52        {
53            none,
54            ambient,
55            effects
56        };
57    }
58   
[3060]59    /**
60     * The SoundManager class manages the OpenAL device, context and listener
[5929]61     * position. It is a singleton.
[3060]62     *
63     */
[6184]64    class _OrxonoxExport SoundManager
65    // tolua_end
66        : public Singleton<SoundManager>, public OrxonoxClass
67    { // tolua_export
[3370]68        friend class Singleton<SoundManager>;
[6117]69
[3060]70    public:
71        SoundManager();
72        ~SoundManager();
73
[6183]74        void preUpdate(const Clock& time);
[6117]75        void setConfigValues();
[6184]76       
77        static SoundManager& getInstance() { return Singleton<SoundManager>::getInstance(); } // tolua_export
[6117]78
[5929]79        void setListenerPosition(const Vector3& position);
80        void setListenerOrientation(const Quaternion& orientation);
81
[6117]82        void registerAmbientSound(AmbientSound* newAmbient);
83        void unregisterAmbientSound(AmbientSound* oldAmbient);
84        void pauseAmbientSound(AmbientSound* ambient);
[6184]85       
[6194]86        void setVolume(float vol, SoundType::Value type);
[6186]87        float getVolume(SoundType::Value type); // tolua_export
[6184]88       
[6186]89        void toggleMute(SoundType::Value type); // tolua_export
90        bool getMute(SoundType::Value type); // tolua_export
[6117]91
[6203]92        shared_ptr<SoundBuffer> getSoundBuffer(shared_ptr<ResourceInfo> fileInfo);
93        void removeBuffer(shared_ptr<ResourceInfo> fileInfo);
94
[3060]95    private:
[6117]96        void processCrossFading(float dt);
97        void fadeIn(AmbientSound* sound);
98        void fadeOut(AmbientSound* sound);
99
100        void checkFadeStepValidity();
[6186]101        bool checkVolumeValidity(SoundType::Value type);
102        void checkSoundVolumeValidity(void);
103        void checkAmbientVolumeValidity(void);
104        void checkEffectsVolumeValidity(void);
[6184]105       
[6186]106        float checkVolumeRange(float vol);
107       
108        void updateVolume(SoundType::Value type);
109       
110        void setVolumeInternal(float vol, SoundType::Value type);
111        float getVolumeInternal(SoundType::Value type);
[6117]112
[6237]113/*
[3280]114        ALCdevice* device_;
[3060]115        ALCcontext* context_;
[6237]116*/
[6117]117       
118        typedef std::list<std::pair<AmbientSound*, bool> > AmbientList;
119        AmbientList ambientSounds_;
120       
121        float crossFadeStep_;       //!< Absolute change per second (0.1 means 10% of the nominal volume) for cross fading
122        std::list<AmbientSound*> fadeInList_;
123        std::list<AmbientSound*> fadeOutList_;
124       
[6186]125        float soundVolume_;
[6184]126        float ambientVolume_;
127        float effectsVolume_;
[6186]128        std::map<SoundType::Value, bool> mute_;
[6203]129
130        std::map<std::string, weak_ptr<SoundBuffer> > soundBuffers_;
[6184]131       
[3370]132        static SoundManager* singletonPtr_s;
[6184]133    }; // tolua_export
134} // tolua_export
[3060]135
[3196]136#endif /* _SoundManager_H__ */
Note: See TracBrowser for help on using the repository browser.