BsWaveDecoder.h 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
  2. //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
  3. #pragma once
  4. #include "BsOAPrerequisites.h"
  5. #include "BsAudioDecoder.h"
  6. namespace bs
  7. {
  8. /** @addtogroup OpenAudio
  9. * @{
  10. */
  11. /** Decodes .WAV audio data into raw PCM format. */
  12. class WaveDecoder : public AudioDecoder
  13. {
  14. public:
  15. WaveDecoder();
  16. /** @copydoc AudioDecoder::open */
  17. bool open(const SPtr<DataStream>& stream, AudioDataInfo& info, UINT32 offset = 0) override;
  18. /** @copydoc AudioDecoder::read */
  19. UINT32 read(UINT8* samples, UINT32 numSamples) override;
  20. /** @copydoc AudioDecoder::seek */
  21. void seek(UINT32 offset) override;
  22. /** @copydoc AudioDecoder::isValid */
  23. bool isValid(const SPtr<DataStream>& stream, UINT32 offset = 0) override;
  24. private:
  25. /** Parses the WAVE header and output audio file meta-data. Returns false if the header is not valid. */
  26. bool parseHeader(AudioDataInfo& info);
  27. SPtr<DataStream> mStream;
  28. UINT32 mDataOffset;
  29. UINT32 mBytesPerSample;
  30. static const UINT32 MAIN_CHUNK_SIZE = 12;
  31. };
  32. /** @} */
  33. }