Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 6190 was 6186, checked in by dafrick, 15 years ago

Some cleanup in SoundManager and related classes. Overrall volume works now. Mute function has been implemented into the gui.
Once again you'll have to delete your orxonox.ini file to be trouble free.

  • Property svn:eol-style set to native
File size: 3.8 KB
Line 
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
24 *       Kevin Young
25 *   Co-authors:
26 *      ...
27 */
28
29#ifndef _SoundManager_H__
30#define _SoundManager_H__
31
32#include "OrxonoxPrereqs.h"
33
34#include <list>
35#include <string>
36#include <map>
37#include "util/Singleton.h"
38#include "core/OrxonoxClass.h"
39
40// tolua_begin
41namespace orxonox
42{
43   
44    //! Enum for the sound type.
45    namespace SoundType
46    {
47        enum Value
48        {
49            none,
50            ambient,
51            effects
52        };
53    }
54   
55    /**
56     * The SoundManager class manages the OpenAL device, context and listener
57     * position. It is a singleton.
58     *
59     */
60    class _OrxonoxExport SoundManager
61    // tolua_end
62        : public Singleton<SoundManager>, public OrxonoxClass
63    { // tolua_export
64        friend class Singleton<SoundManager>;
65
66    public:
67        SoundManager();
68        ~SoundManager();
69
70        void preUpdate(const Clock& time);
71        void setConfigValues();
72       
73        static SoundManager& getInstance() { return Singleton<SoundManager>::getInstance(); } // tolua_export
74
75        void setListenerPosition(const Vector3& position);
76        void setListenerOrientation(const Quaternion& orientation);
77
78        void registerAmbientSound(AmbientSound* newAmbient);
79        void unregisterAmbientSound(AmbientSound* oldAmbient);
80        void pauseAmbientSound(AmbientSound* ambient);
81       
82        void setVolume(float vol, SoundType::Value type); // tolua_export
83        float getVolume(SoundType::Value type); // tolua_export
84       
85        void toggleMute(SoundType::Value type); // tolua_export
86        bool getMute(SoundType::Value type); // tolua_export
87
88    private:
89        void processCrossFading(float dt);
90        void fadeIn(AmbientSound* sound);
91        void fadeOut(AmbientSound* sound);
92
93        void checkFadeStepValidity();
94        bool checkVolumeValidity(SoundType::Value type);
95        void checkSoundVolumeValidity(void);
96        void checkAmbientVolumeValidity(void);
97        void checkEffectsVolumeValidity(void);
98       
99        float checkVolumeRange(float vol);
100       
101        void updateVolume(SoundType::Value type);
102       
103        void setVolumeInternal(float vol, SoundType::Value type);
104        float getVolumeInternal(SoundType::Value type);
105
106        ALCdevice* device_;
107        ALCcontext* context_;
108       
109        typedef std::list<std::pair<AmbientSound*, bool> > AmbientList;
110        AmbientList ambientSounds_;
111       
112        float crossFadeStep_;       //!< Absolute change per second (0.1 means 10% of the nominal volume) for cross fading
113        std::list<AmbientSound*> fadeInList_;
114        std::list<AmbientSound*> fadeOutList_;
115       
116        float soundVolume_;
117        float ambientVolume_;
118        float effectsVolume_;
119        std::map<SoundType::Value, bool> mute_;
120       
121        static SoundManager* singletonPtr_s;
122    }; // tolua_export
123} // tolua_export
124
125#endif /* _SoundManager_H__ */
Note: See TracBrowser for help on using the repository browser.