// Copyright (c) 2012-2021 Wojciech Figat. All rights reserved.
#pragma once
#if COMPILE_WITH_AUDIO_TOOL
#include "AudioDecoder.h"
#include "Engine/Serialization/ReadStream.h"
///
/// Decodes .wav audio data into raw PCM format.
///
///
class WaveDecoder : public AudioDecoder
{
private:
ReadStream* mStream;
uint16 mFormat;
uint32 mDataOffset;
uint32 mBytesPerSample;
public:
///
/// Initializes a new instance of the class.
///
WaveDecoder()
{
mStream = nullptr;
mFormat = 0;
mDataOffset = 0;
mBytesPerSample = 0;
}
private:
///
/// Parses the WAVE header and output audio file meta-data. Returns false if the header is not valid.
///
/// The output information.
/// True if header is valid, otherwise false.
bool ParseHeader(AudioDataInfo& info);
public:
// [AudioDecoder]
bool Open(ReadStream* stream, AudioDataInfo& info, uint32 offset = 0) override;
void Seek(uint32 offset) override;
void Read(byte* samples, uint32 numSamples) override;
bool IsValid(ReadStream* stream, uint32 offset = 0) override;
};
#endif