]> Dogcows Code - chaz/yoink/blob - src/Moof/Sound.hh
d3cfa895f4743e747a89fa7f984d8f80c6c6a562
[chaz/yoink] / src / Moof / Sound.hh
1
2 /*] Copyright (c) 2009-2010, Charles McGarvey [**************************
3 **] All rights reserved.
4 *
5 * vi:ts=4 sw=4 tw=75
6 *
7 * Distributable under the terms and conditions of the 2-clause BSD license;
8 * see the file COPYING for a complete text of the license.
9 *
10 **************************************************************************/
11
12 #ifndef _MOOF_SOUND_HH_
13 #define _MOOF_SOUND_HH_
14
15 /**
16 * @file Sound.hh
17 * Load and play sounds, current supports ogg vorbis.
18 */
19
20 #include <string>
21
22 #include <boost/shared_ptr.hpp>
23
24 #include <Moof/Math.hh>
25 #include <Moof/Resource.hh>
26
27
28 namespace Mf {
29
30
31 class Sound;
32 typedef boost::shared_ptr<Sound> SoundP;
33
34 class SoundStream;
35 typedef boost::shared_ptr<SoundStream> SoundStreamP;
36
37
38 class Sound : public Resource
39 {
40 public:
41
42 static SoundP alloc(const std::string& name)
43 {
44 return SoundP(new Sound(name));
45 }
46
47 Sound();
48 explicit Sound(const std::string& name);
49
50 virtual ~Sound() {}
51
52 // this implicitly stops the sound if it is playing
53 void setSample(const std::string& name);
54
55 virtual void play();
56 void stop();
57 void pause();
58
59 void toggle();
60 bool isPlaying() const;
61
62 void setPosition(const Vector3& position);
63 void setVelocity(const Vector3& velocity);
64 void setGain(Scalar gain);
65 void setPitch(Scalar pitch);
66 void setLooping(bool looping);
67
68 static void setListenerPosition(const Vector3& position);
69 static void setListenerVelocity(const Vector3& velocity);
70 static void setListenerOrientation(const Vector3& forward,
71 const Vector3& up);
72
73 static std::string getPath(const std::string& name);
74
75 protected:
76
77 class Impl;
78 boost::shared_ptr<Impl> mImpl;
79 };
80
81
82 class SoundStream : public Sound
83 {
84 public:
85
86 static SoundStreamP alloc(const std::string& name)
87 {
88 return SoundStreamP(new SoundStream(name));
89 }
90
91 SoundStream();
92 explicit SoundStream(const std::string& name) :
93 Sound(name) {}
94
95 void enqueue(const std::string& name);
96
97 void play();
98 };
99
100
101 } // namespace Mf
102
103 #endif // _MOOF_SOUND_HH_
104
This page took 0.035449 seconds and 3 git commands to generate.