You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
libnyquist/midi-playback.md

9 lines
1.7 KiB
Markdown

## MIDI Player Functionality
A SoundFont `.sf2` file is a file that contains many samples of different instruments playing different notes, enabling Libnyquist to render finally each instrument sound in the MIDI song. SoundFonts are available on the web, but the quality and size varies a lot, and they may have licensing issues (because of the copyright of the different samples), they may be designed for different styles of music (classical, jazz, pop...), and they may target different sets of instruments as well. As a general rule, most MIDI files are targeted to use the 128 sounds of [General MIDI standard (GM)](http://en.wikipedia.org/wiki/General_MIDI), so use a SoundFont that does conform to this standard. You probably want to try the [Fluid R3 GM (141 MB uncompressed)](http://google.com/search?q=Fluid+R3+GM+soundfont) as a starter pack, which is a very good general purpose SoundFont (and fully MIT licensed).
SoundFont files are large and often compressed in `.zip`, `.tar.gz` or `.sfArk` formats. `.sfArk` files can be unpacked with [sfark tool](http://www.melodymachine.com/sfark.htm). For now, libnyquist supports `.pat` (GUS) soundfonts only, which can be converted from `.sf2` files with the [unsf tool](http://alsa.opensrc.org/Unsf).
Back to the library, the compiler directive `PAT_CONFIG_FILE` tells libnyquist what soundfont file is hardcoded by default (defaults to `pat/timidity.cfg`, but might be `FluidR3_GM2/FluidR3_GM2-2.cfg`, or any other valid path during compilation). Additionally, there is a 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)