37 return val > 1.0 ? val-2.0 : val;
51 return (1 << (bitdepth-1)) - 1;
63 m_WavFileStream.open(sFileName.c_str(), std::ios_base::in | std::ios_base::binary);
99 char headerInfo[5] = {0,0,0,0,0};
102 if (strcmp(headerInfo,
"RIFF"))
111 if (strcmp(headerInfo,
"WAVE"))
217 uint32_t samples[2] = {0,0};
245 std::vector<Sample> vSamples;
247 for (
size_t i = 0; i < len; i++)
252 vSamples.push_back(
read());
269 for (
const Sample& s : vSamples)
virtual std::vector< Sample > readSome(size_t len) const override
Read a block of samples from the audio stream.
bool readHeader()
Private member function to read the wave file header to memory. It will ensure that the current file ...
virtual void write(const Sample &sample) override
Write a sample to the audio stream.
virtual ~WavFile()
Destructor. Will close the file stream and update the header.
virtual void writeSome(const std::vector< Sample > vSamples) override
Write a block of samples to the audio stream.
void closeFile()
Updates the wave file header, which is currently open, and closes the file afterwards.
virtual Sample read() const override
Read a sample from the audio stream.
virtual void newFile() override
Prepares the wave file header for a new file, opens the stream and writes the header to the file....
std::fstream m_WavFileStream
WavFile(const std::string &sFileName)
Constructor. Tries to open the wave file, if it exists.
uint32_t m_DataBlockLength
static double getMaxVal(uint16_t bitdepth)
Calculates the maximal value available with the current bitdepth.
static double convertFromUnsigned(double val)
Applies the necessary conversion to obtain a signed floating point value from an unsigned integer.
CONSTCD11 std::enable_if<!std::chrono::treat_as_floating_point< T >::value, T >::type trunc(T t) NOEXCEPT
bool isnan(const value_type &v)
Defines a sample in the audio stream, i.e. a single value per channel.