| [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 | *      Erwin 'vaiursch' Herrsche | 
|---|
| [3060] | 24 | *   Co-authors: | 
|---|
| [5896] | 25 | *      Reto Grieder | 
|---|
| [3060] | 26 | * | 
|---|
|  | 27 | */ | 
|---|
| [6117] | 28 |  | 
|---|
| [5896] | 29 | #ifndef _BaseSound_H__ | 
|---|
|  | 30 | #define _BaseSound_H__ | 
|---|
| [3060] | 31 |  | 
|---|
|  | 32 | #include "OrxonoxPrereqs.h" | 
|---|
|  | 33 |  | 
|---|
| [5896] | 34 | #include <string> | 
|---|
| [6203] | 35 | #include <boost/shared_ptr.hpp> | 
|---|
| [5904] | 36 | #include <OgreDataStream.h> | 
|---|
| [5896] | 37 | #include "core/OrxonoxClass.h" | 
|---|
|  | 38 |  | 
|---|
| [3060] | 39 | namespace orxonox | 
|---|
|  | 40 | { | 
|---|
| [6203] | 41 | // forward declaration | 
|---|
|  | 42 | class SoundBuffer; | 
|---|
|  | 43 |  | 
|---|
| [3060] | 44 | /** | 
|---|
| [5896] | 45 | * The BaseSound class is the base class for all sound file loader classes. | 
|---|
| [3060] | 46 | * It server as main interface to the OpenAL library. | 
|---|
|  | 47 | * | 
|---|
|  | 48 | */ | 
|---|
| [5896] | 49 | class _OrxonoxExport BaseSound : virtual public OrxonoxClass | 
|---|
| [3060] | 50 | { | 
|---|
|  | 51 | public: | 
|---|
| [5896] | 52 | BaseSound(); | 
|---|
|  | 53 | virtual ~BaseSound(); | 
|---|
| [3060] | 54 |  | 
|---|
| [6117] | 55 | void XMLPortExtern(Element& xmlelement, XMLPort::Mode mode); | 
|---|
| [3060] | 56 |  | 
|---|
| [6117] | 57 | virtual void play(); | 
|---|
|  | 58 | virtual void stop(); | 
|---|
|  | 59 | virtual void pause(); | 
|---|
| [3060] | 60 |  | 
|---|
| [6320] | 61 | bool isPlaying() const { return this->state_ == Playing; } | 
|---|
|  | 62 | bool isPaused()  const { return this->state_ == Paused; } | 
|---|
|  | 63 | bool isStopped() const { return this->state_ == Stopped; } | 
|---|
| [3060] | 64 |  | 
|---|
| [6188] | 65 | void setPlaying(bool val) | 
|---|
|  | 66 | { val ? this->play() : this->stop(); } | 
|---|
|  | 67 |  | 
|---|
| [6117] | 68 | virtual void setSource(const std::string& source); | 
|---|
|  | 69 | virtual const std::string& getSource() const { return this->source_; } | 
|---|
| [6307] | 70 | inline void sourceChanged(){ this->setSource(this->source_); } | 
|---|
| [5896] | 71 |  | 
|---|
| [6117] | 72 | void setVolume(float vol); | 
|---|
|  | 73 | float getVolume() const { return this->volume_; } | 
|---|
| [6307] | 74 | inline void volumeChanged(){ this->setVolume(this->volume_); } | 
|---|
| [6184] | 75 |  | 
|---|
| [6186] | 76 | virtual float getVolumeGain(); | 
|---|
|  | 77 | void updateVolume(void); | 
|---|
| [5896] | 78 |  | 
|---|
| [6307] | 79 | bool getLooping() const   { return this->bLooping_; } | 
|---|
| [6117] | 80 | void setLooping(bool val); | 
|---|
| [6307] | 81 | inline void loopingChanged(){ this->setLooping(this->bLooping_); } | 
|---|
| [6117] | 82 |  | 
|---|
| [6202] | 83 | float getPitch() const   { return this->pitch_; } | 
|---|
|  | 84 | void setPitch(float pitch); | 
|---|
| [6307] | 85 | inline void pitchChanged(){ this->setPitch(this->pitch_); } | 
|---|
| [6320] | 86 |  | 
|---|
|  | 87 | void stateChanged(); | 
|---|
| [6202] | 88 |  | 
|---|
| [6117] | 89 | //ALuint getALAudioSource(void); | 
|---|
|  | 90 |  | 
|---|
| [5896] | 91 | protected: | 
|---|
| [6117] | 92 | enum State | 
|---|
|  | 93 | { | 
|---|
|  | 94 | Stopped, | 
|---|
|  | 95 | Playing, | 
|---|
|  | 96 | Paused | 
|---|
|  | 97 | }; | 
|---|
| [6322] | 98 | virtual void initialiseSource(); | 
|---|
| [6307] | 99 | ALint getSourceState() const; | 
|---|
| [6117] | 100 |  | 
|---|
| [6307] | 101 | ALuint          audioSource_; | 
|---|
|  | 102 | bool            bPooling_; | 
|---|
|  | 103 | shared_ptr<SoundBuffer> soundBuffer_; | 
|---|
| [6117] | 104 | std::string     source_; | 
|---|
|  | 105 | float           volume_; | 
|---|
| [6307] | 106 | bool            bLooping_; | 
|---|
| [6117] | 107 | State           state_; | 
|---|
| [6231] | 108 | float           pitch_; | 
|---|
| [6307] | 109 |  | 
|---|
|  | 110 | private: | 
|---|
| [6117] | 111 | DataStreamPtr   dataStream_; | 
|---|
| [5896] | 112 | }; | 
|---|
|  | 113 | } | 
|---|
| [3060] | 114 |  | 
|---|
| [5896] | 115 | #endif /* _BaseSound_H__ */ | 
|---|