| 1 | //************************************ bs::framework - Copyright 2018 Marko Pintera **************************************// |
| 2 | //*********** Licensed under the MIT license. See LICENSE.md for full terms. This notice is not to be removed. ***********// |
| 3 | #pragma once |
| 4 | |
| 5 | #include "BsOAPrerequisites.h" |
| 6 | #include "BsAudioDecoder.h" |
| 7 | |
| 8 | namespace bs |
| 9 | { |
| 10 | /** @addtogroup OpenAudio |
| 11 | * @{ |
| 12 | */ |
| 13 | |
| 14 | /** Decodes .WAV audio data into raw PCM format. */ |
| 15 | class WaveDecoder : public AudioDecoder |
| 16 | { |
| 17 | public: |
| 18 | WaveDecoder() = default; |
| 19 | |
| 20 | /** @copydoc AudioDecoder::open */ |
| 21 | bool open(const SPtr<DataStream>& stream, AudioDataInfo& info, UINT32 offset = 0) override; |
| 22 | |
| 23 | /** @copydoc AudioDecoder::read */ |
| 24 | UINT32 read(UINT8* samples, UINT32 numSamples) override; |
| 25 | |
| 26 | /** @copydoc AudioDecoder::seek */ |
| 27 | void seek(UINT32 offset) override; |
| 28 | |
| 29 | /** @copydoc AudioDecoder::isValid */ |
| 30 | bool isValid(const SPtr<DataStream>& stream, UINT32 offset = 0) override; |
| 31 | private: |
| 32 | /** Parses the WAVE header and output audio file meta-data. Returns false if the header is not valid. */ |
| 33 | bool (AudioDataInfo& info); |
| 34 | |
| 35 | SPtr<DataStream> mStream; |
| 36 | UINT32 mDataOffset = 0; |
| 37 | UINT32 mBytesPerSample = 0; |
| 38 | |
| 39 | static const UINT32 MAIN_CHUNK_SIZE = 12; |
| 40 | }; |
| 41 | |
| 42 | /** @} */ |
| 43 | } |