]> Dogcows Code - chaz/yoink/blob - src/moof/sound.hh
begin cleaning up resource management
[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 resource_handle<sound> sound_handle;
33 class sound_stream;
34 typedef resource_handle<sound_stream> sound_stream_handle;
35
36
37 class sound : public resource
38 {
39 public:
40
41 //sound();
42 explicit sound(const std::string& path);
43
44 virtual ~sound() {}
45
46 // this implicitly stops the sound if it is playing
47 void sample(const std::string& path);
48
49 virtual void play();
50 void stop();
51 void pause();
52
53 void toggle();
54 bool is_playing() const;
55
56 void position(const vector3& position);
57 void velocity(const vector3& velocity);
58 void gain(scalar gain);
59 void pitch(scalar pitch);
60 void loop(bool looping);
61
62 static void listener_position(const vector3& position);
63 static void listener_velocity(const vector3& velocity);
64 static void listener_orientation(const vector3& forward,
65 const vector3& up);
66
67 protected:
68
69 class impl;
70 boost::shared_ptr<impl> impl_;
71 };
72
73
74 class sound_stream : public sound
75 {
76 public:
77
78 //sound_stream();
79 explicit sound_stream(const std::string& path) :
80 sound(path) {}
81
82 void enqueue(const std::string& path);
83
84 void play();
85 };
86
87
88 } // namespace moof
89
90 #endif // _MOOF_SOUND_HH_
91
This page took 0.03286 seconds and 4 git commands to generate.