- sfmanager gets initialized

This commit is contained in:
Christoph Oelckers 2018-02-22 14:30:43 +01:00
parent aaedae6972
commit 8b8a7e5e45
3 changed files with 25 additions and 12 deletions

View file

@ -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 ();

View file

@ -42,6 +42,7 @@
#include "gameconfigfile.h"
#include "resourcefiles/resourcefile.h"
FSoundFontManager sfmanager;
//==========================================================================
//
@ -327,8 +328,10 @@ void FSoundFontManager::ProcessOneFile(const FString &fn, TArray<FString> &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)
{
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
{
auto zipl = zip->FindLump("timidity.cfg");
if (zipl != nullptr)
@ -338,6 +341,7 @@ void FSoundFontManager::ProcessOneFile(const FString &fn, TArray<FString> &sffil
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,6 +394,7 @@ void FSoundFontManager::CollectSoundfonts()
}
}
}
if (sffiles.Size() > 0)
soundfontcollection.InitMultipleFiles(sffiles);
}
@ -444,4 +450,9 @@ FSoundFontReader *FSoundFontManager::OpenSoundFont(const char *name, int allowed
}
void I_InitSoundFonts()
{
sfmanager.CollectSoundfonts();
}

View file

@ -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)