PageRenderTime 42ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 0ms

/Modules/Audio/inc/TCAudioSoundFormat.h

https://bitbucket.org/the____tiger/tcsystem
C Header | 138 lines | 74 code | 16 blank | 48 comment | 7 complexity | e38da24d43e76fdfba67be79b16a1ac3 MD5 | raw file
Possible License(s): LGPL-2.1
  1. //*******************************************************************************
  2. //
  3. // ******* *** *** *
  4. // * * * *
  5. // * * * *****
  6. // * * *** * * ** * ** ***
  7. // * * * * * * * **** * * *
  8. // * * * * * * * * * * *
  9. // * *** *** * ** ** ** * *
  10. // *
  11. //*******************************************************************************
  12. // see http://sourceforge.net/projects/tcsystem/ for details.
  13. // Copyright (C) 2003 - 2012 Thomas Goessler. All Rights Reserved.
  14. //*******************************************************************************
  15. //
  16. // TCSystem is the legal property of its developers.
  17. // Please refer to the COPYRIGHT file distributed with this source distribution.
  18. //
  19. // This library is free software; you can redistribute it and/or
  20. // modify it under the terms of the GNU Lesser General Public
  21. // License as published by the Free Software Foundation; either
  22. // version 2.1 of the License, or (at your option) any later version.
  23. //
  24. // This library is distributed in the hope that it will be useful,
  25. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  26. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  27. // Lesser General Public License for more details.
  28. //
  29. // You should have received a copy of the GNU Lesser General Public
  30. // License along with this library; if not, write to the Free Software
  31. // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
  32. //*******************************************************************************
  33. // $Id: TCAudioSoundFormat.h,v 89939db0b777 2012/09/24 21:17:18 thomas $
  34. //*******************************************************************************
  35. #ifndef _TC_AUDIO_SOUND_FORMAT_H_
  36. #define _TC_AUDIO_SOUND_FORMAT_H_
  37. #include "TCSharedPtr.h"
  38. namespace tc
  39. {
  40. namespace audio
  41. {
  42. /**
  43. * @addtogroup TC_AUDIO
  44. * @{
  45. */
  46. /**
  47. * @file
  48. * @brief This file provides the definition of tc::audio::SoundFormat
  49. *
  50. * @author Thomas Goessler
  51. */
  52. /** class holding audio format information */
  53. class SoundFormat
  54. {
  55. public:
  56. SoundFormat()
  57. :m_num_channels(0),
  58. m_samples_per_second(0),
  59. m_bits_per_sample(0)
  60. {
  61. }
  62. bool operator==(const SoundFormat& other) const
  63. {
  64. return (
  65. (m_num_channels == other.m_num_channels)
  66. && (m_samples_per_second == other.m_samples_per_second)
  67. && (m_bits_per_sample == other.m_bits_per_sample)
  68. );
  69. }
  70. bool operator!=(const SoundFormat& other) const
  71. {
  72. return (!this->operator==(other));
  73. }
  74. bool IsValid()
  75. {
  76. return ( m_num_channels
  77. && m_samples_per_second
  78. && m_bits_per_sample);
  79. }
  80. void SetNumChannels(uint16_t num_channels)
  81. {
  82. m_num_channels = num_channels;
  83. }
  84. uint16_t GetNumChannels() const
  85. {
  86. return m_num_channels;
  87. }
  88. void SetSamplesPerSecond(uint32_t samples_per_second)
  89. {
  90. m_samples_per_second = samples_per_second;
  91. }
  92. uint32_t GetSamplesPerSecond() const
  93. {
  94. return m_samples_per_second;
  95. }
  96. uint32_t GetBytesPerSecond() const
  97. {
  98. return (m_samples_per_second * m_num_channels * m_bits_per_sample / 8);
  99. }
  100. uint16_t GetBytesPerSample() const
  101. {
  102. return (m_num_channels * m_bits_per_sample / 8);
  103. }
  104. void SetBitsPerSample(uint16_t bits_per_sample)
  105. {
  106. m_bits_per_sample = bits_per_sample;
  107. }
  108. uint16_t GetBitsPerSample() const
  109. {
  110. return m_bits_per_sample;
  111. }
  112. private:
  113. uint16_t m_num_channels; ///< Number of channels, can be any number
  114. uint32_t m_samples_per_second; ///< Samples per second (Hertz)
  115. uint16_t m_bits_per_sample; ///< 8, 16 or 24
  116. }; // end of class SoundFormat
  117. /**
  118. * @}
  119. */
  120. }
  121. }
  122. #endif // _TC_AUDIO_SOUND_FORMAT_H_