Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/presentation2/src/orxonox/sound/BaseSound.h @ 6382

Last change on this file since 6382 was 6382, checked in by rgrieder, 16 years ago

Several small changes in sound:

  • Fixed a bug that caused a sound source to be initialised on pause() even it already existed
  • The XML parameter is now called "looping" instead of "loop" because looping was used really all over the code
  • The "play" XML parameter doesn't exist anymore, use "playOnLoad" for AmbientSound only.
  • Added "pitch" XML parameter
  • Changes in synchronisation policy: Ambient sound should not synchronise the state but instead th new playOnLoad parameter
  • 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 */
[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]39namespace 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();
[3060]53
[6117]54        void XMLPortExtern(Element& xmlelement, XMLPort::Mode mode);
[3060]55
[6382]56        virtual void play()  { this->doPlay(); }
57        virtual void stop()  { this->doStop(); }
58        virtual void pause() { this->doPause(); }
[3060]59
[6320]60        bool isPlaying() const { return this->state_ == Playing; }
61        bool isPaused()  const { return this->state_ == Paused; }
62        bool isStopped() const { return this->state_ == Stopped; }
[3060]63
[6117]64        virtual void setSource(const std::string& source);
[6370]65        virtual const std::string& getSource() const
66            { return this->source_; }
[5896]67
[6117]68        void setVolume(float vol);
[6370]69        float getVolume() const
70            { return this->volume_; }
71        void updateVolume();
[5896]72
[6370]73        bool getLooping() const
74            { return this->bLooping_; }
[6117]75        void setLooping(bool val);
76
[6370]77        float getPitch() const
78            { return this->pitch_; }
[6202]79        void setPitch(float pitch);
80
[5896]81    protected:
[6117]82        enum State
83        {
84            Stopped,
85            Playing,
86            Paused
87        };
[6370]88
[6382]89        virtual ~BaseSound();
90
91        void doPlay();
92        void doStop();
93        void doPause();
94
[6370]95        // network callbacks
96        inline void pitchChanged()
97            { this->setPitch(this->pitch_); }
98        inline void loopingChanged()
99            { this->setLooping(this->bLooping_); }
100        inline void volumeChanged()
101            { this->setVolume(this->volume_); }
102        inline void sourceChanged()
103            { this->setSource(this->source_); }
104        void stateChanged();
105
[6322]106        virtual void initialiseSource();
[6307]107        ALint getSourceState() const;
[6117]108
[6370]109        virtual float getRealVolume() = 0;
110
[6307]111        ALuint          audioSource_;
112        bool            bPooling_;
113        shared_ptr<SoundBuffer> soundBuffer_;
[6117]114        std::string     source_;
115        float           volume_;
[6307]116        bool            bLooping_;
[6117]117        State           state_;
[6231]118        float           pitch_;
[6307]119
120    private:
[6117]121        DataStreamPtr   dataStream_;
[5896]122    };
123}
[3060]124
[5896]125#endif /* _BaseSound_H__ */
Note: See TracBrowser for help on using the repository browser.