]> Dogcows Code - chaz/yoink/blobdiff - src/moof/sound.hh
the massive refactoring effort
[chaz/yoink] / src / moof / sound.hh
diff --git a/src/moof/sound.hh b/src/moof/sound.hh
new file mode 100644 (file)
index 0000000..5a60f0c
--- /dev/null
@@ -0,0 +1,104 @@
+
+/*]  Copyright (c) 2009-2010, Charles McGarvey  [**************************
+**]  All rights reserved.
+*
+* vi:ts=4 sw=4 tw=75
+*
+* Distributable under the terms and conditions of the 2-clause BSD license;
+* see the file COPYING for a complete text of the license.
+*
+**************************************************************************/
+
+#ifndef _MOOF_SOUND_HH_
+#define _MOOF_SOUND_HH_
+
+/**
+ * \file sound.hh
+ * Load and play sounds, current supports ogg vorbis.
+ */
+
+#include <string>
+
+#include <boost/shared_ptr.hpp>
+
+#include <moof/math.hh>
+#include <moof/resource.hh>
+
+
+namespace moof {
+
+
+class sound;
+typedef boost::shared_ptr<sound> sound_ptr;
+
+class sound_stream;
+typedef boost::shared_ptr<sound_stream> sound_stream_ptr;
+
+
+class sound : public resource
+{
+public:
+
+       static sound_ptr alloc(const std::string& name)
+       {
+               return sound_ptr(new sound(name));
+       }
+
+       sound();
+       explicit sound(const std::string& name);
+
+       virtual ~sound() {}
+
+       // this implicitly stops the sound if it is playing
+       void sample(const std::string& name);
+
+       virtual void play();
+       void stop();
+       void pause();
+
+       void toggle();
+       bool is_playing() const;
+
+       void position(const vector3& position);
+       void velocity(const vector3& velocity);
+       void gain(scalar gain);
+       void pitch(scalar pitch);
+       void loop(bool looping);
+
+       static void listener_position(const vector3& position);
+       static void listener_velocity(const vector3& velocity);
+       static void listener_orientation(const vector3& forward,
+                                                                        const vector3& up);
+
+       static bool find_path(std::string& name);
+
+protected:
+
+       class impl;
+       boost::shared_ptr<impl> impl_;
+};
+
+
+class sound_stream : public sound
+{
+public:
+
+       static sound_stream_ptr alloc(const std::string& name)
+       {
+               return sound_stream_ptr(new sound_stream(name));
+       }
+
+       sound_stream();
+       explicit sound_stream(const std::string& name) :
+               sound(name) {}
+
+       void enqueue(const std::string& name);
+
+       void play();
+};
+
+
+} // namespace moof
+
+#endif // _MOOF_SOUND_HH_
+
This page took 0.022955 seconds and 4 git commands to generate.