AUDIO.H 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. /*
  2. ** Command & Conquer(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. /* $Header: F:\projects\c&c\vcs\code\audio.h_v 2.18 16 Oct 1995 16:45:34 JOE_BOSTIC $ */
  19. /***********************************************************************************************
  20. *** 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 ***
  21. ***********************************************************************************************
  22. * *
  23. * Project Name : Command & Conquer *
  24. * *
  25. * File Name : AUDIO.H *
  26. * *
  27. * Programmer : Joe L. Bostic *
  28. * *
  29. * Start Date : June 21, 1994 *
  30. * *
  31. * Last Update : June 21, 1994 [JLB] *
  32. * *
  33. *---------------------------------------------------------------------------------------------*
  34. * Functions: *
  35. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  36. #ifndef AUDIO_H
  37. #define AUDIO_H
  38. #include "memory.h"
  39. class AudioClass {
  40. char const * Name; // Name of audio asset.
  41. void const * Data; // Loaded audio data.
  42. int Handle; // Handle of asset (as it is playing).
  43. MemoryClass *Mem; // Pointer to memory handler class.
  44. unsigned IsMIDI:1; // Is this a midi file?
  45. public:
  46. AudioClass(void);
  47. AudioClass(char const *name, MemoryClass &mem);
  48. virtual ~AudioClass(void);
  49. bool Load(char const *name = 0);
  50. bool Free(void);
  51. bool Play(int volume = 0xFF);
  52. bool Stop(void);
  53. bool Pause(void);
  54. bool Resume(void);
  55. bool Set_Name(char const *name);
  56. bool Is_Playing(void) const;
  57. bool Is_Loaded(void) const;
  58. bool Is_MIDI(void) const;
  59. };
  60. inline AudioClass::AudioClass(void)
  61. {
  62. Name = 0;
  63. Data = 0;
  64. Mem = 0;
  65. Handle = -1;
  66. };
  67. inline AudioClass::AudioClass(char const *name, MemoryClass &mem)
  68. {
  69. if (mem) {
  70. Mem = &mem;
  71. } else {
  72. Mem = &::Mem; // Uses global default memory handler.
  73. }
  74. Name = strdup(name);
  75. Data = 0;
  76. Handle = -1;
  77. };
  78. inline AudioClass::~AudioClass(void)
  79. {
  80. if (GameActive) {
  81. if (Name) free(Name);
  82. if (Data) Mem->Free(Data);
  83. Name = 0;
  84. Data = 0;
  85. Handle = -1;
  86. }
  87. };
  88. #endif