soundst.h 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313
  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. #ifndef __SOUNDSTH__
  36. #define __SOUNDSTH__
  37. #define S_MAX_VOLUME 127
  38. // when to clip out sounds
  39. // Doesn't fit the large outdoor areas.
  40. #define S_CLIPPING_DIST (1200*0x10000)
  41. // when sounds should be max'd out
  42. #define S_CLOSE_DIST (200*0x10000)
  43. #define S_ATTENUATOR ((S_CLIPPING_DIST-S_CLOSE_DIST)>>FRACBITS)
  44. #define NORM_PITCH 128
  45. #define NORM_PRIORITY 64
  46. #define NORM_VOLUME snd_MaxVolume
  47. #define S_PITCH_PERTURB 1
  48. #define NORM_SEP 128
  49. #define S_STEREO_SWING (96*0x10000)
  50. // % attenuation from front to back
  51. #define S_IFRACVOL 30
  52. #define NA 0
  53. #define S_NUMCHANNELS 2
  54. //
  55. // MusicInfo struct.
  56. //
  57. typedef struct
  58. {
  59. // up to 6-character name
  60. char* name;
  61. // lump number of music
  62. int lumpnum;
  63. // music data
  64. void* data;
  65. // music handle once registered
  66. int handle;
  67. } musicinfo_t;
  68. //
  69. // SoundFX struct.
  70. //
  71. typedef struct sfxinfo_struct sfxinfo_t;
  72. struct sfxinfo_struct
  73. {
  74. // up to 6-character name
  75. char* name;
  76. // Sfx singularity (only one at a time)
  77. int singularity;
  78. // Sfx priority
  79. int priority;
  80. // referenced sound if a link
  81. sfxinfo_t* link;
  82. // pitch if a link
  83. int pitch;
  84. // volume if a link
  85. int volume;
  86. // sound data
  87. void* data;
  88. // this is checked every second to see if sound
  89. // can be thrown out (if 0, then decrement, if -1,
  90. // then throw out, if > 0, then it's in use)
  91. int usefulness;
  92. // lump number of sfx
  93. int lumpnum;
  94. };
  95. typedef struct
  96. {
  97. // sound information (if null, channel avail.)
  98. sfxinfo_t* sfxinfo;
  99. // origin of sound
  100. void* origin;
  101. // handle of the sound being played
  102. int handle;
  103. } channel_t;
  104. enum
  105. {
  106. Music,
  107. Sfx,
  108. SfxLink
  109. };
  110. enum
  111. {
  112. PC=1,
  113. Adlib=2,
  114. SB=4,
  115. Midi=8
  116. }; // cards available
  117. enum
  118. {
  119. sfxThrowOut=-1,
  120. sfxNotUsed=0
  121. };
  122. //
  123. // Initialize the sound code at start of level
  124. //
  125. void S_Start(void);
  126. //
  127. // Start sound for thing at <origin>
  128. // using <sound_id> from sounds.h
  129. //
  130. extern void
  131. S_StartSound
  132. ( void* origin,
  133. int sound_id );
  134. // Will start a sound at a given volume.
  135. extern void
  136. S_StartSoundAtVolume
  137. ( void* origin,
  138. int sound_id,
  139. int volume );
  140. // Stop sound for thing at <origin>
  141. extern void S_StopSound(void* origin);
  142. // Start music using <music_id> from sounds.h
  143. extern void S_StartMusic(int music_id);
  144. // Start music using <music_id> from sounds.h,
  145. // and set whether looping
  146. extern void
  147. S_ChangeMusic
  148. ( int music_id,
  149. int looping );
  150. // Stops the music
  151. extern void S_StopMusic(void);
  152. void S_PauseSound(void);
  153. void S_ResumeSound(void);
  154. //
  155. // Updates music & sounds
  156. //
  157. extern void S_UpdateSounds(void* listener);
  158. void S_SetMusicVolume(int volume);
  159. void S_SetSfxVolume(int volume);
  160. //
  161. // Initializes sound stuff, including volume
  162. //
  163. void
  164. S_Init
  165. ( int ,
  166. int );
  167. //
  168. // SOUND IO
  169. //
  170. #define FREQ_LOW 0x40
  171. #define FREQ_NORM 0x80
  172. #define FREQ_HIGH 0xff
  173. void I_SetMusicVolume(int volume);
  174. void I_SetSfxVolume(int volume);
  175. //
  176. // MUSIC I/O
  177. //
  178. void I_PauseSong(int handle);
  179. void I_ResumeSong(int handle);
  180. //
  181. // Called by anything that wishes to start music.
  182. // plays a song, and when the song is done,
  183. // starts playing it again in an endless loop.
  184. // Horrible thing to do, considering.
  185. void
  186. I_PlaySong
  187. ( int handle,
  188. int looping );
  189. // stops a song over 3 seconds.
  190. void I_StopSong(int handle);
  191. // registers a song handle to song data
  192. int I_RegisterSong(void *data);
  193. // see above then think backwards
  194. void I_UnRegisterSong(int handle);
  195. // is the song playing?
  196. int I_QrySongPlaying(int handle);
  197. //
  198. // SFX I/O
  199. //
  200. void I_SetChannels(int channels);
  201. int I_GetSfxLumpNum (sfxinfo_t*);
  202. // Starts a sound in a particular sound channel.
  203. int
  204. I_StartSound
  205. ( int id,
  206. void* data,
  207. int vol,
  208. int sep,
  209. int pitch,
  210. int priority );
  211. // Updates the volume, separation,
  212. // and pitch of a sound channel.
  213. void
  214. I_UpdateSoundParams
  215. ( int handle,
  216. int vol,
  217. int sep,
  218. int pitch );
  219. // Stops a sound channel.
  220. void I_StopSound(int handle);
  221. // Called by S_*()'s to see if a channel is still playing.
  222. // Returns 0 if no longer playing, 1 if playing.
  223. int I_SoundIsPlaying(int handle);
  224. // the complete set of sound effects
  225. extern sfxinfo_t S_sfx[];
  226. // the complete set of music
  227. extern musicinfo_t S_music[];
  228. #endif