How to use multiple Soundfonts in Timidity

Kiran Karkera
2 min readJul 10, 2022

--

This post describes how to configure Timidity to use multiple soundfonts, especially instruments from different soundfont files.

Photo by Rajesh Kavasseri on Unsplash

So you’ve got some Midi files, and different Soundfont files. Lets say the Expressive Flute Soundfont for flute, and another guitar Soundfont.

You’d like to generate (or play) audio (using Timidity to convert midi to audio.) How to go about this?

Step 1:

  • Put the Soundfont files in a single directory. For the sake of this discussion, let’s say its in /soundfont folder
  • Ensure that the Soundfont files are unzipped and have a .sf2 filename ending.

<Digression>

A midi file denotes instruments using numbers 0–127. For example,

  • Piano: 1
  • Flute: 74
  • Guitar: 28

If the Midi file has notes played on the flute (indicated by instrument=74 for those notes) , Timidity looks for the instrument number (74) in the default Soundfont.

However when one or more Soundfonts are loaded, we need to configure Timidity to look for the instrument in a different place.

Preset numbers for violin and strings in Strings-4U Soundfont

Each individual Soundfont may not place the instrument in the default position. For example, in the Strings-4U Soundfont, it has Violin at preset number 0 instead of 40 (which is the default).

Therefore we need to configure Timidity to

  • Load the Soundfont
  • For each instrument number, associate the present number in the Soundfont.

Step 2:

Configure timidity.cfg:

In the above example:

  • Line 1 declares where the Soundfont files are to be found
  • Line 3 declares that the following sounds are in bank 0 (A Soundfont file can have multiple banks)
  • Line 3–6 each define an instrument, with the format

instrument %font soundfont-filename band preset

Example

74 %font ExpressiveFluteSSO-v1.2.sf2 0 0

indicates that instrument 74 (flute) is to be played from the Expressive Flute Soundpack, from bank 0 and preset 0.

Hope that was helpful!

--

--