aboutsummaryrefslogtreecommitdiff
path: root/examples/simpletest/WaveFile.h
diff options
context:
space:
mode:
Diffstat (limited to 'examples/simpletest/WaveFile.h')
-rw-r--r--examples/simpletest/WaveFile.h66
1 files changed, 66 insertions, 0 deletions
diff --git a/examples/simpletest/WaveFile.h b/examples/simpletest/WaveFile.h
new file mode 100644
index 0000000..b684b41
--- /dev/null
+++ b/examples/simpletest/WaveFile.h
@@ -0,0 +1,66 @@
+#ifndef WaveFile_h__
+#define WaveFile_h__
+
+#include <string>
+
+///\note All meta data is undefined if IsLoaded() == false
+class WaveFile
+{
+public:
+ enum AudioFormat
+ {
+ PCM = 1,
+ WAVE_FORMAT_IEEE_FLOAT = 3
+ };
+
+ WaveFile();
+ WaveFile(const std::string &filename);
+ ~WaveFile();
+
+ bool Load(const std::string &filename);
+ void Unload();
+
+ inline bool IsLoaded() const
+ {
+ return (data != nullptr && size != 0);
+ }
+
+ inline AudioFormat GetAudioFormat() const
+ {
+ return meta.audioFormat;
+ }
+ inline unsigned int GetNumChannels() const
+ {
+ return meta.numChannels;
+ }
+ inline unsigned int GetSampleRate() const
+ {
+ return meta.sampleRate;
+ }
+ inline unsigned int GetBitsPerSample() const
+ {
+ return meta.bitsPerSample;
+ }
+
+ inline const char *GetData() const
+ {
+ return data;
+ }
+ inline std::size_t GetDataSize() const
+ {
+ return size;
+ }
+
+private:
+ struct Meta
+ {
+ AudioFormat audioFormat;
+ unsigned int numChannels;
+ unsigned int sampleRate;
+ unsigned int bitsPerSample;
+ } meta;
+ char *data;
+ std::size_t size;
+};
+
+#endif // WaveFile_h__