Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/sound3/src/orxonox/sound/SoundManager.h @ 6102

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

Improved synchronisability of the sound classes (not yet Synchronisable though!).

  • Property svn:eol-style set to native
File size: 2.5 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
38namespace orxonox
39{
40    /**
41     * The SoundManager class manages the OpenAL device, context and listener
42     * position. It is a singleton.
43     *
44     */
45    class _OrxonoxExport SoundManager : public Singleton<SoundManager>, public OrxonoxClass
46    {
47        friend class Singleton<SoundManager>;
48
49    public:
50        SoundManager();
51        ~SoundManager();
52
53        void update(const Clock& time);
54        void setConfigValues();
55
56        void setListenerPosition(const Vector3& position);
57        void setListenerOrientation(const Quaternion& orientation);
58
59        void registerAmbientSound(AmbientSound* newAmbient);
60        void unregisterAmbientSound(AmbientSound* oldAmbient);
61        void pauseAmbientSound(AmbientSound* ambient);
62
63    private:
64        void processCrossFading(float dt);
65        void fadeIn(AmbientSound* sound);
66        void fadeOut(AmbientSound* sound);
67
68        void checkFadeStepValidity();
69
70        ALCdevice* device_;
71        ALCcontext* context_;
72       
73        typedef std::list<std::pair<AmbientSound*, bool> > AmbientList;
74        AmbientList ambientSounds_;
75       
76        float crossFadeStep_;       //!< Absolute change per second (0.1 means 10% of the nominal volume) for cross fading
77        std::list<AmbientSound*> fadeInList_;
78        std::list<AmbientSound*> fadeOutList_;
79       
80        static SoundManager* singletonPtr_s;
81    };
82}
83
84#endif /* _SoundManager_H__ */
Note: See TracBrowser for help on using the repository browser.