add support for non-timidity soundfonts (like Fluid R3)

pull/16/head
r-lyeh 10 years ago
parent fbd87c0752
commit 868ec9f2d6

@ -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)

Binary file not shown.

@ -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

@ -28,6 +28,7 @@
All systems - all compilers (hopefully)
*/
#include <string>
#include <stdlib.h>
#include <time.h>
#include <string.h>
@ -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;

Loading…
Cancel
Save