Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

Created capability in SoundManager to set an overall volume, and to also adjust general ambient and effects volumes.
For this to work, you need to delete your config-file (orxonox.ini) so that it can be reset.
It has still som quirks, though.

  • Property svn:eol-style set to native
File size: 3.4 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 "util/Singleton.h"
37#include "core/OrxonoxClass.h"
38
39// tolua_begin
40namespace orxonox
41{
42    /**
43     * The SoundManager class manages the OpenAL device, context and listener
44     * position. It is a singleton.
45     *
46     */
47    class _OrxonoxExport SoundManager
48    // tolua_end
49        : public Singleton<SoundManager>, public OrxonoxClass
50    { // tolua_export
51        friend class Singleton<SoundManager>;
52
53    public:
54        SoundManager();
55        ~SoundManager();
56
57        void preUpdate(const Clock& time);
58        void setConfigValues();
59       
60        static SoundManager& getInstance() { return Singleton<SoundManager>::getInstance(); } // tolua_export
61
62        void setListenerPosition(const Vector3& position);
63        void setListenerOrientation(const Quaternion& orientation);
64
65        void registerAmbientSound(AmbientSound* newAmbient);
66        void unregisterAmbientSound(AmbientSound* oldAmbient);
67        void pauseAmbientSound(AmbientSound* ambient);
68       
69        void setAmbientVolume(float vol); // tolua_export
70        void setEffectsVolume(float vol); // tolua_export
71        void setVolume(float vol); // tolua_export
72       
73        float getAmbientVolume(void); // tolua_export
74        float getEffectsVolume(void); // tolua_export
75        float getVolume(void); // tolua_export
76
77    private:
78        void processCrossFading(float dt);
79        void fadeIn(AmbientSound* sound);
80        void fadeOut(AmbientSound* sound);
81
82        void checkFadeStepValidity();
83        void checkVolumeValidity();
84        void checkAmbientVolumeValidity();
85        void checkEffectsVolumeValidity();
86       
87        void updateAmbientVolume(void);
88        void updateEffectsVolume(void);
89        void updateVolume(void);
90
91        ALCdevice* device_;
92        ALCcontext* context_;
93       
94        typedef std::list<std::pair<AmbientSound*, bool> > AmbientList;
95        AmbientList ambientSounds_;
96       
97        float crossFadeStep_;       //!< Absolute change per second (0.1 means 10% of the nominal volume) for cross fading
98        std::list<AmbientSound*> fadeInList_;
99        std::list<AmbientSound*> fadeOutList_;
100       
101        float ambientVolume_;
102        float effectsVolume_;
103        float volume_;
104       
105        static SoundManager* singletonPtr_s;
106    }; // tolua_export
107} // tolua_export
108
109#endif /* _SoundManager_H__ */
Note: See TracBrowser for help on using the repository browser.