Source:NetHack 5.0.0/include/sndprocs.h
Jump to navigation
Jump to search
Below is the full text to sndprocs.h from the source code of NetHack 5.0.0. To link to a particular line, write [[Source:NetHack 5.0.0/include/sndprocs.h#line12]], for example.
The NetHack General Public License applies to screenshots, source code and other content from NetHack.
This content was modified from the original NetHack source code distribution (by splitting up NetHack content between wiki pages, and possibly further editing). See the page history for a list of who changed it, and on what dates.
1. /* NetHack 5.0 sndprocs.h $NHDT-Date: 1725653015 2024/09/06 20:03:35 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.26 $ */ 2. /* Copyright (c) Michael Allison, 2022 */ 3. /* NetHack may be freely redistributed. See license for details. */ 4. 5. #ifndef SNDPROCS_H 6. #define SNDPROCS_H 7. 8. enum soundlib_ids { 9. soundlib_nosound, 10. #ifdef SND_LIB_PORTAUDIO 11. soundlib_portaudio, 12. #endif 13. #ifdef SND_LIB_OPENAL 14. soundlib_openal, 15. #endif 16. #ifdef SND_LIB_SDL_MIXER 17. soundlib_sdl_mixer, 18. #endif 19. #ifdef SND_LIB_MINIAUDIO 20. soundlib_miniaudio, 21. #endif 22. #ifdef SND_LIB_FMOD 23. soundlib_fmod, 24. #endif 25. #ifdef SND_LIB_SOUND_ESCCODES 26. soundlib_sound_esccodes, 27. #endif 28. #ifdef SND_LIB_VISSOUND 29. soundlib_vissound, 30. #endif 31. #ifdef SND_LIB_WINDSOUND 32. soundlib_windsound, 33. #endif 34. #ifdef SND_LIB_MACSOUND 35. soundlib_macsound, 36. #endif 37. #ifdef SND_LIB_QTSOUND 38. soundlib_qtsound, 39. #endif 40. soundlib_notused 41. }; 42. 43. struct sound_procs { 44. const char *soundname; 45. enum soundlib_ids soundlib_id; 46. unsigned long sound_triggers; /* capabilities in the port */ 47. void (*sound_init_nhsound)(void); 48. void (*sound_exit_nhsound)(const char *); 49. void (*sound_achievement)(schar, schar, int32_t); 50. void (*sound_soundeffect)(char *desc, int32_t, int32_t volume); 51. void (*sound_hero_playnotes)(int32_t instrument, const char *str, 52. int32_t volume); 53. void (*sound_play_usersound)(char *filename, int32_t volume, int32_t idx); 54. void (*sound_ambience)(int32_t ambience_action, int32_t ambienceid, 55. int32_t proximity); 56. void (*sound_verbal)(char *text, int32_t gender, int32_t tone, 57. int32_t vol, int32_t moreinfo); 58. }; 59. 60. struct sound_voice { 61. int32_t serialno; 62. int32_t gender; 63. int32_t tone; 64. int32_t volume; 65. int32_t moreinfo; 66. struct monst *mon; 67. const char *nameid; 68. }; 69. 70. extern struct sound_procs sndprocs; 71. 72. #define SOUNDID(soundname) \ 73. #soundname, ((enum soundlib_ids) soundlib_##soundname) 74. 75. /* 76. * Types of triggers 77. */ 78. #define SOUND_TRIGGER_USERSOUNDS 0x0001L 79. #define SOUND_TRIGGER_HEROMUSIC 0x0002L 80. #define SOUND_TRIGGER_ACHIEVEMENTS 0x0004L 81. #define SOUND_TRIGGER_SOUNDEFFECTS 0x0008L 82. #define SOUND_TRIGGER_AMBIENCE 0x0010L 83. #define SOUND_TRIGGER_VERBAL 0x0020L 84. /* 26 free bits */ 85. 86. extern struct sound_procs soundprocs; 87. 88. /* subset for NetHack */ 89. enum instruments { 90. ins_cello = 43, ins_orchestral_harp = 47, ins_choir_aahs = 53, 91. ins_trumpet = 57, ins_trombone = 58, ins_french_horn = 61, 92. ins_baritone_sax = 68, ins_english_horn = 70, ins_piccolo = 73, 93. ins_flute = 74, ins_pan_flute = 76, ins_blown_bottle = 77, 94. ins_whistle = 79, ins_tinkle_bell = 113, ins_woodblock = 116, 95. ins_taiko_drum = 117, ins_melodic_tom = 118, ins_seashore = 123, 96. ins_no_instrument 97. }; 98. 99. #if 0 100. enum instruments_broad { 101. ins_acoustic_grand_piano = 1, ins_bright_acoustic_piano = 2, 102. ins_electric_grand_piano = 3, ins_honkytonk_piano = 4, 103. ins_electric_piano_1 = 5, ins_electric_piano_2 = 6, 104. ins_harpsichord = 7, ins_clavinet = 8, ins_celesta = 9, 105. ins_glockenspiel = 10, ins_music_box = 11, ins_vibraphone = 12, 106. ins_marimba = 13, ins_xylophone = 14, ins_tubular_bells = 15, 107. ins_dulcimer = 16, ins_drawbar_organ = 17, 108. ins_percussive_organ = 18, ins_rock_organ = 19, ins_church_organ = 20, 109. ins_reed_organ = 21, ins_french_accordion = 22, ins_harmonica = 23, 110. ins_tango_accordion = 24, ins_acoustic_guitar__nylon = 25, 111. ins_acoustic_guitar_steel = 26, ins_electric_guitar_jazz = 27, 112. ins_electric_guitar_clean = 28, ins_electric_guitar_muted = 29, 113. ins_overdriven_guitar = 30, ins_distortion_guitar = 31, 114. ins_guitar_harmonics = 32, ins_acoustic_bass = 33, 115. ins_electric_bass__fingered = 34, ins_electric_bass_picked = 35, 116. ins_fretless_bass = 36, ins_slap_bass_1 = 37, ins_slap_bass_2 = 38, 117. ins_synth_bass_1 = 39, ins_synth_bass_2 = 40, ins_violin = 41, 118. ins_viola = 42, ins_cello = 43, ins_contrabass = 44, 119. ins_tremolo_strings = 45, ins_pizzicato_strings = 46, 120. ins_orchestral_harp = 47, ins_timpani = 48, 121. ins_string_ensemble_1 = 49, ins_string_ensemble_2 = 50, 122. ins_synthstrings_1 = 51, ins_synthstrings_2 = 52, ins_choir_aahs = 53, 123. ins_voice_oohs = 54, ins_synth_voice = 55, ins_orchestra_hit = 56, 124. ins_trumpet = 57, ins_trombone = 58, ins_tuba = 59, ins_muted_trumpet = 60, 125. ins_french_horn = 61, ins_brass_section = 62, ins_synthbrass_1 = 63, 126. ins_synthbrass_2 = 64, ins_soprano_sax = 65, ins_alto_sax = 66, 127. ins_tenor_sax = 67, ins_baritone_sax = 68, ins_oboe = 69, 128. ins_english_horn = 70, ins_bassoon = 71, ins_clarinet = 72, 129. ins_piccolo = 73, ins_flute = 74, ins_recorder = 75, 130. ins_pan_flute = 76, ins_blown_bottle = 77, ins_shakuhachi = 78, 131. ins_whistle = 79, ins_ocarina = 80, ins_sitar = 105, ins_banjo = 106, 132. ins_shamisen = 107, ins_koto = 108, ins_kalimba = 109, ins_bag_pipe = 110, 133. ins_fiddle = 111, ins_shanai = 112, ins_tinkle_bell = 113, ins_agogo = 114, 134. ins_steel_drums = 115, ins_woodblock = 116, ins_taiko_drum = 117, 135. ins_melodic_tom = 118, ins_synth_drum = 119, ins_reverse_cymbal = 120, 136. ins_guitar_fret_noise = 121, ins_breath_noise = 122, ins_seashore = 123, 137. ins_bird_tweet = 124, ins_telephone_ring = 125, ins_helicopter = 126, 138. ins_applause = 127, ins_gunshot = 128, 139. ins_no_instrument 140. }; 141. #endif 142. 143. #define SEFFECTS_ENUM 144. enum sound_effect_entries { 145. se_zero_invalid = 0, 146. #include "seffects.h" 147. number_of_se_entries 148. }; 149. #undef SEFFECTS_ENUM 150. 151. enum ambience_actions { 152. ambience_nothing, ambience_begin, ambience_end, ambience_update 153. }; 154. 155. enum ambiences { 156. amb_noambience, 157. }; 158. 159. enum voice_moreinfo { 160. voice_nothing_special, 161. voice_audioassistant = 0x0001, /* accessibility */ 162. voice_talking_artifact = 0x0002, 163. voice_deity = 0x0004, 164. voice_oracle = 0x0008, 165. voice_throne = 0x0010, 166. voice_death = 0x0020 167. }; 168. 169. enum achievements_arg2 { 170. sa2_zero_invalid, sa2_splashscreen, sa2_newgame_nosplash, sa2_restoregame, 171. sa2_xplevelup, sa2_xpleveldown, number_of_sa2_entries 172. }; 173. 174. /* 175. Arguments for sound_achievement(schar arg1, schar arg2, int32_t aflags) 176. 177. Arguments for actual achievements, those in you.h, 178. arg1 = the achievement value. 179. arg2 = 0 (irrelevant). 180. aflags = 0 for first time, 1 for repeat. 181. 182. These next ones make use of arg2, and aflags may be 183. filled with additional int values dependent on arg2. 184. arg1 must always be 0 for these. 185. 186. SoundAchievement(0, sa2_splashscreen, 0); 187. SoundAchievement(0, sa2_newgame_nosplash, 0); 188. SoundAchievement(0, sa2_restoregame, 0); 189. SoundAchievement(0, sa2_levelup, level); 190. SoundAchievement(0, sa2_xpleveldown, level); 191. */ 192. 193. #if defined(SND_LIB_QTSOUND) || defined(SND_LIB_PORTAUDIO) \ 194. || defined(SND_LIB_OPENAL) || defined(SND_LIB_SDL_MIXER) \ 195. || defined(SND_LIB_MINIAUDIO) || defined(SND_LIB_FMOD) \ 196. || defined(SND_LIB_SOUND_ESCCODES) || defined(SND_LIB_VISSOUND) \ 197. || defined(SND_LIB_WINDSOUND) || defined(SND_LIB_MACSOUND) 198. 199. /* shortcut for conditional code in other files */ 200. #define SND_LIB_INTEGRATED 201. 202. #define Play_usersound(filename, vol, idx) \ 203. do { \ 204. if (iflags.sounds && !Deaf && soundprocs.sound_play_usersound \ 205. && ((soundprocs.sound_triggers & SOUND_TRIGGER_USERSOUNDS) != 0)) \ 206. (*soundprocs.sound_play_usersound)((filename), (vol), (idx)); \ 207. } while(0) 208. 209. #define Soundeffect(seid, vol) \ 210. do { \ 211. if (iflags.sounds && !Deaf && soundprocs.sound_soundeffect \ 212. && ((soundprocs.sound_triggers & SOUND_TRIGGER_SOUNDEFFECTS) != 0)) \ 213. (*soundprocs.sound_soundeffect)(emptystr, (seid), (vol)); \ 214. } while(0) 215. 216. /* Player's perspective, not the hero's; no Deaf suppression */ 217. #define SoundeffectEvenIfDeaf(seid, vol) \ 218. do { \ 219. if (iflags.sounds && !soundprocs.sound_soundeffect \ 220. && ((soundprocs.sound_triggers & SOUND_TRIGGER_SOUNDEFFECTS) != 0)) \ 221. (*soundprocs.sound_soundeffect)(emptystr, (seid), (vol)); \ 222. } while(0) 223. 224. #define Hero_playnotes(instrument, str, vol) \ 225. do { \ 226. if (iflags.sounds && !Deaf && soundprocs.sound_hero_playnotes \ 227. && ((soundprocs.sound_triggers & SOUND_TRIGGER_HEROMUSIC) != 0)) \ 228. (*soundprocs.sound_hero_playnotes)((instrument), (str), (vol)); \ 229. } while(0) 230. 231. /* Player's perspective, not the hero's; no Deaf suppression */ 232. #define SoundAchievement(arg1, arg2, avals) \ 233. do { \ 234. if (iflags.sounds && soundprocs.sound_achievement \ 235. && ((soundprocs.sound_triggers & SOUND_TRIGGER_ACHIEVEMENTS) != 0)) \ 236. (*soundprocs.sound_achievement)((arg1), (arg2), (avals)); \ 237. } while(0) 238. 239. /* sound_speak is in sound.c */ 240. #define SoundSpeak(text) \ 241. do { \ 242. if ((gp.pline_flags & (PLINE_VERBALIZE | PLINE_SPEECH)) != 0 \ 243. && soundprocs.sound_verbal && iflags.voices \ 244. && ((soundprocs.sound_triggers & SOUND_TRIGGER_VERBAL) != 0)) \ 245. sound_speak(text); \ 246. } while(0) 247. 248. /* set_voice is in sound.c */ 249. #define SetVoice(mon, tone, vol, moreinfo) \ 250. do { \ 251. set_voice(mon, tone, vol, moreinfo); \ 252. } while(0) 253. 254. /* void (*sound_achievement)(schar, schar, int32_t); */ 255. 256. #ifdef SOUNDLIBONLY 257. #undef SOUNDLIBONLY 258. #endif 259. #define SOUNDLIBONLY 260. #ifdef SND_SPEECH 261. #define VOICEONLY 262. #else 263. #define VOICEONLY UNUSED 264. #endif 265. 266. #else /* NO SOUNDLIB IS INTEGRATED AFTER THIS */ 267. 268. #ifdef SND_LIB_INTEGRATED 269. #undef SND_LIB_INTEGRATED 270. #endif 271. #define Play_usersound(filename, vol, idx) 272. #define Soundeffect(seid, vol) 273. #define Hero_playnotes(instrument, str, vol) 274. #define SoundAchievement(arg1, arg2, avals) 275. #define SoundSpeak(text) 276. #define SetVoice(mon, tone, vol, moreinfo) 277. #ifdef SOUNDLIBONLY 278. #undef SOUNDLIBONLY 279. #endif 280. #define SOUNDLIBONLY UNUSED 281. #ifdef SND_SPEECH 282. #undef SND_SPEECH 283. #endif 284. #ifdef VOICEONLY 285. #undef VOICEONLY 286. #endif 287. #define VOICEONLY UNUSED 288. 289. #endif /* No SOUNDLIB */ 290. 291. enum findsound_approaches { 292. findsound_embedded, 293. findsound_soundfile 294. }; 295. 296. enum sound_file_flags { 297. sff_default, /* add dir prefix + '/' + sound + suffix */ 298. sff_base_only, /* base sound name only, no dir, no suffix */ 299. sff_havedir_append_rest, /* dir provided, append base sound name+suffix */ 300. sff_baseknown_add_rest /* base is already known, add dir and suffix */ 301. }; 302. 303. #endif /* SNDPROCS_H */