CnC_Remastered_Collection

Command and Conquer: Red Alert
Log | Files | Refs | README | LICENSE

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 /*=========================================================================*/
     60 /*	There can be a different sound driver for sound effects, digitized		*/
     61 /*	samples, and musical scores.  Each one must be of these specified			*/
     62 /*	types.																						*/
     63 /*=========================================================================*/
     64 typedef enum {
     65 	SAMPLE_NONE,		// No digitized sounds will be played.
     66 	SAMPLE_SB,			// Sound Blaster digitized driver.
     67 	SAMPLE_SBPRO,		// Sound Blaster Pro digitized driver.
     68 	SAMPLE_PAS,			// Pro-Audio Spectrum digitized driver.
     69 	SAMPLE_ADLIBG,		// Adlib-Gold digitized driver.
     70 	SAMPLE_TANDY,		// Tandy 'compatible' driver.
     71 	SAMPLE_PCSPKR,		// PC speaker digitized driver (The Audio Solution driver).
     72 	SAMPLE_ADLIB,		// Adlib digitized driver (The Audio Solution driver).
     73 	SAMPLE_TEMP=0x1000,
     74 	SAMPLE_LAST
     75 } Sample_Type;
     76 
     77 typedef enum {
     78 	SCORE_NONE,			// No scores will be played.
     79 	SCORE_ALFX,			// Westwood's ALFX adlib compatable driver.
     80 	SCORE_WWPCSPKR,	// Westwood's PC-speaker driver (obsolete).
     81 	SCORE_WWTANDY,		// Westwood's PC-speaker driver with Tandy mod (obsolete).
     82 	SCORE_PCSPKR,		// PC speaker XMIDI driver.
     83 	SCORE_TANDY,		// Tandy XMIDI driver.
     84 	SCORE_MT32,			// MT-32 / LAPC-1 Roland XMIDI driver.
     85 	SCORE_CANVAS,		// Sound Canvas SC-55.
     86 	SCORE_ADLIB,		// Adlib XMIDI driver.
     87 	SCORE_ADLIBG,		// Adlib Gold XMIDI driver.
     88 	SCORE_PASFM,		// Pro Audio Spectrum XMIDI driver.
     89 	SCORE_SBFM,			// Sound Blaster XMIDI driver.
     90 	SCORE_SBP1FM,		// Sound Blaster Pro (YM3812) XMIDI driver.
     91 	SCORE_SBP2FM,		// Sound Blaster Pro (OPL3) XMIDI driver (Can't use with SFX_ALFX).
     92 	SCORE_TEMP=0x1000,
     93 	SCORE_LAST
     94 } Score_Type;
     95 
     96 typedef enum {
     97 	SFX_NONE,			// No sound effects will be played.
     98 	SFX_ALFX,			// Westwood's ALFX adlib compatable driver.
     99 	SFX_WWPCSPKR,		// Westwood's PC-speaker driver.
    100 	SFX_WWTANDY,		// Westwood's PC-speaker driver with Tandy mod.
    101 	SFX_PCSPKR,			// PC speaker XMIDI driver.
    102 	SFX_TANDY,			// Tandy XMIDI driver.
    103 	SFX_MT32,			// MT-32 / LAPC-1 Roland XMIDI driver.
    104 	SFX_CANVAS,			// Sound Canvas SC-55.
    105 	SFX_ADLIB,			// Adlib XMIDI driver.
    106 	SFX_ADLIBG,			// Adlib Gold XMIDI driver.
    107 	SFX_PASFM,			// Pro Audio Spectrum XMIDI driver.
    108 	SFX_SBFM,			// Sound Blaster XMIDI driver.
    109 	SFX_SBP1FM,			// Sound Blaster Pro (YM3812) XMIDI driver.
    110 	SFX_SBP2FM,			// Sound Blaster Pro (OPL3) XMIDI driver.
    111 	SFX_TEMP=0x1000,
    112 	SFX_LAST
    113 } SFX_Type;
    114 
    115 
    116 
    117 /*=========================================================================*/
    118 /* The following prototypes are for the file: SOUNDIO.CPP						*/
    119 /*=========================================================================*/
    120 int File_Stream_Sample(char const *filename, BOOL real_time_start = FALSE);
    121 int File_Stream_Sample_Vol(char const *filename, int volume, BOOL real_time_start = FALSE);
    122 void __cdecl Sound_Callback(void);
    123 void __cdecl far maintenance_callback(void);
    124 void *Load_Sample(char const *filename);
    125 long Load_Sample_Into_Buffer(char const *filename, void *buffer, long size);
    126 long Sample_Read(int fh, void *buffer, long size);
    127 void Free_Sample(void const *sample);
    128 BOOL Audio_Init( HWND window , int bits_per_sample, BOOL stereo , int rate , int reverse_channels);
    129 void Sound_End(void);
    130 void Stop_Sample(int handle);
    131 BOOL Sample_Status(int handle);
    132 BOOL Is_Sample_Playing(void const * sample);
    133 void Stop_Sample_Playing(void const * sample);
    134 int Play_Sample(void const *sample, int priority=0xFF, int volume=0xFF, signed short panloc = 0x0);
    135 int Play_Sample_Handle(void const *sample, int priority, int volume, signed short panloc, int id);
    136 int Set_Sound_Vol(int volume);
    137 int Set_Score_Vol(int volume);
    138 void Fade_Sample(int handle, int ticks);
    139 int Get_Free_Sample_Handle(int priority);
    140 int Get_Digi_Handle(void);
    141 long Sample_Length(void const *sample);
    142 void Restore_Sound_Buffers (void);
    143 BOOL Set_Primary_Buffer_Format(void);
    144 BOOL Start_Primary_Sound_Buffer (BOOL forced);
    145 void Stop_Primary_Sound_Buffer (void);
    146 
    147 /*
    148 ** Function to call if we detect focus loss
    149 */
    150 extern	void (*Audio_Focus_Loss_Function)(void);
    151 
    152 
    153 extern int Misc;
    154 extern SFX_Type SoundType;
    155 extern Sample_Type SampleType;
    156 
    157 extern CRITICAL_SECTION	GlobalAudioCriticalSection;
    158 
    159 extern int StreamLowImpact;