wavformat.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /******************************************************************************
  2. |* THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
  3. |* ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
  4. |* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
  5. |* PARTICULAR PURPOSE.
  6. |*
  7. |* Copyright 1995-2005 Nero AG. All Rights Reserved.
  8. |*-----------------------------------------------------------------------------
  9. |* NeroSDK / AudioPluginManager
  10. |*
  11. |* FILE: wavformat.h
  12. |*
  13. |* PURPOSE: Definition of a structure holding the raw audio data formats
  14. ******************************************************************************/
  15. #ifndef _WAV_FORMAT_
  16. # define _WAV_FORMAT_
  17. #include "AudioDefs.h"
  18. struct SWavFormat
  19. {
  20. // Construction/Destruction
  21. SWavFormat() { m_iSamplesPerSecond = m_iBitsPerSample = m_iChannels = -1; };
  22. SWavFormat(int iSamplesPerSecond, int iBitsPerSample, int iChannels)
  23. : m_iSamplesPerSecond (iSamplesPerSecond),
  24. m_iBitsPerSample (iBitsPerSample),
  25. m_iChannels (iChannels)
  26. {};
  27. // Operations
  28. int GetFrameSize() const
  29. {
  30. return (m_iBitsPerSample / BITS_PER_BYTE * m_iChannels);
  31. };
  32. // Returns the amount of RAW data corresponding to this format
  33. int DataInOneSec() const
  34. {
  35. return (m_iBitsPerSample * m_iSamplesPerSecond * m_iChannels /
  36. BITS_PER_BYTE);
  37. }
  38. bool IsValid() const
  39. {
  40. return (m_iBitsPerSample > 0 &&
  41. m_iChannels > 0 &&
  42. m_iSamplesPerSecond > 0);
  43. };
  44. void operator=(const SWavFormat &rSQ)
  45. {
  46. m_iBitsPerSample = rSQ.m_iBitsPerSample;
  47. m_iChannels = rSQ.m_iChannels;
  48. m_iSamplesPerSecond = rSQ.m_iSamplesPerSecond;
  49. };
  50. bool operator==(const SWavFormat &rSQ) const
  51. {
  52. return (m_iBitsPerSample == rSQ.m_iBitsPerSample &&
  53. m_iChannels == rSQ.m_iChannels &&
  54. m_iSamplesPerSecond == rSQ.m_iSamplesPerSecond);
  55. };
  56. bool operator!=(const SWavFormat &rSQ) const
  57. {
  58. return !operator==(rSQ);
  59. };
  60. float operator/(const SWavFormat &rSQ) const
  61. {
  62. return (float)(m_iSamplesPerSecond * GetFrameSize()) /
  63. (float)(rSQ.m_iSamplesPerSecond * rSQ.GetFrameSize());
  64. };
  65. // Data
  66. int m_iSamplesPerSecond, // ... 11025 ... 22050 ... 44100 ...
  67. m_iBitsPerSample, // 8, 16, etc.
  68. m_iChannels; // Number of channels in RAW
  69. // (1 - mono, 2 - stereo, etc.)
  70. };
  71. #define CD_QUALITY SWavFormat(44100, 16, 2)
  72. #endif // _WAV_FORMAT_