[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 |
---|
[6069] | 24 | * Kevin Young |
---|
[3060] | 25 | * Co-authors: |
---|
| 26 | * ... |
---|
| 27 | */ |
---|
[6069] | 28 | |
---|
[3196] | 29 | #ifndef _SoundManager_H__ |
---|
| 30 | #define _SoundManager_H__ |
---|
[3060] | 31 | |
---|
| 32 | #include "OrxonoxPrereqs.h" |
---|
| 33 | |
---|
[3196] | 34 | #include <list> |
---|
[6069] | 35 | #include <string> |
---|
[3370] | 36 | #include "util/Singleton.h" |
---|
[3196] | 37 | |
---|
[3060] | 38 | namespace orxonox |
---|
| 39 | { |
---|
| 40 | /** |
---|
| 41 | * The SoundManager class manages the OpenAL device, context and listener |
---|
[5929] | 42 | * position. It is a singleton. |
---|
[3060] | 43 | * |
---|
| 44 | */ |
---|
[6046] | 45 | class _OrxonoxExport SoundManager : public Singleton<SoundManager>, public OrxonoxClass |
---|
[3060] | 46 | { |
---|
[3370] | 47 | friend class Singleton<SoundManager>; |
---|
[6069] | 48 | |
---|
[3060] | 49 | public: |
---|
| 50 | SoundManager(); |
---|
| 51 | ~SoundManager(); |
---|
| 52 | |
---|
[6069] | 53 | void update(const Clock& time); |
---|
| 54 | void setConfigValues(); |
---|
[6046] | 55 | |
---|
[5929] | 56 | void setListenerPosition(const Vector3& position); |
---|
| 57 | void setListenerOrientation(const Quaternion& orientation); |
---|
[6046] | 58 | |
---|
| 59 | void registerAmbientSound(AmbientSound* newAmbient); |
---|
[6069] | 60 | void unregisterAmbientSound(AmbientSound* oldAmbient); |
---|
| 61 | void pauseAmbientSound(AmbientSound* ambient); |
---|
[5929] | 62 | |
---|
[3060] | 63 | private: |
---|
[6069] | 64 | void processCrossFading(float dt); |
---|
| 65 | void fadeIn(AmbientSound* sound); |
---|
| 66 | void fadeOut(AmbientSound* sound); |
---|
| 67 | |
---|
| 68 | void checkFadeStepValidity(); |
---|
| 69 | |
---|
[3280] | 70 | ALCdevice* device_; |
---|
[3060] | 71 | ALCcontext* context_; |
---|
[6046] | 72 | |
---|
[6069] | 73 | typedef std::list<std::pair<AmbientSound*, bool> > AmbientList; |
---|
| 74 | AmbientList ambientSounds_; |
---|
[6046] | 75 | |
---|
[6069] | 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_; |
---|
[6046] | 79 | |
---|
[3370] | 80 | static SoundManager* singletonPtr_s; |
---|
[5929] | 81 | }; |
---|
| 82 | } |
---|
[3060] | 83 | |
---|
[3196] | 84 | #endif /* _SoundManager_H__ */ |
---|