change CHDIR definition conditions
[NetHack.git] / sound / fmod / fmod.c
blob26ad2fff3b5bcfde058ef12fd5ae7dc26a787c0c
1 /* fmod.c */
2 /* Copyright (c) Taylor Daley, 2023. */
3 /* NetHack may be freely redistributed. See license for details. */
5 #ifdef SND_LIB_FMOD
7 #include "hack.h"
8 #include "fmod.h"
10 static FMOD_SYSTEM *systemvar;
11 static FMOD_SOUND *soundvar;
12 static FMOD_CHANNEL *channel1;
13 static FMOD_CHANNEL *channelMus;
15 static void fmod_init_nhsound(void);
16 static void fmod_exit_nhsound(const char *);
17 static void fmod_achievement(schar, schar, int32_t);
18 static void fmod_soundeffect(char *, int32_t, int32_t);
19 static void fmod_hero_playnotes(int32_t instrument, const char *str, int32_t volume);
20 static void fmod_play_usersound(char *, int32_t, int32_t);
21 static void fmod_ambience(int32_t, int32_t, int32_t);
22 static void fmod_verbal(char *, int32_t, int32_t, int32_t, int32_t);
24 struct sound_procs fmod_procs = {
25 SOUNDID(fmod),
26 SOUND_TRIGGER_USERSOUNDS | 0,
27 fmod_init_nhsound,
28 fmod_exit_nhsound,
29 fmod_achievement,
30 fmod_soundeffect,
31 fmod_hero_playnotes,
32 fmod_play_usersound,
33 fmod_ambience,
34 fmod_verbal
37 static void
38 fmod_init_nhsound(void)
40 /* Initialize external sound library */
41 FMOD_System_Create(&systemvar, FMOD_VERSION);
42 FMOD_System_Init(systemvar, 32, FMOD_INIT_NORMAL, 0);
45 static void
46 fmod_exit_nhsound(const char *reason)
48 /* Close / Terminate external sound library */
49 FMOD_System_Close(systemvar);
50 FMOD_System_Release(systemvar);
53 /* fulfill SNDCAP_ACHIEVEMENTS */
54 static void
55 fmod_achievement(schar ach1, schar ach2, int32_t repeat)
57 // to be added in future
60 /* fulfill SNDCAP_SOUNDEFFECTS */
61 static void
62 fmod_soundeffect(char *desc, int32_t seid, int32_t volume)
64 // to be added in future
67 /* fulfill SNDCAP_HEROMUSIC */
68 static void fmod_hero_playnotes(int32_t instrument, const char *str, int32_t volume)
70 // to be added in future
73 /* fulfill SOUND_TRIGGER_USERSOUNDS */
74 static void
75 fmod_play_usersound(char *filename, int32_t volume UNUSED, int32_t idx UNUSED)
77 FMOD_System_CreateSound(systemvar, filename, FMOD_CREATESAMPLE, 0,
78 &soundvar);
79 if (strstr(filename, "music_") != NULL) {
80 FMOD_Channel_Stop(channelMus);
81 FMOD_System_PlaySound(systemvar, soundvar, 0, 0, &channelMus);
82 FMOD_Channel_SetMode(channelMus, FMOD_LOOP_NORMAL);
83 } else {
84 FMOD_Channel_Stop(channel1);
85 FMOD_System_PlaySound(systemvar, soundvar, 0, 0, &channel1);
89 static void
90 fmod_ambience(int32_t ambienceid, int32_t ambience_action,
91 int32_t hero_proximity)
93 // to be added in future
96 static void
97 fmod_verbal(char *text, int32_t gender, int32_t tone,
98 int32_t vol, int32_t moreinfo)
100 // to be added in future
103 #endif /* SND_LIB_FMOD */
104 /* end of fmod.c */