SoundBuffer.h 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. /*
  2. ** Command & Conquer Renegade(tm)
  3. ** Copyright 2025 Electronic Arts Inc.
  4. **
  5. ** This program is free software: you can redistribute it and/or modify
  6. ** it under the terms of the GNU General Public License as published by
  7. ** the Free Software Foundation, either version 3 of the License, or
  8. ** (at your option) any later version.
  9. **
  10. ** This program is distributed in the hope that it will be useful,
  11. ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. ** GNU General Public License for more details.
  14. **
  15. ** You should have received a copy of the GNU General Public License
  16. ** along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. /***********************************************************************************************
  19. *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S ***
  20. ***********************************************************************************************
  21. * *
  22. * Project Name : WWAudio *
  23. * *
  24. * $Archive:: /Commando/Code/WWAudio/SoundBuffer.h $*
  25. * *
  26. * Author:: Patrick Smith *
  27. * *
  28. * $Modtime:: 8/17/01 11:12a $*
  29. * *
  30. * $Revision:: 7 $*
  31. * *
  32. *---------------------------------------------------------------------------------------------*
  33. * Functions: *
  34. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  35. #if defined(_MSC_VER)
  36. #pragma once
  37. #endif
  38. #ifndef __SOUNDBUFFER_H
  39. #define __SOUNDBUFFER_H
  40. #pragma warning (push, 3)
  41. #include "Mss.H"
  42. #pragma warning (pop)
  43. #include "RefCount.H"
  44. // Forward declarations
  45. class FileClass;
  46. /////////////////////////////////////////////////////////////////////////////////
  47. //
  48. // SoundBufferClass
  49. //
  50. // A sound buffer manages the raw sound data for any of the SoundObj types
  51. // except for the StreamSoundClass object.
  52. //
  53. class SoundBufferClass : public RefCountClass
  54. {
  55. public:
  56. //////////////////////////////////////////////////////////////////////
  57. // Public constructors/destructors
  58. //////////////////////////////////////////////////////////////////////
  59. SoundBufferClass (void);
  60. virtual ~SoundBufferClass (void);
  61. //////////////////////////////////////////////////////////////////////
  62. // Public operators
  63. //////////////////////////////////////////////////////////////////////
  64. operator unsigned char * (void) { return Get_Raw_Buffer (); }
  65. //////////////////////////////////////////////////////////////////////
  66. // File methods
  67. //////////////////////////////////////////////////////////////////////
  68. virtual bool Load_From_File (const char *filename);
  69. virtual bool Load_From_File (FileClass &file);
  70. //////////////////////////////////////////////////////////////////////
  71. // Memory methods
  72. //////////////////////////////////////////////////////////////////////
  73. virtual bool Load_From_Memory (unsigned char *mem_buffer, unsigned long size);
  74. //////////////////////////////////////////////////////////////////////
  75. // Buffer access
  76. //////////////////////////////////////////////////////////////////////
  77. virtual unsigned char * Get_Raw_Buffer (void) const { return m_Buffer; }
  78. virtual unsigned long Get_Raw_Length (void) const { return m_Length; }
  79. //////////////////////////////////////////////////////////////////////
  80. // Information methods
  81. //////////////////////////////////////////////////////////////////////
  82. virtual const char * Get_Filename (void) const { return m_Filename; }
  83. virtual void Set_Filename (const char *name);
  84. virtual unsigned long Get_Duration (void) const { return m_Duration; }
  85. virtual unsigned long Get_Rate (void) const { return m_Rate; }
  86. virtual unsigned long Get_Bits (void) const { return m_Bits; }
  87. virtual unsigned long Get_Channels (void) const { return m_Channels; }
  88. virtual unsigned long Get_Type (void) const { return m_Type; }
  89. //////////////////////////////////////////////////////////////////////
  90. // Type methods
  91. //////////////////////////////////////////////////////////////////////
  92. virtual bool Is_Streaming (void) const { return false; }
  93. protected:
  94. //////////////////////////////////////////////////////////////////////
  95. // Protected methods
  96. //////////////////////////////////////////////////////////////////////
  97. virtual void Free_Buffer (void);
  98. virtual void Determine_Stats (unsigned char *buffer);
  99. //////////////////////////////////////////////////////////////////////
  100. // Protected member data
  101. //////////////////////////////////////////////////////////////////////
  102. unsigned char * m_Buffer;
  103. unsigned long m_Length;
  104. char * m_Filename;
  105. unsigned long m_Duration;
  106. unsigned long m_Rate;
  107. unsigned long m_Bits;
  108. unsigned long m_Channels;
  109. unsigned long m_Type;
  110. };
  111. /////////////////////////////////////////////////////////////////////////////////
  112. //
  113. // StreamSoundBufferClass
  114. //
  115. // A sound buffer manages the raw sound data for any of the SoundObj types
  116. // except for the StreamSoundClass object.
  117. //
  118. class StreamSoundBufferClass : public SoundBufferClass
  119. {
  120. public:
  121. //////////////////////////////////////////////////////////////////////
  122. // Public constructors/destructors
  123. //////////////////////////////////////////////////////////////////////
  124. StreamSoundBufferClass (void);
  125. virtual ~StreamSoundBufferClass (void);
  126. //////////////////////////////////////////////////////////////////////
  127. // File methods
  128. //////////////////////////////////////////////////////////////////////
  129. virtual bool Load_From_File (const char *filename);
  130. virtual bool Load_From_File (FileClass &file);
  131. //////////////////////////////////////////////////////////////////////
  132. // Memory methods
  133. //////////////////////////////////////////////////////////////////////
  134. virtual bool Load_From_Memory (unsigned char *mem_buffer, unsigned long size) { return false; }
  135. //////////////////////////////////////////////////////////////////////
  136. // Type methods
  137. //////////////////////////////////////////////////////////////////////
  138. virtual bool Is_Streaming (void) const { return true; }
  139. protected:
  140. //////////////////////////////////////////////////////////////////////
  141. // Protected methods
  142. //////////////////////////////////////////////////////////////////////
  143. virtual void Free_Buffer (void);
  144. virtual bool Load_From_File (HANDLE hfile, unsigned long size, unsigned long offset);
  145. //////////////////////////////////////////////////////////////////////
  146. // Protected member data
  147. //////////////////////////////////////////////////////////////////////
  148. };
  149. #endif //__SOUNDBUFFER_H