From 0688d53ea8aa96924d792e81d43dc2a2dc8aa46d Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 21 Feb 2018 23:38:04 +0100 Subject: [PATCH] - allow reloading the sound font for the GUS device. --- src/sound/timidity/timidity.cpp | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/sound/timidity/timidity.cpp b/src/sound/timidity/timidity.cpp index a74d6baeb..f0a6787e7 100644 --- a/src/sound/timidity/timidity.cpp +++ b/src/sound/timidity/timidity.cpp @@ -67,6 +67,8 @@ static int read_config_file(const char *name, bool ismain) if (!(fp = pathExpander.openFileReader(name, &lumpnum))) return -1; + FreeAll(); + if (ismain) { if (lumpnum > 0) @@ -516,6 +518,8 @@ void FreeAll() } } +static FString currentConfig; + int LoadConfig(const char *filename) { /* !!! FIXME: This may be ugly, but slightly less so than requiring the @@ -525,6 +529,8 @@ int LoadConfig(const char *filename) * file itself since that file should contain any other directory * that needs to be added to the search path. */ + if (currentConfig.CompareNoCase(filename) == 0) return 0; + currentConfig = filename; pathExpander.clearPathlist(); #ifdef _WIN32 pathExpander.addToPathlist("C:\\TIMIDITY"); @@ -560,6 +566,8 @@ int LoadConfig() int LoadDMXGUS() { + if (currentConfig.CompareNoCase("DMXGUS") == 0) return 0; + int lump = Wads.CheckNumForName("DMXGUS"); if (lump == -1) lump = Wads.CheckNumForName("DMXGUSC"); if (lump == -1) return LoadConfig(midi_config); @@ -567,6 +575,9 @@ int LoadDMXGUS() FWadLump data = Wads.OpenLumpNum(lump); if (data.GetLength() == 0) return LoadConfig(midi_config); + currentConfig = "DMXGUS"; + FreeAll(); + // The GUS put its patches in %ULTRADIR%/MIDI so we can try that FString ultradir = getenv("ULTRADIR"); if (ultradir.IsNotEmpty()) @@ -684,7 +695,13 @@ void FreeDLS(DLS_Data *data); Renderer::Renderer(float sample_rate, const char *args) { - // 'args' should be used to load a custom config or DMXGUS, but since setup currently requires a snd_reset call, this will need some refactoring first + // Load explicitly stated sound font if so desired. + if (args != nullptr) + { + if (!stricmp(args, "DMXGUS")) LoadDMXGUS(); + LoadConfig(args); + } + rate = sample_rate; patches = NULL; resample_buffer_size = 0;