Added FMOD library support (needs work)
removed extra initializer fmod.c int to int32_t fmod support now functional Added snd_lib check in windmain fmod_ambience func for future implementation updated some funcs (CAN'T BUILD) -- static'd vars
This commit is contained in:
99
sound/fmod/fmod.c
Normal file
99
sound/fmod/fmod.c
Normal file
@@ -0,0 +1,99 @@
|
||||
/* Copyright (c) Taylor Daley, 2023. */
|
||||
/* fmod.c */
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
|
||||
#ifdef SND_LIB_FMOD
|
||||
|
||||
#include "hack.h"
|
||||
#include "fmod.h"
|
||||
|
||||
static FMOD_SYSTEM *systemvar;
|
||||
static FMOD_SOUND *soundvar;
|
||||
static FMOD_CHANNEL *channel1;
|
||||
static FMOD_CHANNEL *channelMus;
|
||||
|
||||
static void fmod_init_nhsound(void);
|
||||
static void fmod_exit_nhsound(const char *);
|
||||
static void fmod_achievement(schar, schar, int32_t);
|
||||
static void fmod_soundeffect(char *, int32_t, int32_t);
|
||||
static void fmod_hero_playnotes(int32_t, const char *, int32_t);
|
||||
static void fmod_play_usersound(const char *, int32_t, int32_t);
|
||||
static void fmod_ambience(int32_t, int32_t, int32_t);
|
||||
static void fmod_verbal(char *, int32_t, int32_t, int32_t, int32_t);
|
||||
|
||||
struct sound_procs fmod_procs = {
|
||||
SOUNDID(fmod),
|
||||
SOUND_TRIGGER_USERSOUNDS | 0,
|
||||
fmod_init_nhsound,
|
||||
fmod_exit_nhsound,
|
||||
fmod_achievement,
|
||||
fmod_soundeffect,
|
||||
fmod_hero_playnotes,
|
||||
fmod_play_usersound,
|
||||
fmod_ambience,
|
||||
fmod_verbal
|
||||
};
|
||||
|
||||
static void
|
||||
fmod_init_nhsound(void)
|
||||
{
|
||||
/* Initialize external sound library */
|
||||
FMOD_System_Create(&systemvar, FMOD_VERSION);
|
||||
FMOD_System_Init(systemvar, 32, FMOD_INIT_NORMAL, 0);
|
||||
}
|
||||
|
||||
static void
|
||||
fmod_exit_nhsound(const char *reason)
|
||||
{
|
||||
/* Close / Terminate external sound library */
|
||||
FMOD_System_Close(&systemvar);
|
||||
FMOD_System_Release(&systemvar);
|
||||
}
|
||||
|
||||
/* fulfill SNDCAP_ACHIEVEMENTS */
|
||||
static void
|
||||
fmod_achievement(schar ach1, schar ach2, int32_t repeat)
|
||||
{
|
||||
// to be added in future
|
||||
}
|
||||
|
||||
/* fulfill SNDCAP_SOUNDEFFECTS */
|
||||
static void
|
||||
fmod_soundeffect(char *desc, int32_t seid, int32_t volume)
|
||||
{
|
||||
// to be added in future
|
||||
}
|
||||
|
||||
/* fulfill SNDCAP_HEROMUSIC */
|
||||
static void fmod_hero_playnotes(int32_t instrument, char *str, int32_t volume)
|
||||
{
|
||||
// to be added in future
|
||||
}
|
||||
|
||||
/* fulfill SOUND_TRIGGER_USERSOUNDS */
|
||||
static void
|
||||
fmod_play_usersound(const char *filename, int32_t volume UNUSED, int32_t idx UNUSED)
|
||||
{
|
||||
FMOD_System_CreateSound(systemvar, filename, FMOD_CREATESAMPLE, 0,
|
||||
&soundvar);
|
||||
if (strstr(filename, "music_") != NULL) {
|
||||
FMOD_Channel_Stop(channelMus);
|
||||
FMOD_System_PlaySound(systemvar, soundvar, 0, 0, &channelMus);
|
||||
FMOD_Channel_SetMode(channelMus, FMOD_LOOP_NORMAL);
|
||||
} else {
|
||||
FMOD_Channel_Stop(channel1);
|
||||
FMOD_System_PlaySound(systemvar, soundvar, 0, 0, &channel1);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
fmod_ambience(int32_t ambienceid, int32_t ambience_action,
|
||||
int32_t hero_proximity)
|
||||
{
|
||||
// to be added in future
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endif /* SND_LIB_FMOD */
|
||||
/* end of fmod.c */
|
||||
@@ -592,8 +592,9 @@ _CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR);*/
|
||||
windowtype = gc.chosen_windowtype;
|
||||
}
|
||||
choose_windows(windowtype);
|
||||
|
||||
#if defined(SND_LIB_WINDSOUND)
|
||||
#if defined(SND_LIB_FMOD)
|
||||
assign_soundlib(soundlib_fmod);
|
||||
#elif defined(SND_LIB_WINDSOUND)
|
||||
assign_soundlib(soundlib_windsound);
|
||||
#endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user