BsOAFileReader.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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. namespace BansheeEngine
  6. {
  7. /** @addtogroup OpenAudio
  8. * @{
  9. */
  10. /** Interface used for implementations that parse audio formats into a set of samples. */
  11. class OAFileReader
  12. {
  13. public:
  14. virtual ~OAFileReader() { }
  15. /**
  16. * Attempts to open audio data from the provided stream. Must be called before any reads or seeks.
  17. *
  18. * @param[in] stream Data stream audio data is stored in.
  19. * @param[out] info Output information describing meta-data of the audio in the stream.
  20. * @return True if the data is valid, false otherwise.
  21. */
  22. virtual bool open(const SPtr<DataStream>& stream, AudioFileInfo& info) = 0;
  23. /**
  24. * Moves the read pointer to the specified offset. Any further read() calls will read from this location. User must
  25. * ensure not to seek past the end of the data.
  26. *
  27. * @param[in] offset Offset to move the pointer in. In number of samples.
  28. */
  29. virtual void seek(UINT32 offset) = 0;
  30. /**
  31. * Reads a set of samples from the audio data.
  32. *
  33. * @param[out] samples Pre-allocated buffer to store the samples in.
  34. * @param[in] numSamples Number of samples to read.
  35. * @return Number of samples that were actually read (can be less than requested if the more data
  36. * in the stream).
  37. *
  38. * @note 8-bit sample data is returned as unsigned values, while higher bit-depth all use signed values.
  39. */
  40. virtual UINT32 read(UINT8* samples, UINT32 numSamples) = 0;
  41. /**
  42. * Checks if the data in the provided stream valid audio data for the current format. You should check this before
  43. * calling open().
  44. */
  45. virtual bool isValid(const SPtr<DataStream>& stream) = 0;
  46. };
  47. /** @} */
  48. }