[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: |
---|
[5896] | 23 | * Reto Grieder |
---|
[6767] | 24 | * |
---|
| 25 | * Co-authors: |
---|
[6417] | 26 | * Kevin Young |
---|
[3060] | 27 | * |
---|
| 28 | */ |
---|
[6417] | 29 | |
---|
[5896] | 30 | #ifndef _AmbientSound_H__ |
---|
| 31 | #define _AmbientSound_H__ |
---|
[3060] | 32 | |
---|
[6506] | 33 | #include <boost/thread.hpp> |
---|
[3060] | 34 | |
---|
[6506] | 35 | #include "sound/SoundPrereqs.h" |
---|
| 36 | |
---|
[5896] | 37 | #include "core/BaseObject.h" |
---|
[6417] | 38 | #include "network/synchronisable/Synchronisable.h" |
---|
| 39 | #include "BaseSound.h" |
---|
| 40 | #include "MoodManager.h" |
---|
[5896] | 41 | |
---|
[3060] | 42 | namespace orxonox |
---|
| 43 | { |
---|
| 44 | /** |
---|
[6767] | 45 | * The AmbientSound class implements the non-3D sound, i.e. sound files that are used for atmospheric |
---|
| 46 | * highlighting. |
---|
| 47 | * It interfaces with BaseSound and is controllable by MoodManager. |
---|
| 48 | * Ambient sounds are always cross-faded. New sounds are registered and activated/deactivated as needed. |
---|
[3060] | 49 | * |
---|
| 50 | */ |
---|
[6417] | 51 | class _OrxonoxExport AmbientSound : public BaseSound, public BaseObject, public Synchronisable, public MoodListener |
---|
[3060] | 52 | { |
---|
[6417] | 53 | friend class SoundManager; |
---|
| 54 | |
---|
[3060] | 55 | public: |
---|
[5896] | 56 | AmbientSound(BaseObject* creator); |
---|
[3060] | 57 | |
---|
[6417] | 58 | void XMLPort(Element& xmlelement, XMLPort::Mode mode); |
---|
| 59 | void XMLEventPort(Element& xmlelement, XMLPort::Mode mode); |
---|
| 60 | void changedActivity(); |
---|
[3060] | 61 | |
---|
[6417] | 62 | void play(); |
---|
| 63 | void stop(); |
---|
| 64 | void pause(); |
---|
| 65 | |
---|
| 66 | void setAmbientSource(const std::string& source); |
---|
| 67 | inline const std::string& getAmbientSource() const |
---|
| 68 | { return this->ambientSource_; } |
---|
| 69 | |
---|
| 70 | void setPlayOnLoad(bool val); |
---|
| 71 | bool getPlayOnLoad() const |
---|
| 72 | { return this->bPlayOnLoad_; } |
---|
| 73 | |
---|
| 74 | protected: |
---|
| 75 | ~AmbientSound() { } |
---|
| 76 | |
---|
[6506] | 77 | void doStop(); |
---|
[6674] | 78 | void doPlay(); |
---|
[6506] | 79 | |
---|
[3060] | 80 | private: |
---|
[6417] | 81 | void preDestroy(); |
---|
| 82 | void registerVariables(); |
---|
| 83 | float getRealVolume(); |
---|
| 84 | void moodChanged(const std::string& mood); |
---|
| 85 | inline void ambientSourceChanged() |
---|
| 86 | { this->setAmbientSource(this->ambientSource_); } |
---|
| 87 | inline void playOnLoadChanged() |
---|
| 88 | { this->setPlayOnLoad(this->bPlayOnLoad_); } |
---|
| 89 | |
---|
| 90 | std::string ambientSource_; //!< Analogous to source_, but mood independent |
---|
| 91 | bool bPlayOnLoad_; //!< Play the sound immediately when loaded |
---|
[6506] | 92 | |
---|
| 93 | boost::thread soundstreamthread_; // hacky solution for streaming |
---|
| 94 | void setStreamSource(const std::string& source); |
---|
[5896] | 95 | }; |
---|
| 96 | } |
---|
[3060] | 97 | |
---|
[5896] | 98 | #endif /* _AmbientSound_H__ */ |
---|