1 /* Patrick 5/6/97 ------------------------------------------------------------- 2 AvP platform specific sound management header: 3 Support for sample and CDDA sounds. 4 ----------------------------------------------------------------------------*/ 5 #ifndef PSNDPLAT_H 6 #define PSNDPLAT_H 7 8 #ifdef __cplusplus 9 extern "C" { 10 #endif 11 12 #include "psndproj.h" 13 #include "psnd.h" 14 15 /* Patrick 10/6/97 ------------------------------------------------------------- 16 SAMPLE SUPPORT 17 ----------------------------------------------------------------------------*/ 18 19 /* Patrick 5/6/97 ------------------------------------------------------------- 20 Data structure for a loaded sound. The first four fields must be included 21 for all platforms. 22 ----------------------------------------------------------------------------*/ 23 typedef struct soundsampledata 24 { 25 int loaded; 26 int activeInstances; 27 int volume; 28 int pitch; 29 30 // LPDIRECTSOUNDBUFFER dsBufferP; 31 int dsBufferP; 32 void *buffer; 33 34 unsigned int flags; 35 int dsFrequency; 36 char * wavName; 37 int length; //time in fixed point seconds 38 39 }SOUNDSAMPLEDATA; 40 41 /* Defines for the flags. */ 42 #define SAMPLE_IN_HW 0x00000001 43 #define SAMPLE_IN_SW 0x00000002 44 #define SAMPLE_IN_3D 0x00000004 45 46 /* Patrick 5/6/97 ------------------------------------------------------------- 47 Data structure for a playing (active) sound. The first eight fields must be 48 included for all platforms. 49 ----------------------------------------------------------------------------*/ 50 typedef struct activesoundsample 51 { 52 SOUNDINDEX soundIndex; 53 ACTIVESOUNDPRIORITY priority; 54 int volume; 55 int pitch; 56 int *externalRef; 57 unsigned int loop :1; 58 unsigned int threedee :1; 59 unsigned int paused :1; 60 unsigned int marine_ignore :1; 61 unsigned int reverb_off :1; 62 SOUND3DDATA threedeedata; 63 64 // LPDIRECTSOUNDBUFFER dsBufferP; 65 // LPDIRECTSOUND3DBUFFER ds3DBufferP; 66 // LPKSPROPERTYSET PropSetP; 67 int dsBufferP; 68 int ds3DBufferP; 69 float PropSetP_pos[3]; 70 float PropSetP_vel[3]; 71 72 void *buffer; 73 void *buffer3d; 74 void *propset; 75 }ACTIVESOUNDSAMPLE; 76 77 /* Patrick 5/6/97 ------------------------------------------------------------- 78 Data structures for WAV headers and chuncks 79 ----------------------------------------------------------------------------*/ 80 typedef struct pwavchunkheader 81 { 82 char chunkName[4]; 83 int chunkLength; 84 } PWAVCHUNKHEADER; 85 86 typedef struct pwavriffheader 87 { 88 char type[4]; 89 } PWAVRIFFHEADER; 90 91 void InitialiseBaseFrequency(SOUNDINDEX soundNum); 92 int LoadWavFile(int soundNum, char *); 93 int LoadWavFromFastFile(int soundNum, char *); 94 95 /* Patrick 5/6/97 ------------------------------------------------------------- 96 Start and EndSoundSys: does any platform operations required to initialise 97 and exit the sound system 98 ----------------------------------------------------------------------------*/ 99 extern int PlatStartSoundSys(void); 100 extern void PlatEndSoundSys(void); 101 /* Patrick 5/6/97 ------------------------------------------------------------- 102 Sets the global volume, and returns true (1) if successful, or false (0) 103 otherwise. 104 ----------------------------------------------------------------------------*/ 105 extern int PlatChangeGlobalVolume(int volume); 106 /* Patrick 5/6/97 ------------------------------------------------------------- 107 Play a sound: does platform operations required to create and play a new 108 sound from the active sound data for the given sound. This function must 109 also perform any neccessary operations that may be required to initilaise 110 a sounds volume, pitch, or 3d attributes. 111 PlatStartSoundSys returns true (1) if successful, or false (0) otherwise. 112 ----------------------------------------------------------------------------*/ 113 extern int PlatPlaySound(int activeIndex); 114 /* Patrick 5/6/97 ------------------------------------------------------------- 115 Stop a sound: Any platform operations required for stopping a sound. returns 116 true (1) if successful, or SOUND_PLATFORMERROR (-1) otherwise. 117 ----------------------------------------------------------------------------*/ 118 extern void PlatStopSound(int activeIndex); 119 /* Patrick 5/6/97 ------------------------------------------------------------- 120 The following perform the required platform operations for changing volume, 121 and pitch for a playing sound. All return true (1) if successful, or 122 SOUND_PLATFORMERROR (-1) otherwise. 123 ----------------------------------------------------------------------------*/ 124 extern int PlatChangeSoundVolume(int activeIndex, int volume); 125 extern int PlatChangeSoundPitch(int activeIndex, int pitch); 126 /* Patrick 5/6/97 ------------------------------------------------------------- 127 The following function performs the neccessary operations required for a 3d 128 sound (eg volume, pan). Return true (1) if successful, or SOUND_PLATFORMERROR 129 (-1) otherwise. 130 ----------------------------------------------------------------------------*/ 131 extern int PlatDo3dSound(int activeIndex); 132 /* Patrick 5/6/97 ------------------------------------------------------------- 133 Return true (1) if the sound has stopped, false (0) if it is still playing 134 or SOUND_PLATFORMERROR (-1) otherwise. 135 ----------------------------------------------------------------------------*/ 136 extern int PlatSoundHasStopped(int activeIndex); 137 /* Patrick 5/6/97 ------------------------------------------------------------- 138 Performs any platform specific operations required to unload a game sound, 139 wile the sound system is exiting 140 ----------------------------------------------------------------------------*/ 141 extern void PlatEndGameSound(SOUNDINDEX index); 142 143 /* Davew 23/7/98 -------------------------------------------------------------- 144 Update the player in the 3D sound system. 145 ----------------------------------------------------------------------------*/ 146 extern void PlatUpdatePlayer(); 147 148 /* Davew 27/7/98 --------------------------------------------------------------- 149 This sets the enviroment for the Listener. The first parameter is the index 150 of the enviroment, the second is the reverb ratio to apply to sound (0 - 1) 151 float. Negative means let the card deal with reverb. 152 ---------------------------------------------------------------------------*/ 153 extern void PlatSetEnviroment(unsigned int env_index, float reverb_mix); 154 extern unsigned int PlatMaxHWSounds(); 155 156 /* Davew 11/11/98 -------------------------------------------------------------- 157 Controls the use of 3DHW, by default it is used if present. Return codes 158 2 means it was already in that state, 1 means to changed state sucessfully 159 -1 means it failed to change state. Note these functions may well be slow. 160 ---------------------------------------------------------------------------*/ 161 extern int PlatUse3DSoundHW(); 162 extern int PlatDontUse3DSoundHW(); 163 164 /* Patrick 5/6/97 ------------------------------------------------------------- 165 Defines for max number of sounds, and instances of sounds, allowed; 166 also maximum and minimum volume, pitch, and pan values for platform. 167 ----------------------------------------------------------------------------*/ 168 #define SOUND_MAXACTIVE (120) 169 #define SOUND_MAXACTIVE_SW (20) 170 #define SOUND_MAXINSTANCES (20) 171 #define SOUND_MAXSIZE (250000) /* biggest sample we will allow to be loaded */ 172 173 #define SOUND_DEACTIVATERANGE (10000 * GlobalScale) 174 175 #define VOLUME_MAXPLAT (0) /* attenuation values, in db's */ 176 #define VOLUME_MINPLAT (-10000) 177 #define VOLUME_PLAT2DSCALE (96) /* in 128ths of the original volume */ 178 179 /* frequency values are those accepted by ds. Pitch is measured in semi-tones, 180 and is applied relative to the loaded frequency of the sound */ 181 #define FREQUENCY_MAXPLAT (100000) 182 #define FREQUENCY_MINPLAT (100) 183 #define PITCH_MAXPLAT (6144) 184 #define PITCH_MINPLAT (-6144) 185 #define PITCH_DEFAULTPLAT (0) 186 187 #define PAN_MAXPLAT (1200) 188 #define PAN_MINPLAT (-1200) 189 #define PAN_3DDAMPDISTANCE (1000) 190 191 /* NB ds supports pan +- 10000: */ 192 193 /* Patrick 5/6/97 ------------------------------------------------------------- 194 Defines for 3D attenuation: 195 Volume attenuation is per metre, in global volume units, as defined by 196 VOLUME_MAX and VOLUME_MIN in psnd.h 197 Pan attenuation is per 180/2048 degrees, in platform units as defined above 198 by PAN_MAXPLAT and PAN_MINPLAT (ie panattenuation*(1024)<=PAN_MAXPLAT), 199 assuming symetrical range. 200 ----------------------------------------------------------------------------*/ 201 #define VOLUME_3DATTENUATION (4) 202 203 /* Patrick 5/6/97 ------------------------------------------------------------- 204 Global references to sound management data areas, and blank instances of data 205 structures storted in those areas 206 ----------------------------------------------------------------------------*/ 207 extern SOUNDSAMPLEDATA GameSounds[]; 208 extern ACTIVESOUNDSAMPLE ActiveSounds[]; 209 extern SOUNDSAMPLEDATA BlankGameSound; 210 extern ACTIVESOUNDSAMPLE BlankActiveSound; 211 212 void UpdateSoundFrequencies(void); 213 214 #ifdef __cplusplus 215 } 216 #endif 217 218 #endif 219