rhubarb-lip-sync/src/audio/WaveFileReader.h

39 lines
862 B
C
Raw Normal View History

#pragma once
#include <boost/filesystem/path.hpp>
#include <boost/filesystem/fstream.hpp>
#include "AudioStream.h"
enum class SampleFormat {
UInt8,
Int16,
Int24,
Float32
};
class WaveFileReader : public AudioStream {
public:
WaveFileReader(boost::filesystem::path filePath);
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 ;
int64_t getSampleCount() const override;
int64_t getSampleIndex() const override;
void seek(int64_t sampleIndex) override;
float readSample() override;
private:
void openFile();
private:
boost::filesystem::path filePath;
boost::filesystem::ifstream file;
int bytesPerSample;
SampleFormat sampleFormat;
int frameRate;
int64_t frameCount;
int channelCount;
2016-03-15 19:12:11 +00:00
std::streampos dataOffset;
int64_t frameIndex;
};