Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 6202 was 6202, checked in by youngk, 14 years ago

Implemented speed dependent audio pitch. BUG pitching doesn't currently work.

  • Property svn:eol-style set to native
File size: 2.8 KB
Line 
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:
23 *      Erwin 'vaiursch' Herrsche
24 *   Co-authors:
25 *      Reto Grieder
26 *
27 */
28
29#ifndef _BaseSound_H__
30#define _BaseSound_H__
31
32#include "OrxonoxPrereqs.h"
33
34#include <string>
35#include <OgreDataStream.h>
36#include "core/OrxonoxClass.h"
37
38namespace orxonox
39{
40    /**
41     * The BaseSound class is the base class for all sound file loader classes.
42     * It server as main interface to the OpenAL library.
43     *
44     */
45    class _OrxonoxExport BaseSound : virtual public OrxonoxClass
46    {
47    public:
48        BaseSound();
49        virtual ~BaseSound();
50
51        void XMLPortExtern(Element& xmlelement, XMLPort::Mode mode);
52
53        virtual void play();
54        virtual void stop();
55        virtual void pause();
56
57        bool isPlaying() { return this->state_ == Playing; }
58        bool isPaused()  { return this->state_ == Paused; }
59        bool isStopped() { return this->state_ == Stopped; }
60
61        void setPlaying(bool val)
62            { val ? this->play() : this->stop(); }
63
64        virtual void setSource(const std::string& source);
65        virtual const std::string& getSource() const { return this->source_; }
66
67        void setVolume(float vol);
68        float getVolume() const { return this->volume_; }
69       
70        virtual float getVolumeGain();
71        void updateVolume(void);
72
73        bool getLooping() const   { return this->bLoop_; }
74        void setLooping(bool val);
75
76        float getPitch() const   { return this->pitch_; }
77        void setPitch(float pitch);
78
79        //ALuint getALAudioSource(void);
80
81    protected:
82        ALuint loadOggFile();
83
84        ALuint audioSource_;
85        ALuint audioBuffer_;
86
87    private:
88        enum State
89        {
90            Stopped,
91            Playing,
92            Paused
93        };
94
95        std::string     source_;
96        float           volume_;
97        float           pitch_;
98        bool            bLoop_;
99        State           state_;
100        DataStreamPtr   dataStream_;
101    };
102}
103
104#endif /* _BaseSound_H__ */
Note: See TracBrowser for help on using the repository browser.