- 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,16 +328,19 @@ 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)
{
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();
}

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)