2016-01-06 20:02:06 +00:00
|
|
|
#pragma once
|
2015-09-17 19:47:58 +00:00
|
|
|
|
2015-11-19 20:17:35 +00:00
|
|
|
#include <boost/filesystem/path.hpp>
|
|
|
|
#include <boost/filesystem/fstream.hpp>
|
2015-09-17 19:47:58 +00:00
|
|
|
#include "AudioStream.h"
|
|
|
|
|
|
|
|
enum class SampleFormat {
|
|
|
|
UInt8,
|
|
|
|
Int16,
|
|
|
|
Int24,
|
|
|
|
Float32
|
|
|
|
};
|
|
|
|
|
|
|
|
class WaveFileReader : public AudioStream {
|
|
|
|
public:
|
2015-11-19 20:17:35 +00:00
|
|
|
WaveFileReader(boost::filesystem::path filePath);
|
2016-03-07 20:28:31 +00:00
|
|
|
WaveFileReader(const WaveFileReader& rhs, bool reset);
|
2016-04-19 19:12:44 +00:00
|
|
|
std::unique_ptr<AudioStream> clone(bool reset) const override;
|
|
|
|
int getSampleRate() const override ;
|
2016-06-14 15:41:58 +00:00
|
|
|
int64_t getSampleCount() const override;
|
|
|
|
int64_t getSampleIndex() const override;
|
|
|
|
void seek(int64_t sampleIndex) override;
|
2016-03-07 20:28:31 +00:00
|
|
|
float readSample() override;
|
2015-09-17 19:47:58 +00:00
|
|
|
|
|
|
|
private:
|
2016-03-07 20:28:31 +00:00
|
|
|
void openFile();
|
|
|
|
|
|
|
|
private:
|
|
|
|
boost::filesystem::path filePath;
|
2015-11-19 20:17:35 +00:00
|
|
|
boost::filesystem::ifstream file;
|
2016-03-07 20:28:31 +00:00
|
|
|
int bytesPerSample;
|
2015-09-17 19:47:58 +00:00
|
|
|
SampleFormat sampleFormat;
|
|
|
|
int frameRate;
|
2016-06-14 15:41:58 +00:00
|
|
|
int64_t frameCount;
|
2015-09-17 19:47:58 +00:00
|
|
|
int channelCount;
|
2016-03-15 19:12:11 +00:00
|
|
|
std::streampos dataOffset;
|
2016-06-14 17:46:30 +00:00
|
|
|
int64_t frameIndex;
|
2015-09-17 19:47:58 +00:00
|
|
|
};
|