AUDIO.H 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. /*
  2. ** Command & Conquer Red Alert(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 : Westwood 32 bit Library *
  23. * *
  24. * File Name : AUDIO.H *
  25. * *
  26. * Programmer : Phil W. Gorrow *
  27. * *
  28. * Start Date : March 10, 1995 *
  29. * *
  30. * Last Update : March 10, 1995 [PWG] *
  31. * *
  32. *-------------------------------------------------------------------------*
  33. * Functions: *
  34. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  35. #include "wwstd.h"
  36. /*=========================================================================*/
  37. /* AUD file header type */
  38. /*=========================================================================*/
  39. #define AUD_FLAG_STEREO 1
  40. #define AUD_FLAG_16BIT 2
  41. // PWG 3-14-95: This structure used to have bit fields defined for Stereo
  42. // and Bits. These were removed because watcom packs them into a 32 bit
  43. // flag entry even though they could have fit in a 8 bit entry.
  44. #pragma pack(1);
  45. typedef struct {
  46. unsigned short int Rate; // Playback rate (hertz).
  47. long Size; // Size of data (bytes).
  48. long UncompSize; // Size of data (bytes).
  49. unsigned char Flags; // Holds flags for info
  50. // 1: Is the sample stereo?
  51. // 2: Is the sample 16 bits?
  52. unsigned char Compression; // What kind of compression for this sample?
  53. } AUDHeaderType;
  54. /*=========================================================================*/
  55. /* There can be a different sound driver for sound effects, digitized */
  56. /* samples, and musical scores. Each one must be of these specified */
  57. /* types. */
  58. /*=========================================================================*/
  59. typedef enum {
  60. SAMPLE_NONE, // No digitized sounds will be played.
  61. SAMPLE_SB, // Sound Blaster digitized driver.
  62. SAMPLE_SBPRO, // Sound Blaster Pro digitized driver.
  63. SAMPLE_PAS, // Pro-Audio Spectrum digitized driver.
  64. SAMPLE_ADLIBG, // Adlib-Gold digitized driver.
  65. SAMPLE_TANDY, // Tandy 'compatible' driver.
  66. SAMPLE_PCSPKR, // PC speaker digitized driver (The Audio Solution driver).
  67. SAMPLE_ADLIB, // Adlib digitized driver (The Audio Solution driver).
  68. SAMPLE_TEMP=0x1000,
  69. SAMPLE_LAST
  70. } Sample_Type;
  71. typedef enum {
  72. SCORE_NONE, // No scores will be played.
  73. SCORE_ALFX, // Westwood's ALFX adlib compatable driver.
  74. SCORE_WWPCSPKR, // Westwood's PC-speaker driver (obsolete).
  75. SCORE_WWTANDY, // Westwood's PC-speaker driver with Tandy mod (obsolete).
  76. SCORE_PCSPKR, // PC speaker XMIDI driver.
  77. SCORE_TANDY, // Tandy XMIDI driver.
  78. SCORE_MT32, // MT-32 / LAPC-1 Roland XMIDI driver.
  79. SCORE_CANVAS, // Sound Canvas SC-55.
  80. SCORE_ADLIB, // Adlib XMIDI driver.
  81. SCORE_ADLIBG, // Adlib Gold XMIDI driver.
  82. SCORE_PASFM, // Pro Audio Spectrum XMIDI driver.
  83. SCORE_SBFM, // Sound Blaster XMIDI driver.
  84. SCORE_SBP1FM, // Sound Blaster Pro (YM3812) XMIDI driver.
  85. SCORE_SBP2FM, // Sound Blaster Pro (OPL3) XMIDI driver (Can't use with SFX_ALFX).
  86. SCORE_TEMP=0x1000,
  87. SCORE_LAST
  88. } Score_Type;
  89. typedef enum {
  90. SFX_NONE, // No sound effects will be played.
  91. SFX_ALFX, // Westwood's ALFX adlib compatable driver.
  92. SFX_WWPCSPKR, // Westwood's PC-speaker driver.
  93. SFX_WWTANDY, // Westwood's PC-speaker driver with Tandy mod.
  94. SFX_PCSPKR, // PC speaker XMIDI driver.
  95. SFX_TANDY, // Tandy XMIDI driver.
  96. SFX_MT32, // MT-32 / LAPC-1 Roland XMIDI driver.
  97. SFX_CANVAS, // Sound Canvas SC-55.
  98. SFX_ADLIB, // Adlib XMIDI driver.
  99. SFX_ADLIBG, // Adlib Gold XMIDI driver.
  100. SFX_PASFM, // Pro Audio Spectrum XMIDI driver.
  101. SFX_SBFM, // Sound Blaster XMIDI driver.
  102. SFX_SBP1FM, // Sound Blaster Pro (YM3812) XMIDI driver.
  103. SFX_SBP2FM, // Sound Blaster Pro (OPL3) XMIDI driver.
  104. SFX_TEMP=0x1000,
  105. SFX_LAST
  106. } SFX_Type;
  107. /*=========================================================================*/
  108. /* The following prototypes are for the file: SOUNDIO.CPP */
  109. /*=========================================================================*/
  110. int File_Stream_Sample(char const *filename, BOOL real_time_start = FALSE);
  111. int File_Stream_Sample_Vol(char const *filename, int volume, BOOL real_time_start = FALSE);
  112. void __cdecl Sound_Callback(void);
  113. void __cdecl far maintenance_callback(void);
  114. void *Load_Sample(char const *filename);
  115. long Load_Sample_Into_Buffer(char const *filename, void *buffer, long size);
  116. long Sample_Read(int fh, void *buffer, long size);
  117. void Free_Sample(void const *sample);
  118. BOOL Audio_Init( HWND window , int bits_per_sample, BOOL stereo , int rate , int reverse_channels);
  119. void Sound_End(void);
  120. void Stop_Sample(int handle);
  121. BOOL Sample_Status(int handle);
  122. BOOL Is_Sample_Playing(void const * sample);
  123. void Stop_Sample_Playing(void const * sample);
  124. int Play_Sample(void const *sample, int priority=0xFF, int volume=0xFF, signed short panloc = 0x0);
  125. int Play_Sample_Handle(void const *sample, int priority, int volume, signed short panloc, int id);
  126. int Set_Sound_Vol(int volume);
  127. int Set_Score_Vol(int volume);
  128. void Fade_Sample(int handle, int ticks);
  129. int Get_Free_Sample_Handle(int priority);
  130. int Get_Digi_Handle(void);
  131. long Sample_Length(void const *sample);
  132. void Restore_Sound_Buffers (void);
  133. BOOL Set_Primary_Buffer_Format(void);
  134. BOOL Start_Primary_Sound_Buffer (BOOL forced);
  135. void Stop_Primary_Sound_Buffer (void);
  136. /*
  137. ** Function to call if we detect focus loss
  138. */
  139. extern void (*Audio_Focus_Loss_Function)(void);
  140. extern int Misc;
  141. extern SFX_Type SoundType;
  142. extern Sample_Type SampleType;
  143. extern CRITICAL_SECTION GlobalAudioCriticalSection;
  144. extern int StreamLowImpact;