]> git.tdb.fi Git - libs/al.git/blobdiff - source/sounddecoder.h
Split Sound into SoundDecoder and Waveform parts
[libs/al.git] / source / sounddecoder.h
diff --git a/source/sounddecoder.h b/source/sounddecoder.h
new file mode 100644 (file)
index 0000000..ad56646
--- /dev/null
@@ -0,0 +1,46 @@
+#ifndef MSP_AL_SOUND_H_
+#define MSP_AL_SOUND_H_
+
+#include <string>
+#include <vorbis/vorbisfile.h>
+#include "format.h"
+
+namespace Msp {
+namespace AL {
+
+/**
+This class facilitates loading sound files.  Currently only Ogg Vorbis is
+supported.
+*/
+class SoundDecoder
+{
+private:
+       OggVorbis_File ovfile;
+       unsigned freq;
+       unsigned size;
+       Format format;
+       bool eof_flag;
+
+public:
+       SoundDecoder();
+       ~SoundDecoder();
+
+       void open_file(const std::string &);
+       void open_memory(const void *, unsigned);
+private:
+       void open_common();
+public:
+       void close();
+       void rewind();
+       unsigned read(char *, unsigned);
+       bool eof() const { return eof_flag; }
+
+       Format get_format() const { return format; }
+       unsigned get_frequency() const { return freq; }
+       unsigned get_size() const { return size; }
+};
+
+} // namespace AL
+} // namespace Msp
+
+#endif