SoundData.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. /* Copyright (c) 2002-2012 Croteam Ltd.
  2. This program is free software; you can redistribute it and/or modify
  3. it under the terms of version 2 of the GNU General Public License as published by
  4. the Free Software Foundation
  5. This program is distributed in the hope that it will be useful,
  6. but WITHOUT ANY WARRANTY; without even the implied warranty of
  7. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  8. GNU General Public License for more details.
  9. You should have received a copy of the GNU General Public License along
  10. with this program; if not, write to the Free Software Foundation, Inc.,
  11. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */
  12. #ifndef SE_INCL_SOUNDDATA_H
  13. #define SE_INCL_SOUNDDATA_H
  14. #ifdef PRAGMA_ONCE
  15. #pragma once
  16. #endif
  17. #include <Engine/Base/Lists.h>
  18. #include <Engine/Base/Serial.h>
  19. #define SDF_ENCODED (1UL<<0) // this is ogg or mpx compressed file
  20. #define SDF_STREAMING (1UL<<1) // streaming from disk
  21. class ENGINE_API CSoundData : public CSerial {
  22. public:
  23. // Sound Mode Aware class (notify class when sound mode change)
  24. CListNode sd_Node; // for linking in list
  25. ULONG sd_ulFlags; // flags
  26. //private:
  27. public:
  28. // Call-back called when sound mode changes.
  29. void ModeChanged(void);
  30. inline BOOL IsHooked(void) const { return sd_Node.IsLinked(); };
  31. CListHead sd_ClhLinkList; // list of objects linked to data
  32. void PausePlayingObjects(void);
  33. void ResumePlayingObjects(void);
  34. // Sound Buffer
  35. WAVEFORMATEX sd_wfeFormat; // primary sound buffer format
  36. SWORD *sd_pswBuffer; // pointer on buffer
  37. SLONG sd_slBufferSampleSize; // buffer sample size
  38. double sd_dSecondsLength; // sound length in seconds
  39. // free Buffer (and all linked Objects)
  40. void ClearBuffer(void);
  41. // Add object in sound aware list
  42. void AddObjectLink(CSoundObject &CsoAdd);
  43. // Remove an object from aware list
  44. void RemoveObjectLink(CSoundObject &CsoRemove);
  45. // reference counting functions
  46. void AddReference(void);
  47. void RemReference(void);
  48. public:
  49. // Constructor
  50. CSoundData();
  51. // Destructor
  52. ~CSoundData();
  53. // get sound length in seconds
  54. double GetSecondsLength(void);
  55. // read sound from file and convert it to the current sound format
  56. void Read_t(CTStream *inFile); // throw char *
  57. // write sound to file (not implemented)
  58. void Write_t(CTStream *outFile); // throw char *
  59. /* Get the description of this object. */
  60. CTString GetDescription(void);
  61. // free allocated memory for sound and Sound in DXBuffer
  62. void Clear(void);
  63. // check if this kind of objects is auto-freed
  64. virtual BOOL IsAutoFreed(void);
  65. // get amount of memory used by this object
  66. SLONG GetUsedMemory(void);
  67. };
  68. #endif /* include-once check. */