BsOAWaveReader.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 "BsOAFileReader.h"
  6. namespace BansheeEngine
  7. {
  8. /** @addtogroup OpenAudio
  9. * @{
  10. */
  11. /** Used for reading .WAV audio files. */
  12. class OAWaveReader : public OAFileReader
  13. {
  14. public:
  15. OAWaveReader();
  16. /** @copydoc OAFileReader::open */
  17. bool open(const SPtr<DataStream>& stream, AudioFileInfo& info) override;
  18. /** @copydoc OAFileReader::read */
  19. UINT32 read(UINT8* samples, UINT32 numSamples) override;
  20. /** @copydoc OAFileReader::seek */
  21. void seek(UINT32 offset) override;
  22. /** @copydoc OAFileReader::isValid */
  23. bool isValid(const SPtr<DataStream>& stream) 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(AudioFileInfo& info);
  27. SPtr<DataStream> mStream;
  28. UINT32 mDataOffset;
  29. UINT32 mBytesPerSample;
  30. static const UINT32 MAIN_CHUNK_SIZE = 12;
  31. };
  32. /** @} */
  33. }