]> Dogcows Code - chaz/yoink/blob - src/moof/sound.hh
the massive refactoring effort
[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 moof {
29
30
31 class sound;
32 typedef boost::shared_ptr<sound> sound_ptr;
33
34 class sound_stream;
35 typedef boost::shared_ptr<sound_stream> sound_stream_ptr;
36
37
38 class sound : public resource
39 {
40 public:
41
42 static sound_ptr alloc(const std::string& name)
43 {
44 return sound_ptr(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 sample(const std::string& name);
54
55 virtual void play();
56 void stop();
57 void pause();
58
59 void toggle();
60 bool is_playing() const;
61
62 void position(const vector3& position);
63 void velocity(const vector3& velocity);
64 void gain(scalar gain);
65 void pitch(scalar pitch);
66 void loop(bool looping);
67
68 static void listener_position(const vector3& position);
69 static void listener_velocity(const vector3& velocity);
70 static void listener_orientation(const vector3& forward,
71 const vector3& up);
72
73 static bool find_path(std::string& name);
74
75 protected:
76
77 class impl;
78 boost::shared_ptr<impl> impl_;
79 };
80
81
82 class sound_stream : public sound
83 {
84 public:
85
86 static sound_stream_ptr alloc(const std::string& name)
87 {
88 return sound_stream_ptr(new sound_stream(name));
89 }
90
91 sound_stream();
92 explicit sound_stream(const std::string& name) :
93 sound(name) {}
94
95 void enqueue(const std::string& name);
96
97 void play();
98 };
99
100
101 } // namespace moof
102
103 #endif // _MOOF_SOUND_HH_
104
This page took 0.038288 seconds and 4 git commands to generate.