#ifndef __SOUND_EXPORTER_HPP__
#define __SOUND_EXPORTER_HPP__
#include <fstream>
#include <vector>
#include "../emucore/m6502/src/bspf/src/bspf.hxx"
namespace ale {
namespace sound {
template <typename T> void write(std::ofstream& stream, const T& t) {
stream.write((const char*)&t, sizeof(T));
}
class SoundExporter {
public:
static const int SamplesPerFrame = 512;
using SampleType = uInt8;
SoundExporter(const std::string& filename, int channels);
~SoundExporter();
void addSamples(SampleType* s, int len);
private:
void writeWAVData();
std::string m_filename;
int m_channels;
std::vector<SampleType> m_data;
size_t m_samples_since_write;
};
} }
#endif