Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/src/orxonox/sound/SoundManager.h @ 8804

Last change on this file since 8804 was 8351, checked in by rgrieder, 14 years ago

Merged kicklib2 branch back to trunk (includes former branches ois_update, mac_osx and kicklib).

Notes for updating

Linux:
You don't need an extra package for CEGUILua and Tolua, it's already shipped with CEGUI.
However you do need to make sure that the OgreRenderer is installed too with CEGUI 0.7 (may be a separate package).
Also, Orxonox now recognises if you install the CgProgramManager (a separate package available on newer Ubuntu on Debian systems).

Windows:
Download the new dependency packages versioned 6.0 and use these. If you have problems with that or if you don't like the in game console problem mentioned below, you can download the new 4.3 version of the packages (only available for Visual Studio 2005/2008).

Key new features:

  • *Support for Mac OS X*
  • Visual Studio 2010 support
  • Bullet library update to 2.77
  • OIS library update to 1.3
  • Support for CEGUI 0.7 —> Support for Arch Linux and even SuSE
  • Improved install target
  • Compiles now with GCC 4.6
  • Ogre Cg Shader plugin activated for Linux if available
  • And of course lots of bug fixes

There are also some regressions:

  • No support for CEGUI 0.5, Ogre 1.4 and boost 1.35 - 1.39 any more
  • In game console is not working in main menu for CEGUI 0.7
  • Tolua (just the C lib, not the application) and CEGUILua libraries are no longer in our repository. —> You will need to get these as well when compiling Orxonox
  • And of course lots of new bugs we don't yet know about
  • Property svn:eol-style set to native
File size: 5.2 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 *       Reto Grieder
26 *   Co-authors:
27 *      ...
28 */
29
30#ifndef _SoundManager_H__
31#define _SoundManager_H__
32
33#include "OrxonoxPrereqs.h"
34
35#include <list>
36#include <map>
37#include <string>
38#include <boost/shared_ptr.hpp>
39
40#include "util/Singleton.h"
41#include "core/OrxonoxClass.h"
42#include "core/SmartPtr.h"
43
44// tolua_begin
45namespace orxonox
46{
47    //! Enum for the sound type.
48    namespace SoundType
49    {
50        enum Value
51        {
52            All     = 0,
53            Music   = 1,
54            Effects = 2
55        };
56    }
57
58    //! The SoundManager class manages the OpenAL device, context and listener position.
59    class _OrxonoxExport SoundManager
60    // tolua_end
61        : public Singleton<SoundManager>, public OrxonoxClass
62    { // tolua_export
63        friend class Singleton<SoundManager>;
64
65    public:
66        SoundManager();
67        ~SoundManager();
68
69        void preUpdate(const Clock& time);
70        void setConfigValues();
71
72        // tolua_begin
73        static SoundManager& getInstance() { return Singleton<SoundManager>::getInstance(); }
74        static bool exists() { return Singleton<SoundManager>::exists(); }
75
76        std::string getDeviceName(unsigned int index) const
77            { return index < this->deviceNames_.size() ? this->deviceNames_[index] : std::string(); }
78        // tolua_end
79
80        void setListenerPosition(const Vector3& position);
81        void setListenerOrientation(const Quaternion& orientation);
82
83        void registerAmbientSound(AmbientSound* newAmbient);
84        void unregisterAmbientSound(AmbientSound* oldAmbient);
85        void pauseAmbientSound(AmbientSound* ambient);
86
87        // tolua_begin
88        void setVolume(float vol, SoundType::Value type);
89        float getVolume(SoundType::Value type);
90        float getRealVolume(SoundType::Value type);
91
92        void toggleMute(SoundType::Value type);
93        bool getMute(SoundType::Value type);
94        // tolua_end
95
96        shared_ptr<SoundBuffer> getSoundBuffer(const std::string& filename);
97        void releaseSoundBuffer(const shared_ptr<SoundBuffer>& buffer, bool bPoolBuffer);
98
99        ALuint getSoundSource(BaseSound* object);
100        void releaseSoundSource(ALuint source);
101
102        static std::string getALErrorString(ALenum error);
103
104    private:
105        void processCrossFading(float dt);
106        void fadeIn(const SmartPtr<AmbientSound>& sound);
107        void fadeOut(const SmartPtr<AmbientSound>& sound);
108
109        void checkFadeStepValidity();
110
111        void checkVolumeValidity(SoundType::Value type);
112        void checkSoundVolumeValidity()   { this->checkVolumeValidity(SoundType::All); }
113        void checkAmbientVolumeValidity() { this->checkVolumeValidity(SoundType::Music); }
114        void checkEffectsVolumeValidity() { this->checkVolumeValidity(SoundType::Effects); }
115        void updateVolume(SoundType::Value type);
116
117        unsigned int createSoundSources(unsigned int n);
118
119        // OpenAL device/context related
120        std::vector<std::string> deviceNames_;
121        ALCdevice* device_;
122        ALCcontext* context_;
123
124        // Ambient sound related
125        typedef std::list<std::pair<AmbientSound*, bool> > AmbientList;
126        AmbientList                        ambientSounds_;
127        //! Absolute change per second (0.1 means 10% of the nominal volume) for cross fading
128        float                              crossFadeStep_;
129        std::list<SmartPtr<AmbientSound> > fadeInList_;
130        std::list<SmartPtr<AmbientSound> > fadeOutList_;
131
132        // Volume related
133        float volume_[3];
134        float mute_[3];
135
136        // Sound buffer related
137        static const unsigned int maxEffectsPoolSize_s = 40 * 1024 * 1024;
138        unsigned int effectsPoolSize_;
139        typedef std::list<shared_ptr<SoundBuffer> > EffectsPoolList;
140        EffectsPoolList effectsPool_;
141        typedef std::map<std::string, shared_ptr<SoundBuffer> > SoundBufferMap;
142        SoundBufferMap soundBuffers_;
143
144        // Sound source related
145        unsigned int minSources_;
146        unsigned int maxSources_;
147        std::vector<ALuint> availableSoundSources_;
148        std::vector<std::pair<ALuint, BaseSound*> > usedSoundSources_;
149
150        bool bDestructorCalled_; ///< Becomes true if the destructor is called - used to prevent ambient sounds from registering after the lists were cleared
151
152        static SoundManager* singletonPtr_s;
153    }; // tolua_export
154} // tolua_export
155
156#endif /* _SoundManager_H__ */
Note: See TracBrowser for help on using the repository browser.