diff --git a/README.md b/README.md index 5dbffc4..7c3e1c2 100644 --- a/README.md +++ b/README.md @@ -39,5 +39,6 @@ Libyquist is released under the 2-Clause BSD license. All dependencies and codec ## About MIDI files * [SoundFonts](https://en.wikipedia.org/wiki/SoundFont) are required to decode MIDI files. -* Libnyquist supports `.pat` soundfonts only. Use [unsf tool](http://alsa.opensrc.org/Unsf) to convert from `.sf2` to `.pat` soundfonts. -* Also, [sfark tool](http://www.melodymachine.com/sfark.htm) may be needed to unpack legacy compressed soundfonts. +* Libnyquist supports `.pat` (GUS) soundfonts only. Use [unsf tool](http://alsa.opensrc.org/Unsf) to convert from `.sf2` to `.pat` soundfonts, and [sfark tool](http://www.melodymachine.com/sfark.htm) to unpack compressed soundfonts (`.sf2ark`). +* The compiler directive `PAT_CONFIG_FILE` tells libnyquist what soundfont file is set by default (defaults to `pat/timidity.cfg`; valid options are `FluidR3_GM2/FluidR3_GM2-2.cfg`, etc). +* Additionally, there is runtime check for the environment variable `MMPAT_PATH_TO_CFG`, which contains the path to the config file. For more info please check [this source file](third_party\libmodplug\src\load_pat.cpp) diff --git a/test_data/mid/migm1.mid b/test_data/mid/migm1.mid new file mode 100644 index 0000000..aef79ef Binary files /dev/null and b/test_data/mid/migm1.mid differ diff --git a/test_data/mid/migm1.txt b/test_data/mid/migm1.txt new file mode 100644 index 0000000..e3f8294 --- /dev/null +++ b/test_data/mid/migm1.txt @@ -0,0 +1,43 @@ + QUEST STUDIOS + SOFTWARE SOUNDTRACK SERIES + ==================================================== + THE SECRET OF MONKEY ISLAND + + + "INTRODUCTION/OPENING THEMES" + Michael Z. Land + ==================================================== + Copyright (c)1989 LucasArts Entertainment Co. + ==================================================== + + G E N E R A L M I D I V E R S I O N + + + +System Requirements: + +- MIDI Playback Software capable of reading Type 1 Standard + MIDI File format +- General MIDI sound device (Wave Table recommended.) + + +This Standard MIDI File was recorded directly from LucasFilm Game's +"The Secret of Monkey Island" adventure game. It has been converted +from the MT-32 version for playback on General MIDI sound cards. A +Wave Table sound card is highly recommended for optimal playback. + +Recorded/Converted to Standard MIDI File format by Tom Lewandowski. +Address questions or comments to: + + QUEST STUDIOS + Tom Lewandowski + tom+di@netnet.net + + + + THE ROLAND MT-32 SOUND MODULE RESOURCE CENTER + THE SIERRA SOUNDTRACK SERIES/SOFTWARE SOUNDTRACK SERIES + http://bayland.net/~tom+di/sierra/roland.html + + + diff --git a/third_party/libmodplug/src/load_pat.cpp b/third_party/libmodplug/src/load_pat.cpp index 15ab12b..a8f77e5 100644 --- a/third_party/libmodplug/src/load_pat.cpp +++ b/third_party/libmodplug/src/load_pat.cpp @@ -28,6 +28,7 @@ All systems - all compilers (hopefully) */ +#include #include #include #include @@ -47,11 +48,21 @@ #include "load_pat.h" #define DIRDELIM '/' -//#define TIMIDITYCFG "pat/TimGM6mb.cfg" -#define TIMIDITYCFG "pat/timidity.cfg" -#define PATHFORPAT "pat" -#define PAT_ENV_PATH2CFG "MMPAT_PATH_TO_CFG" +#ifndef PAT_CONFIG_FILE +//#define PAT_CONFIG_FILE "FluidR3_GM2/FluidR3_GM2-2.cfg" +#define PAT_CONFIG_FILE "pat/timidity.cfg" +#endif + +#ifndef PAT_CONFIG_DRUM_OFFSET +#define PAT_CONFIG_DRUM_OFFSET 25 // timidity.cfg drum patches start at 25 +#endif + +#ifndef PAT_ENV_PATH2CFG +#define PAT_ENV_PATH2CFG "MMPAT_PATH_TO_CFG" +#endif + + // 128 gm and 63 drum #define MAXSMP 191 @@ -221,7 +232,7 @@ int pat_gm_drumnr(int n) { if( n < 25 ) return 129; if( n+129-25 < MAXSMP ) - return 129+n-25; // timidity.cfg drum patches start at 25 + return 129+n-PAT_CONFIG_DRUM_OFFSET; return MAXSMP; } @@ -356,15 +367,20 @@ void pat_init_patnames(void) char line[PATH_MAX]; char cfgsources[5][PATH_MAX] = {{0}, {0}, {0}, {0}, {0}}; MMSTREAM *mmcfg; - strncpy(pathforpat, PATHFORPAT, PATH_MAX); - strncpy(timiditycfg, TIMIDITYCFG, PATH_MAX); + + strncpy(timiditycfg, PAT_CONFIG_FILE, PATH_MAX); p = getenv(PAT_ENV_PATH2CFG); if( p ) { - strncpy(timiditycfg, p, PATH_MAX - 14); - strncpy(pathforpat, p, PATH_MAX - 13); - strcat(timiditycfg, "/timidity.cfg"); - strcat(pathforpat, "/instruments"); + strncpy(timiditycfg, p, PATH_MAX); } + { + std::string normalized(timiditycfg); + for( size_t i = 0; i < normalized.size(); ++i ) { + if( normalized[i] == '\\' ) normalized[i] = '/'; + } + strcat(pathforpat, normalized.substr(0, normalized.find_last_of('/') + 1).c_str() ); + } + strncpy(cfgsources[0], timiditycfg, PATH_MAX - 1); nsources = 1;