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