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