From 8b8a7e5e4550be875b35e1b983a16a902aa41f3c Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 22 Feb 2018 14:30:43 +0100 Subject: [PATCH] - sfmanager gets initialized --- src/sound/i_music.cpp | 3 ++- src/sound/i_soundfont.cpp | 33 ++++++++++++++++++++++----------- src/sound/timidity/timidity.cpp | 1 + 3 files changed, 25 insertions(+), 12 deletions(-) diff --git a/src/sound/i_music.cpp b/src/sound/i_music.cpp index 1e57771e0..7733fdbc9 100644 --- a/src/sound/i_music.cpp +++ b/src/sound/i_music.cpp @@ -87,6 +87,7 @@ enum EMIDIType }; extern int MUSHeaderSearch(const uint8_t *head, int len); +void I_InitSoundFonts(); EXTERN_CVAR (Int, snd_samplerate) EXTERN_CVAR (Int, snd_mididevice) @@ -143,7 +144,7 @@ void I_InitMusic (void) { static bool setatterm = false; - Timidity::LoadConfig(); + I_InitSoundFonts(); snd_musicvolume.Callback (); diff --git a/src/sound/i_soundfont.cpp b/src/sound/i_soundfont.cpp index 1ab424204..c0d767bbf 100644 --- a/src/sound/i_soundfont.cpp +++ b/src/sound/i_soundfont.cpp @@ -42,6 +42,7 @@ #include "gameconfigfile.h" #include "resourcefiles/resourcefile.h" +FSoundFontManager sfmanager; //========================================================================== // @@ -327,16 +328,19 @@ void FSoundFontManager::ProcessOneFile(const FString &fn, TArray &sffil } else if (!memcmp(head, "PK", 2)) { - auto zip = FResourceFile::OpenResourceFile(fn, &fr); - if (zip != nullptr && zip->LumpCount() > 1) // Anything with just one lump cannot possibly be a packed GUS patch set so skip it right away and simplify the lookup code + auto zip = FResourceFile::OpenResourceFile(fn, nullptr); + if (zip != nullptr) { - auto zipl = zip->FindLump("timidity.cfg"); - if (zipl != nullptr) + if (zip->LumpCount() > 1) // Anything with just one lump cannot possibly be a packed GUS patch set so skip it right away and simplify the lookup code { - // It seems like this is what we are looking for - sffiles.Push(fn); - FSoundFontInfo sft = { fb, fn, SF_GUS }; - soundfonts.Push(sft); + auto zipl = zip->FindLump("timidity.cfg"); + if (zipl != nullptr) + { + // It seems like this is what we are looking for + sffiles.Push(fn); + FSoundFontInfo sft = { fb, fn, SF_GUS }; + soundfonts.Push(sft); + } } delete zip; } @@ -372,8 +376,9 @@ void FSoundFontManager::CollectSoundfonts() if (dir.IsNotEmpty()) { if (dir.Back() != '/') dir += '/'; - FString path = dir + '*'; - if ((file = I_FindFirst(path, &c_file)) != ((void *)(-1))) + FString path = dir + "soundfonts/"; + FString mask = path + '*'; + if ((file = I_FindFirst(mask, &c_file)) != ((void *)(-1))) { do { @@ -389,7 +394,8 @@ void FSoundFontManager::CollectSoundfonts() } } } - soundfontcollection.InitMultipleFiles(sffiles); + if (sffiles.Size() > 0) + soundfontcollection.InitMultipleFiles(sffiles); } //========================================================================== @@ -444,4 +450,9 @@ FSoundFontReader *FSoundFontManager::OpenSoundFont(const char *name, int allowed } +void I_InitSoundFonts() +{ + sfmanager.CollectSoundfonts(); +} + diff --git a/src/sound/timidity/timidity.cpp b/src/sound/timidity/timidity.cpp index f0a6787e7..9fc94a496 100644 --- a/src/sound/timidity/timidity.cpp +++ b/src/sound/timidity/timidity.cpp @@ -31,6 +31,7 @@ #include "i_system.h" #include "files.h" #include "w_wad.h" +#include "i_soundfont.h" // Unlike the other softsynths, this one cannot change its config data at run time. CVAR(String, midi_config, CONFIG_FILE, CVAR_ARCHIVE|CVAR_GLOBALCONFIG)