From e193170ae03a5b4eaf07a7a12f7a502e8c9b2abd Mon Sep 17 00:00:00 2001 From: erysdren Date: Wed, 24 Jul 2024 13:31:01 -0500 Subject: [PATCH] Use Mix_GetSoundFonts(); (#78) * Use Mix_GetSoundFonts(); * Write soundfonts to sound.rot * set boolean here * Don't save soundfonts to CFG, and have sane fallback --- rott/dukemusc.c | 17 +++++++++++++++++ rott/rt_cfg.c | 2 -- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/rott/dukemusc.c b/rott/dukemusc.c index 655efc0..3bc514d 100644 --- a/rott/dukemusc.c +++ b/rott/dukemusc.c @@ -150,6 +150,9 @@ static unsigned char *music_songdata = NULL; static Mix_Music *music_musicchunk = NULL; static size_t music_songdatasize = 0; +static char MUSIC_SoundFonts[2048]; +static const char soundfonts_fallback[] = "/usr/share/soundfonts/default.sf2;/usr/share/sounds/sf2/default-GM.sf2;/usr/share/sounds/sf2/FluidR3_GM.sf2"; + int MUSIC_Init(int SoundCard, int Address) { init_debugging(); @@ -169,6 +172,20 @@ int MUSIC_Init(int SoundCard, int Address) return(MUSIC_Error); } // if + // add soundfonts + const char *soundfonts = Mix_GetSoundFonts(); + if (soundfonts) + { + M_snprintf(MUSIC_SoundFonts, sizeof(MUSIC_SoundFonts), "%s", soundfonts); + } + else + { + M_snprintf(MUSIC_SoundFonts, sizeof(MUSIC_SoundFonts), "%s", soundfonts_fallback); + } + + printf("Using soundfonts path string \"%s\"\n", MUSIC_SoundFonts); + Mix_SetSoundFonts(MUSIC_SoundFonts); + music_initialized = 1; return(MUSIC_Ok); } // MUSIC_Init diff --git a/rott/rt_cfg.c b/rott/rt_cfg.c index 571d00d..10913b6 100644 --- a/rott/rt_cfg.c +++ b/rott/rt_cfg.c @@ -252,8 +252,6 @@ boolean ParseSoundFile (void) return (retval); } - - //****************************************************************************** // // SetSoundDefaultValues ()