Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 7185 was 7163, checked in by dafrick, 14 years ago

Merged presentation3 branch into trunk.

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