From 04344505c0606b3c9606695033c2988bc161947d Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 22 Feb 2018 13:42:12 +0100 Subject: [PATCH] Soundfont header --- src/sound/i_soundfont.cpp | 131 +------------------------------------- src/sound/i_soundfont.h | 127 ++++++++++++++++++++++++++++++++++++ 2 files changed, 128 insertions(+), 130 deletions(-) create mode 100644 src/sound/i_soundfont.h diff --git a/src/sound/i_soundfont.cpp b/src/sound/i_soundfont.cpp index 50714e9a9..d851f1d40 100644 --- a/src/sound/i_soundfont.cpp +++ b/src/sound/i_soundfont.cpp @@ -35,138 +35,9 @@ #include #include #include - -#include "i_musicinterns.h" -#include "doomtype.h" -#include "m_argv.h" -#include "i_music.h" -#include "w_wad.h" +#include "i_soundfont.h" #include "cmdlib.h" -#include "files.h" -#include "gameconfigfile.h" -#include "resourcefiles/resourcefile.h" -#include "pathexpander.h" - -enum -{ - SF_SF2 = 1, - SF_GUS = 2 -}; - -struct FSoundFontInfo -{ - FString mName; // This is what the sounfont is identified with. It's the extension-less base file name - FString mFilename; // Full path to the backing file - this is needed by FluidSynth to load the sound font. - int type; -}; - -//========================================================================== -// -// -// -//========================================================================== - -class FSoundFontReader -{ -protected: - FWadCollection *collection; - FString mMainConfigForSF2; - int mFindInfile; - // This is only doable for loose config files that get set as sound fonts. All other cases read from a contained environment where this does not apply. - bool mAllowAbsolutePaths = false; - // This has only meaning if being run on a platform with a case sensitive file system and loose files. - // When reading from an archive it will always be case insensitive, just like the lump manager (since it repurposes the same implementation.) - bool mCaseSensitivePaths = false; - TArray mPaths; - - - FSoundFontReader() - { - collection = nullptr; - mFindInfile = -1; - } - - int pathcmp(const char *p1, const char *p2); - - -public: - - FSoundFontReader(FWadCollection *coll, const FSoundFontInfo *sfi); - virtual FileReader *OpenMainConfigFile(); // this is special because it needs to be synthesized for .sf files and set some restrictions for patch sets - virtual FileReader *OpenFile(const char *name); - std::pair LookupFile(const char *name); - void AddPath(const char *str); -}; - -//========================================================================== -// -// -// -//========================================================================== - -class FSF2Reader : FSoundFontReader -{ - FString mFilename; -public: - FSF2Reader(const char *filename); - virtual FileReader *OpenFile(const char *name) override; -}; - -//========================================================================== -// -// -// -//========================================================================== - -class FZipPatReader : FSoundFontReader -{ - FResourceFile *resf; -public: - FZipPatReader(const char *filename); - ~FZipPatReader(); - virtual FileReader *OpenFile(const char *name) override; -}; - -//========================================================================== -// -// This one gets ugly... -// -//========================================================================== - -class FPatchSetReader : FSoundFontReader -{ - FString mBasePath; - FString mFullPathToConfig; - -public: - FPatchSetReader(const char *filename); - ~FPatchSetReader(); - virtual FileReader *OpenMainConfigFile() override; - virtual FileReader *OpenFile(const char *name) override; -}; - -//========================================================================== -// -// -// -//========================================================================== - -class FSoundFontManager -{ - TArray soundfonts; - FWadCollection soundfontcollection; - - - void ProcessOneFile(const FString & fn, TArray &sffiles); - -public: - void CollectSoundfonts(); - const FSoundFontInfo *FindSoundFont(const char *name, int allowedtypes) const; - FSoundFontReader *OpenSoundFont(const char *name, int allowedtypes); - const auto &GetList() const { return soundfonts; } // This is for the menu - -}; //========================================================================== // diff --git a/src/sound/i_soundfont.h b/src/sound/i_soundfont.h new file mode 100644 index 000000000..d2eefd99d --- /dev/null +++ b/src/sound/i_soundfont.h @@ -0,0 +1,127 @@ +#pragma once + +#include "doomtype.h" +#include "w_wad.h" +#include "files.h" + +enum +{ + SF_SF2 = 1, + SF_GUS = 2 +}; + +struct FSoundFontInfo +{ + FString mName; // This is what the sounfont is identified with. It's the extension-less base file name + FString mFilename; // Full path to the backing file - this is needed by FluidSynth to load the sound font. + int type; +}; + +//========================================================================== +// +// +// +//========================================================================== + +class FSoundFontReader +{ +protected: + FWadCollection *collection; + FString mMainConfigForSF2; + int mFindInfile; + // This is only doable for loose config files that get set as sound fonts. All other cases read from a contained environment where this does not apply. + bool mAllowAbsolutePaths = false; + // This has only meaning if being run on a platform with a case sensitive file system and loose files. + // When reading from an archive it will always be case insensitive, just like the lump manager (since it repurposes the same implementation.) + bool mCaseSensitivePaths = false; + TArray mPaths; + + + FSoundFontReader() + { + collection = nullptr; + mFindInfile = -1; + } + + int pathcmp(const char *p1, const char *p2); + + +public: + + FSoundFontReader(FWadCollection *coll, const FSoundFontInfo *sfi); + virtual FileReader *OpenMainConfigFile(); // this is special because it needs to be synthesized for .sf files and set some restrictions for patch sets + virtual FileReader *OpenFile(const char *name); + std::pair LookupFile(const char *name); + void AddPath(const char *str); +}; + +//========================================================================== +// +// +// +//========================================================================== + +class FSF2Reader : FSoundFontReader +{ + FString mFilename; +public: + FSF2Reader(const char *filename); + virtual FileReader *OpenFile(const char *name) override; +}; + +//========================================================================== +// +// +// +//========================================================================== + +class FZipPatReader : FSoundFontReader +{ + FResourceFile *resf; +public: + FZipPatReader(const char *filename); + ~FZipPatReader(); + virtual FileReader *OpenFile(const char *name) override; +}; + +//========================================================================== +// +// This one gets ugly... +// +//========================================================================== + +class FPatchSetReader : FSoundFontReader +{ + FString mBasePath; + FString mFullPathToConfig; + +public: + FPatchSetReader(const char *filename); + ~FPatchSetReader(); + virtual FileReader *OpenMainConfigFile() override; + virtual FileReader *OpenFile(const char *name) override; +}; + +//========================================================================== +// +// +// +//========================================================================== + +class FSoundFontManager +{ + TArray soundfonts; + FWadCollection soundfontcollection; + + + void ProcessOneFile(const FString & fn, TArray &sffiles); + +public: + void CollectSoundfonts(); + const FSoundFontInfo *FindSoundFont(const char *name, int allowedtypes) const; + FSoundFontReader *OpenSoundFont(const char *name, int allowedtypes); + const auto &GetList() const { return soundfonts; } // This is for the menu + +}; + +