From 542d3431ffcb2f39ccdca704436bd53550af57ee Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 22 Feb 2018 07:21:19 +0100 Subject: [PATCH] - Start of soundfont refactoring. This does not compile yet! --- src/d_main.cpp | 2 +- src/pathexpander.h | 3 ++- src/resourcefiles/resourcefile.h | 30 +++++++++++++++++++++++++ src/sound/i_music.cpp | 38 ++++++++++++++++++++++++++++++++ src/w_wad.h | 1 + 5 files changed, 72 insertions(+), 2 deletions(-) diff --git a/src/d_main.cpp b/src/d_main.cpp index d3838e5d86..0b03cf0987 100644 --- a/src/d_main.cpp +++ b/src/d_main.cpp @@ -1541,7 +1541,7 @@ void ParseCVarInfo() { GameConfig->DoModSetup (gameinfo.ConfigName); } -} +} //========================================================================== // diff --git a/src/pathexpander.h b/src/pathexpander.h index 3183349d50..8582f3c7bc 100644 --- a/src/pathexpander.h +++ b/src/pathexpander.h @@ -16,7 +16,8 @@ public: { OM_FILEORLUMP = 0, OM_LUMP, - OM_FILE + OM_FILE, + OM_ARCHIVE }; PathExpander(int om = OM_FILEORLUMP) diff --git a/src/resourcefiles/resourcefile.h b/src/resourcefiles/resourcefile.h index dbcc1dceee..4cc93cd2eb 100644 --- a/src/resourcefiles/resourcefile.h +++ b/src/resourcefiles/resourcefile.h @@ -150,7 +150,37 @@ struct FExternalLump : public FResourceLump }; +struct FMemoryFile : public FUncompressedFile +{ + MemoryArrayReader mr; + FMemoryFile(const char *_filename, const void *sdata, int length) + : FUncompressedFile(_filename, nullptr), mr((const char *)sdata, length) + { + Reader = &mr; + } + + bool Open(bool quiet) + { + FString name(ExtractFileBase(Filename)); + FString fname(ExtractFileBase(Filename, true)); + + Lumps = new FUncompressedLump[1]; // must use array allocator + uppercopy(Lumps->Name, name); + Lumps->Name[8] = 0; + Lumps->FullName = fname; + Lumps->Owner = this; + Lumps->Position = 0; + Lumps->LumpSize = Reader->GetLength(); + Lumps->Namespace = ns_global; + Lumps->Flags = 0; + Lumps->FullName = NULL; + NumLumps = 1; + return true; + } + + +}; diff --git a/src/sound/i_music.cpp b/src/sound/i_music.cpp index fce71efbe4..4bf77fa7cd 100644 --- a/src/sound/i_music.cpp +++ b/src/sound/i_music.cpp @@ -60,6 +60,7 @@ extern void ChildSigHandler (int signum); #include "m_swap.h" #include "i_cd.h" #include "templates.h" +#include "m_misc.h" #include "stats.h" #include "timidity/timidity.h" #include "vm.h" @@ -663,6 +664,43 @@ void I_SetMusicVolume (float factor) snd_musicvolume.Callback(); } +//========================================================================== +// +// +// +//========================================================================== + +void I_CollectSoundfonts() +{ + FString path = M_GetDocumentsPath(); + TArray sffiles; + const char *match; + findstate_t c_file; + void *file; + + path << "/soundfonts/*"; + + if ((file = I_FindFirst(path, &c_file)) == ((void *)(-1))) + { + return; + } + path.StripRight("*"); + do + { + if (!I_FindAttr(&c_file) & FA_DIREC) + { + FStringf name("%s%s", path.GetChars(), I_FindName(&c_file)); + sffiles.Push(name); + } + } while (I_FindNext(file, &c_file) == 0); + I_FindClose(file); + + auto soundfonts = new FWadCollection; + soundfonts->InitMultipleFiles(sffiles); + + +} + DEFINE_ACTION_FUNCTION(DObject, SetMusicVolume) { PARAM_PROLOGUE; diff --git a/src/w_wad.h b/src/w_wad.h index 6fdc62f848..ddca55ed1f 100644 --- a/src/w_wad.h +++ b/src/w_wad.h @@ -208,6 +208,7 @@ public: int GetNumWads () const; int AddExternalFile(const char *filename); + int AddData(const char *filename, int length); protected: