AUDIO.H 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. //
  2. // Copyright 2020 Electronic Arts Inc.
  3. //
  4. // TiberianDawn.DLL and RedAlert.dll and corresponding source code is free
  5. // software: you can redistribute it and/or modify it under the terms of
  6. // the GNU General Public License as published by the Free Software Foundation,
  7. // either version 3 of the License, or (at your option) any later version.
  8. // TiberianDawn.DLL and RedAlert.dll and corresponding source code is distributed
  9. // in the hope that it will be useful, but with permitted additional restrictions
  10. // under Section 7 of the GPL. See the GNU General Public License in LICENSE.TXT
  11. // distributed with this program. You should have received a copy of the
  12. // GNU General Public License along with permitted additional restrictions
  13. // with this program. If not, see https://github.com/electronicarts/CnC_Remastered_Collection
  14. /* $Header: F:\projects\c&c0\vcs\code\audio.h_v 4.43 05 Jul 1996 17:58:10 JOE_BOSTIC $ */
  15. /***********************************************************************************************
  16. *** 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 ***
  17. ***********************************************************************************************
  18. * *
  19. * Project Name : Command & Conquer *
  20. * *
  21. * File Name : AUDIO.H *
  22. * *
  23. * Programmer : Joe L. Bostic *
  24. * *
  25. * Start Date : June 21, 1994 *
  26. * *
  27. * Last Update : June 21, 1994 [JLB] *
  28. * *
  29. *---------------------------------------------------------------------------------------------*
  30. * Functions: *
  31. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  32. #ifndef AUDIO_H
  33. #define AUDIO_H
  34. #include "memory.h"
  35. class AudioClass {
  36. char const * Name; // Name of audio asset.
  37. void const * Data; // Loaded audio data.
  38. int Handle; // Handle of asset (as it is playing).
  39. MemoryClass *Mem; // Pointer to memory handler class.
  40. unsigned IsMIDI:1; // Is this a midi file?
  41. public:
  42. AudioClass(void);
  43. AudioClass(char const *name, MemoryClass &mem);
  44. virtual ~AudioClass(void);
  45. bool Load(char const *name = 0);
  46. bool Free(void);
  47. bool Play(int volume = 0xFF);
  48. bool Stop(void);
  49. bool Pause(void);
  50. bool Resume(void);
  51. bool Set_Name(char const *name);
  52. bool Is_Playing(void) const;
  53. bool Is_Loaded(void) const;
  54. bool Is_MIDI(void) const;
  55. };
  56. inline AudioClass::AudioClass(void)
  57. {
  58. Name = 0;
  59. Data = 0;
  60. Mem = 0;
  61. Handle = -1;
  62. };
  63. inline AudioClass::AudioClass(char const *name, MemoryClass &mem)
  64. {
  65. if (mem) {
  66. Mem = &mem;
  67. } else {
  68. Mem = &::Mem; // Uses global default memory handler.
  69. }
  70. Name = strdup(name);
  71. Data = 0;
  72. Handle = -1;
  73. };
  74. inline AudioClass::~AudioClass(void)
  75. {
  76. if (GameActive) {
  77. if (Name) free(Name);
  78. if (Data) Mem->Free(Data);
  79. Name = 0;
  80. Data = 0;
  81. Handle = -1;
  82. }
  83. };
  84. #endif