From: <sag...@us...> - 2014-12-06 19:15:54
|
Revision: 4636 http://sourceforge.net/p/modplug/code/4636 Author: saga-games Date: 2014-12-06 19:15:40 +0000 (Sat, 06 Dec 2014) Log Message: ----------- [Imp] Allow soundfonts to be previewed in the sample browser and to be loaded as instruments. Useful for browsing through single-instrument banks. Modified Paths: -------------- trunk/OpenMPT/mptrack/Ctrl_ins.cpp trunk/OpenMPT/mptrack/View_tre.cpp trunk/OpenMPT/soundlib/Dlsbank.cpp trunk/OpenMPT/soundlib/Dlsbank.h trunk/OpenMPT/soundlib/SampleFormats.cpp Modified: trunk/OpenMPT/mptrack/Ctrl_ins.cpp =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_ins.cpp 2014-12-06 18:56:49 UTC (rev 4635) +++ trunk/OpenMPT/mptrack/Ctrl_ins.cpp 2014-12-06 19:15:40 UTC (rev 4636) @@ -1698,10 +1698,12 @@ .AllowMultiSelect() .EnableAudioPreview() .ExtensionFilter( - "All Instruments|*.xi;*.pat;*.iti;*.flac;*.wav;*.aif;*.aiff|" + "All Instruments|*.xi;*.pat;*.iti;*.flac;*.wav;*.aif;*.aiff;*.sf2;*.sbk;*.dls|" "FastTracker II Instruments (*.xi)|*.xi|" "GF1 Patches (*.pat)|*.pat|" "Impulse Tracker Instruments (*.iti)|*.iti|" + "SoundFont 2.0 Banks (*.sf2)|*.sf2;*.sbk|" + "DLS Sound Banks (*.dls)|*.dls|" "All Files (*.*)|*.*||") .WorkingDirectory(TrackerDirectories::Instance().GetWorkingDirectory(DIR_INSTRUMENTS)) .FilterIndex(&nLastIndex); Modified: trunk/OpenMPT/mptrack/View_tre.cpp =================================================================== --- trunk/OpenMPT/mptrack/View_tre.cpp 2014-12-06 18:56:49 UTC (rev 4635) +++ trunk/OpenMPT/mptrack/View_tre.cpp 2014-12-06 19:15:40 UTC (rev 4636) @@ -1806,6 +1806,9 @@ // Instruments if ((!strcmp(s, "xi")) || (!strcmp(s, "iti")) + || (!strcmp(s, "sf2")) + || (!strcmp(s, "sbk")) + || (!strcmp(s, "dls")) || (!strcmp(s, "pat")) ) { if (IsSampleBrowser()) Modified: trunk/OpenMPT/soundlib/Dlsbank.cpp =================================================================== --- trunk/OpenMPT/soundlib/Dlsbank.cpp 2014-12-06 18:56:49 UTC (rev 4635) +++ trunk/OpenMPT/soundlib/Dlsbank.cpp 2014-12-06 19:15:40 UTC (rev 4636) @@ -1151,21 +1151,28 @@ bool CDLSBank::Open(const mpt::PathString &filename) //-------------------------------------------------- { + if(filename.empty()) return false; + m_szFileName = filename; + CMappedFile MapFile; + if (!MapFile.Open(filename)) return false; + return Open(FileReader(MapFile.Lock(), MapFile.GetLength(), &m_szFileName)); +} + + +bool CDLSBank::Open(FileReader file) +//---------------------------------- +{ SF2LOADERINFO sf2info; const BYTE *lpMemFile; // Pointer to memory-mapped file RIFFCHUNKID *priff; DWORD dwMemPos, dwMemLength; UINT nInsDef; - if(filename.empty()) return false; - m_szFileName = filename; - lpMemFile = NULL; - // Memory-Mapped file - CMappedFile MapFile; - if (!MapFile.Open(filename)) return false; - dwMemLength = MapFile.GetLength(); - if (dwMemLength >= 256) lpMemFile = (const BYTE *)MapFile.Lock(); - if (!lpMemFile) + file.Rewind(); + m_szFileName = file.GetFileName(); + lpMemFile = reinterpret_cast<const BYTE *>(file.GetRawData()); + dwMemLength = file.GetLength(); + if (!lpMemFile || dwMemLength < 256) { return false; } Modified: trunk/OpenMPT/soundlib/Dlsbank.h =================================================================== --- trunk/OpenMPT/soundlib/Dlsbank.h 2014-12-06 18:56:49 UTC (rev 4635) +++ trunk/OpenMPT/soundlib/Dlsbank.h 2014-12-06 19:15:40 UTC (rev 4636) @@ -139,6 +139,7 @@ public: bool Open(const mpt::PathString &filename); + bool Open(FileReader file); mpt::PathString GetFileName() const { return m_szFileName; } UINT GetBankType() const { return m_nType; } UINT GetBankInfo(SOUNDBANKINFO *pBankInfo=NULL) const { if (pBankInfo) *pBankInfo = m_BankInfo; return m_nType; } Modified: trunk/OpenMPT/soundlib/SampleFormats.cpp =================================================================== --- trunk/OpenMPT/soundlib/SampleFormats.cpp 2014-12-06 18:56:49 UTC (rev 4635) +++ trunk/OpenMPT/soundlib/SampleFormats.cpp 2014-12-06 19:15:40 UTC (rev 4636) @@ -14,6 +14,7 @@ #ifdef MODPLUG_TRACKER #include "../mptrack/Moddoc.h" #include "../mptrack/TrackerSettings.h" +#include "Dlsbank.h" #endif //MODPLUG_TRACKER #include "../common/AudioCriticalSection.h" #ifndef MODPLUG_NO_FILESAVE @@ -106,7 +107,18 @@ && !ReadXIInstrument(nInstr, file) && !ReadITIInstrument(nInstr, file) // Generic read - && !ReadSampleAsInstrument(nInstr, file, mayNormalize)) return false; + && !ReadSampleAsInstrument(nInstr, file, mayNormalize)) + { + bool ok = false; +#ifdef MODPLUG_TRACKER + CDLSBank bank; + if(bank.Open(file)) + { + ok = bank.ExtractInstrument(*this, nInstr, 0, 0); + } +#endif // MODPLUG_TRACKER + if(!ok) return false; + } if(nInstr > GetNumInstruments()) m_nInstruments = nInstr; return true; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |