BsAudioUtility.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
  2. //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
  3. #pragma once
  4. #include "BsCorePrerequisites.h"
  5. namespace BansheeEngine
  6. {
  7. /** @addtogroup Audio
  8. * @{
  9. */
  10. /** Provides various utility functionality relating to audio. */
  11. class BS_CORE_EXPORT AudioUtility
  12. {
  13. public:
  14. /**
  15. * Converts a set of audio samples using multiple channels into a set of mono samples.
  16. *
  17. * @param[in] input A set of input samples. Per-channels samples should be interleaved. Size of each sample
  18. * is determined by @p bitDepth. Total size of the buffer should be @p numSamples *
  19. * @p numChannels * @p bitDepth / 8.
  20. * @param[out] output Pre-allocated buffer to store the mono samples. Should be of @p numSamples *
  21. * @p bitDepth / 8 size.
  22. * @param[in] bitDepth Size of a single sample in bits.
  23. * @param[in] numSamples Number of samples per a single channel.
  24. * @param[in] numChannels Number of channels in the input data.
  25. */
  26. static void convertToMono(const UINT8* input, UINT8* output, UINT32 bitDepth, UINT32 numSamples, UINT32 numChannels);
  27. /**
  28. * Converts a set of audio samples of a certain bit depth to a new bit depth.
  29. *
  30. * @param[in] input A set of input samples. Total size of the buffer should be @p numSamples *
  31. * @p inBitDepth / 8.
  32. * @param[in] inBitDepth Size of a single sample in the @p input array, in bits.
  33. * @param[out] output Pre-allocated buffer to store the output samples in. Total size of the buffer should be
  34. * @p numSamples * @p outBitDepth / 8.
  35. * @param[in] outBitDepth Size of a single sample in the @p output array, in bits.
  36. * @param[in] numSamples Total number of samples to process.
  37. */
  38. static void convertBitDepth(const UINT8* input, UINT32 inBitDepth, UINT8* output, UINT32 outBitDepth, UINT32 numSamples);
  39. /**
  40. * Converts a set of audio samples of a certain bit depth to a set of floating point samples in range [-1, 1].
  41. *
  42. * @param[in] input A set of input samples. Total size of the buffer should be @p numSamples *
  43. * @p inBitDepth / 8. All input samples should be signed integers.
  44. * @param[in] inBitDepth Size of a single sample in the @p input array, in bits.
  45. * @param[out] output Pre-allocated buffer to store the output samples in. Total size of the buffer should be
  46. * @p numSamples * sizeof(float).
  47. * @param[in] numSamples Total number of samples to process.
  48. */
  49. static void convertToFloat(const UINT8* input, UINT32 inBitDepth, float* output, UINT32 numSamples);
  50. /**
  51. * Converts a 24-bit signed integer into a 32-bit signed integer.
  52. *
  53. * @param[in] input 24-bit signed integer as an array of 3 bytes.
  54. * @return 32-bit signed integer.
  55. */
  56. static INT32 convert24To32Bits(const UINT8* input);
  57. };
  58. /** @} */
  59. }