Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 6185 was 6184, checked in by dafrick, 16 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
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>
[6117]35#include <string>
[3370]36#include "util/Singleton.h"
[6184]37#include "core/OrxonoxClass.h"
[3196]38
[6184]39// tolua_begin
[3060]40namespace orxonox
41{
42    /**
43     * The SoundManager class manages the OpenAL device, context and listener
[5929]44     * position. It is a singleton.
[3060]45     *
46     */
[6184]47    class _OrxonoxExport SoundManager
48    // tolua_end
49        : public Singleton<SoundManager>, public OrxonoxClass
50    { // tolua_export
[3370]51        friend class Singleton<SoundManager>;
[6117]52
[3060]53    public:
54        SoundManager();
55        ~SoundManager();
56
[6183]57        void preUpdate(const Clock& time);
[6117]58        void setConfigValues();
[6184]59       
60        static SoundManager& getInstance() { return Singleton<SoundManager>::getInstance(); } // tolua_export
[6117]61
[5929]62        void setListenerPosition(const Vector3& position);
63        void setListenerOrientation(const Quaternion& orientation);
64
[6117]65        void registerAmbientSound(AmbientSound* newAmbient);
66        void unregisterAmbientSound(AmbientSound* oldAmbient);
67        void pauseAmbientSound(AmbientSound* ambient);
[6184]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
[6117]76
[3060]77    private:
[6117]78        void processCrossFading(float dt);
79        void fadeIn(AmbientSound* sound);
80        void fadeOut(AmbientSound* sound);
81
82        void checkFadeStepValidity();
[6184]83        void checkVolumeValidity();
84        void checkAmbientVolumeValidity();
85        void checkEffectsVolumeValidity();
86       
87        void updateAmbientVolume(void);
88        void updateEffectsVolume(void);
89        void updateVolume(void);
[6117]90
[3280]91        ALCdevice* device_;
[3060]92        ALCcontext* context_;
[6117]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       
[6184]101        float ambientVolume_;
102        float effectsVolume_;
103        float volume_;
104       
[3370]105        static SoundManager* singletonPtr_s;
[6184]106    }; // tolua_export
107} // tolua_export
[3060]108
[3196]109#endif /* _SoundManager_H__ */
Note: See TracBrowser for help on using the repository browser.