Skip to content

Commit 131d457

Browse files
committed
enable reading of zipped GUS patch sets directly without client side support.
Just pass the zip's name for the patch set and it will work automatically. This also deletes a redundant copy of miniz.h in libxmp.
1 parent 59101ab commit 131d457

File tree

11 files changed

+765
-1424
lines changed

11 files changed

+765
-1424
lines changed

CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ set(CMAKE_C_VISIBILITY_PRESET hidden)
44
set(CMAKE_CXX_VISIBILITY_PRESET hidden)
55
set(CMAKE_VISIBILITY_INLINES_HIDDEN ON)
66

7+
set(CMAKE_CXX_STANDARD 17)
8+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
9+
set(CMAKE_CXX_EXTENSIONS OFF)
10+
711
if (VCPKG_LIBSNDFILE)
812
list(APPEND VCPKG_MANIFEST_FEATURES "vcpkg-libsndfile")
913
endif()

source/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ INTERFACE
3838
zmusic/configuration.cpp
3939
zmusic/zmusic.cpp
4040
zmusic/critsec.cpp
41+
zmusic/file_zip.cpp
42+
4143
loader/test.c
4244
)
4345

source/mididevices/music_timidity_mididevice.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,15 @@ bool GUS_SetupConfig(const char* args)
272272
// If the passed file is an SF2 sound font we need to use the special reader that fakes a config for it.
273273
if (memcmp(test, "RIFF", 4) == 0 && memcmp(test + 8, "sfbk", 4) == 0)
274274
reader = new MusicIO::SF2Reader(args);
275+
// Also try zipped GUS patch sets.
276+
else if (memcmp(test, "PK\3\4", 4) == 0)
277+
{
278+
auto zreader = new MusicIO::ZipPatReader(args);
279+
if (zreader->isValid()) // must check if it worked.
280+
reader = zreader;
281+
else
282+
delete zreader;
283+
}
275284
}
276285
if (!reader) reader = new MusicIO::FileSystemSoundFontReader(args, true);
277286
}

source/mididevices/music_timiditypp_mididevice.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,15 @@ bool Timidity_SetupConfig(const char* args)
214214
// If the passed file is an SF2 sound font we need to use the special reader that fakes a config for it.
215215
if (memcmp(test, "RIFF", 4) == 0 && memcmp(test + 8, "sfbk", 4) == 0)
216216
reader = new MusicIO::SF2Reader(args);
217+
// Also try zipped GUS patch sets.
218+
else if (memcmp(test, "PK\3\4", 4) == 0)
219+
{
220+
auto zreader = new MusicIO::ZipPatReader(args);
221+
if (zreader->isValid()) // must check if it worked.
222+
reader = zreader;
223+
else
224+
delete zreader;
225+
}
217226
}
218227
if (!reader) reader = new MusicIO::FileSystemSoundFontReader(args, true);
219228
}

source/mididevices/music_wildmidi_mididevice.cpp

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,24 @@ bool WildMidi_SetupConfig(const char* args)
246246
MusicIO::SoundFontReaderInterface* reader = MusicIO::ClientOpenSoundFont(args, SF_GUS);
247247
if (!reader && MusicIO::fileExists(args))
248248
{
249-
reader = new MusicIO::FileSystemSoundFontReader(args, true);
249+
auto f = MusicIO::utf8_fopen(args, "rb");
250+
if (f)
251+
{
252+
char test[12] = {};
253+
fread(test, 1, 12, f);
254+
fclose(f);
255+
// Also try zipped GUS patch sets.
256+
if (memcmp(test, "PK\3\4", 4) == 0)
257+
{
258+
auto zreader = new MusicIO::ZipPatReader(args);
259+
if (zreader->isValid()) // must check if it worked.
260+
reader = zreader;
261+
else
262+
delete zreader;
263+
}
264+
}
265+
if (reader == nullptr)
266+
reader = new MusicIO::FileSystemSoundFontReader(args, true);
250267
}
251268

252269
if (reader == nullptr)

0 commit comments

Comments
 (0)