Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/src/orxonox/sound/BaseSound.h @ 11217

Last change on this file since 11217 was 11071, checked in by landauf, 9 years ago

merged branch cpp11_v3 back to trunk

  • Property svn:eol-style set to native
File size: 3.6 KB
RevLine 
[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 */
[6417]28
[5896]29#ifndef _BaseSound_H__
30#define _BaseSound_H__
[3060]31
32#include "OrxonoxPrereqs.h"
33
[5896]34#include <string>
[11071]35#include <memory>
[5904]36#include <OgreDataStream.h>
[9667]37#include "core/object/Listable.h"
[5896]38
[3060]39namespace orxonox
40{
41    /**
[5896]42     * The BaseSound class is the base class for all sound file loader classes.
[7854]43     * It serves as main interface to the OpenAL library.
[3060]44     */
[9667]45    class _OrxonoxExport BaseSound : virtual public Listable
[3060]46    {
47    public:
[5896]48        BaseSound();
[3060]49
[6417]50        void XMLPortExtern(Element& xmlelement, XMLPort::Mode mode);
[3060]51
[6417]52        virtual void play()  { this->doPlay(); }
[7856]53        virtual bool stop()  { return this->doStop(); } // returns true if the sound source was destroyed
[6417]54        virtual void pause() { this->doPause(); }
[3060]55
[11071]56        bool isPlaying() const { return this->state_ == State::Playing; }
57        bool isPaused()  const { return this->state_ == State::Paused; }
58        bool isStopped() const { return this->state_ == State::Stopped; }
[3060]59
[6417]60        virtual void setSource(const std::string& source);
61        virtual const std::string& getSource() const
62            { return this->source_; }
[5896]63
[6417]64        void setVolume(float vol);
65        float getVolume() const
66            { return this->volume_; }
67        void updateVolume();
[5896]68
[6417]69        bool getLooping() const
70            { return this->bLooping_; }
71        void setLooping(bool val);
72
73        float getPitch() const
74            { return this->pitch_; }
75        void setPitch(float pitch);
76
[5896]77    protected:
[11071]78        enum class State
[6417]79        {
80            Stopped,
81            Playing,
82            Paused
83        };
[5896]84
[6417]85        virtual ~BaseSound();
[3060]86
[6417]87        void doPlay();
[7856]88        bool doStop(); // returns true if the sound source was destroyed
[6417]89        void doPause();
90
91        // network callbacks
92        inline void pitchChanged()
93            { this->setPitch(this->pitch_); }
94        inline void loopingChanged()
95            { this->setLooping(this->bLooping_); }
96        inline void volumeChanged()
97            { this->setVolume(this->volume_); }
98        inline void sourceChanged()
99            { this->setSource(this->source_); }
100        void stateChanged();
101
102        virtual void initialiseSource();
103        ALint getSourceState() const;
104
105        virtual float getRealVolume() = 0;
106
107        ALuint          audioSource_;
108        bool            bPooling_;
[11071]109        std::shared_ptr<SoundBuffer> soundBuffer_;
[6417]110        std::string     source_;
111        float           volume_;
112        bool            bLooping_;
[11071]113        State           state_;       // This Variable is actually of type State
[6417]114        float           pitch_;
115
[5896]116    private:
[6417]117        DataStreamPtr   dataStream_;
[5896]118    };
119}
[3060]120
[5896]121#endif /* _BaseSound_H__ */
Note: See TracBrowser for help on using the repository browser.