soundst.h (5502B)
1 // Emacs style mode select -*- C++ -*- 2 //----------------------------------------------------------------------------- 3 // 4 // $Id: soundst.h,v 1.3 1997/01/29 22:40:45 b1 Exp $ 5 // 6 // Copyright (C) 1993-1996 by id Software, Inc. 7 // 8 // This source is available for distribution and/or modification 9 // only under the terms of the DOOM Source Code License as 10 // published by id Software. All rights reserved. 11 // 12 // The source is distributed in the hope that it will be useful, 13 // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 // FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License 15 // for more details. 16 // 17 // 18 // $Log: soundst.h,v $ 19 // Revision 1.3 1997/01/29 22:40:45 b1 20 // Reformatting, S (sound) module files. 21 // 22 // Revision 1.2 1997/01/21 19:00:07 b1 23 // First formatting run: 24 // using Emacs cc-mode.el indentation for C++ now. 25 // 26 // Revision 1.1 1997/01/19 17:22:50 b1 27 // Initial check in DOOM sources as of Jan. 10th, 1997 28 // 29 // 30 // DESCRIPTION: 31 // Sound (utility) related. Hang on. 32 // See gensounds.h and gensounds.c for what soundst.h is made of. 33 // 34 //----------------------------------------------------------------------------- 35 36 #ifndef __SOUNDSTH__ 37 #define __SOUNDSTH__ 38 39 #define S_MAX_VOLUME 127 40 41 // when to clip out sounds 42 // Doesn't fit the large outdoor areas. 43 #define S_CLIPPING_DIST (1200*0x10000) 44 45 // when sounds should be max'd out 46 #define S_CLOSE_DIST (200*0x10000) 47 48 49 #define S_ATTENUATOR ((S_CLIPPING_DIST-S_CLOSE_DIST)>>FRACBITS) 50 51 #define NORM_PITCH 128 52 #define NORM_PRIORITY 64 53 #define NORM_VOLUME snd_MaxVolume 54 55 #define S_PITCH_PERTURB 1 56 #define NORM_SEP 128 57 #define S_STEREO_SWING (96*0x10000) 58 59 // % attenuation from front to back 60 #define S_IFRACVOL 30 61 62 #define NA 0 63 #define S_NUMCHANNELS 2 64 65 66 67 68 // 69 // MusicInfo struct. 70 // 71 typedef struct 72 { 73 // up to 6-character name 74 char* name; 75 76 // lump number of music 77 int lumpnum; 78 79 // music data 80 void* data; 81 82 // music handle once registered 83 int handle; 84 85 } musicinfo_t; 86 87 88 89 // 90 // SoundFX struct. 91 // 92 typedef struct sfxinfo_struct sfxinfo_t; 93 94 struct sfxinfo_struct 95 { 96 // up to 6-character name 97 char* name; 98 99 // Sfx singularity (only one at a time) 100 int singularity; 101 102 // Sfx priority 103 int priority; 104 105 // referenced sound if a link 106 sfxinfo_t* link; 107 108 // pitch if a link 109 int pitch; 110 111 // volume if a link 112 int volume; 113 114 // sound data 115 void* data; 116 117 // this is checked every second to see if sound 118 // can be thrown out (if 0, then decrement, if -1, 119 // then throw out, if > 0, then it's in use) 120 int usefulness; 121 122 // lump number of sfx 123 int lumpnum; 124 }; 125 126 127 128 typedef struct 129 { 130 // sound information (if null, channel avail.) 131 sfxinfo_t* sfxinfo; 132 133 // origin of sound 134 void* origin; 135 136 // handle of the sound being played 137 int handle; 138 139 } channel_t; 140 141 142 143 enum 144 { 145 Music, 146 Sfx, 147 SfxLink 148 }; 149 150 enum 151 { 152 PC=1, 153 Adlib=2, 154 SB=4, 155 Midi=8 156 }; // cards available 157 158 enum 159 { 160 sfxThrowOut=-1, 161 sfxNotUsed=0 162 }; 163 164 165 // 166 // Initialize the sound code at start of level 167 // 168 void S_Start(void); 169 170 // 171 // Start sound for thing at <origin> 172 // using <sound_id> from sounds.h 173 // 174 extern void 175 S_StartSound 176 ( void* origin, 177 int sound_id ); 178 179 180 181 // Will start a sound at a given volume. 182 extern void 183 S_StartSoundAtVolume 184 ( void* origin, 185 int sound_id, 186 int volume ); 187 188 189 // Stop sound for thing at <origin> 190 extern void S_StopSound(void* origin); 191 192 // Start music using <music_id> from sounds.h 193 extern void S_StartMusic(int music_id); 194 195 // Start music using <music_id> from sounds.h, 196 // and set whether looping 197 extern void 198 S_ChangeMusic 199 ( int music_id, 200 int looping ); 201 202 203 // Stops the music 204 extern void S_StopMusic(void); 205 206 void S_PauseSound(void); 207 void S_ResumeSound(void); 208 209 210 // 211 // Updates music & sounds 212 // 213 extern void S_UpdateSounds(void* listener); 214 215 void S_SetMusicVolume(int volume); 216 void S_SetSfxVolume(int volume); 217 218 // 219 // Initializes sound stuff, including volume 220 // 221 void 222 S_Init 223 ( int , 224 int ); 225 226 227 228 // 229 // SOUND IO 230 // 231 #define FREQ_LOW 0x40 232 #define FREQ_NORM 0x80 233 #define FREQ_HIGH 0xff 234 235 236 void I_SetMusicVolume(int volume); 237 void I_SetSfxVolume(int volume); 238 239 // 240 // MUSIC I/O 241 // 242 void I_PauseSong(int handle); 243 void I_ResumeSong(int handle); 244 245 // 246 // Called by anything that wishes to start music. 247 // plays a song, and when the song is done, 248 // starts playing it again in an endless loop. 249 // Horrible thing to do, considering. 250 void 251 I_PlaySong 252 ( int handle, 253 int looping ); 254 255 256 // stops a song over 3 seconds. 257 void I_StopSong(int handle); 258 259 // registers a song handle to song data 260 int I_RegisterSong(void *data); 261 262 // see above then think backwards 263 void I_UnRegisterSong(int handle); 264 265 // is the song playing? 266 int I_QrySongPlaying(int handle); 267 268 269 // 270 // SFX I/O 271 // 272 void I_SetChannels(int channels); 273 274 int I_GetSfxLumpNum (sfxinfo_t*); 275 276 277 // Starts a sound in a particular sound channel. 278 int 279 I_StartSound 280 ( int id, 281 void* data, 282 int vol, 283 int sep, 284 int pitch, 285 int priority ); 286 287 288 // Updates the volume, separation, 289 // and pitch of a sound channel. 290 void 291 I_UpdateSoundParams 292 ( int handle, 293 int vol, 294 int sep, 295 int pitch ); 296 297 298 // Stops a sound channel. 299 void I_StopSound(int handle); 300 301 // Called by S_*()'s to see if a channel is still playing. 302 // Returns 0 if no longer playing, 1 if playing. 303 int I_SoundIsPlaying(int handle); 304 305 306 // the complete set of sound effects 307 extern sfxinfo_t S_sfx[]; 308 309 // the complete set of music 310 extern musicinfo_t S_music[]; 311 312 #endif