/ Examples / Instruments / FluidSynth


Projects .. AudioIO .. Control
NoteStreams .. Instruments
Filters .. Effects .. LiCK Effects
Plot .. Utility .. Pure ChucK


Wherein we revel in having hundreds of instruments hidden within a single instrument node

Right-click to copy examples to your workspace

FluidSynth

Fiddle's Fluid instrument is built atop the ChucK Chugin that bridges to the open-source FluidSynth Synthesizer.

The "batteries" that make FluidSynth work are SoundFonts. Here, batteries are included in the form of MIT-licensed FluidR3_GM.sf2, courtesy Frank Wen. This is the default value for the Fluid node's SoundFont parameter and, coupled with a valid Fiddle installation you should be able to operate FluidSynth out-of-box. Of course, if you have a favorite soundfont, you can use that instead. And if you want to go whole-hog you can even cobble together a custom sound font using a specialized soundfont authoring environment like Polyphone.

One advantage of soundfonts over individual sample files is their convenience. Within a single soundfont file reside many hundreds or thousands of sample files. Rather than refer to individual notes by file-name you can use soundfont technolog to refer to all the notes of multiple instruments through 3 integers: bank, preset/program and note. Other MIDI controls (like velocity) can even modify the timbre of an individual note.

In the case of FluidR3_GM more than 128 instruments are included. The _GM in the name refers to the General MIDI standard which assigns a standard voice, like Harpsichord, to a standard preset: 7.

As stated previously there are three integers that identify an individual note within a soundfont. The most important, Instrument, refers to the preset number (often following the General MIDI spec). Most soundfiles comprise at least two Banks, one for melodic instruments and another for percussive. When an instrument from a percussion bank is selected, the MIDI notes refer to specific or related percussion sounds (or instruments) as described here. A convenient part of the GM spec prescribes that the default bank for MIDI channel 10 be a bank that holds percussion instruments.

Below we see the graph for this example, fluidSynth.chg. Here we're using AbcSequencer as our source of notes. We have two Fluid node instances, one FluidDrums that is accessing instruments from the percussion channel, 10 and the other Fluid accessing standard instruments (on channel 1). We have CCGenerator generating a new instrument index every two seconds and so you can use this example to audition every voice in a soundfont. Because CCGenerator.Debug is checked you can see the current number in the Log panel.

Other important notes on the FluidSynth engine:

Fluid Node

The Fluid node targets general purpose melodic instrument usage. It can also be used for percussive soundbanks by setting MidiChannel to 10. It's sibling, FluidDrumkit Node, presents an interface targeting the percussion use-case.

SoundFont selects the soundfont for this instance. At right you see the default value which includes the relative pathname with the Fiddle distribution.

Instrument selects the voice/instrument within the context indicated by MidiChannel and Bank. Usually this is the main parameter for selecting an instrument.

MidiChannel selects from a bank of instruments in the soundfont. Usually this value is set to either 1 for GM or 10 for GM-percussion.

Bank another aspect of instrument specification. Its interpretation/function depends on the soundfont and it often may have no effect.

Gain a multiplier for the output signal loudness. Since FluidSynth has a lot of headphone to support polyphony you may find that you need values as high as 8 here.

Instances is usually set to 1 for FluidSynth because it supports polyphony internally.

FluidDrumKit example

In this second example we produce a rhythm track with the GridEditor and the NoteGrid Node.

NoteGrid Node

The NoteGrid node performs .fgrd files produced by the GridEditor. In this file beatbox.fgrd you'll find around 15 two-bar sections identified by letters [A-Z].

File specifies the .fgrd file to perform.

Layer requests a subset of the layers within the file to be performed. The value -1 means perform all layers, but this example file contains a single note layer.

Arrangement controls how the contents of File are performed. When empty, the entire file is performed. In this example, Arrangement is an expression that refers to sections within the file. In this case each section is a different drumkit pattern and you can use this as described in the BeatBox example.


FluidDrumkit Node

SoundFont described above.

Instrument refers to the preset/program within the specified bank. For bank 128, there are several standard drumkits available.

1 Standard Kit - the only kit specified by General MIDI Level 1
9 Room Kit Drums recorded with room ambience
17 Power Kit More powerful kick and snare sounds
25 Electronic Kit Sounds of various electronic drums
26 TR-808 Kit Analog drum kit similar to Roland TR-808
33 Jazz Kit Softer kick and snare sounds than the Standard Kit
41 Brush Kit Many brush sounds added
49 Orchestra Kit A collection of concert drums and timpani
57 Sound FX Kit

Bank the voice bank. For FluidR3_GM (and many soundfonts), bank 128 is a bank of percussion instruments so you may not need to change this.

MIDINote specifies the base note of a continuous range of MIDI notes to respond to. This is the same approach used by the SoundBufBank node. When MIDI notes above C3 are received, they are converted to a number representing the semitones above the MIDINote. This value is then used by VoiceMap and GainPan to control the behavior of that note.

VoiceMap maps the MIDINote offset to a sound within the instrument. General MIDI prescribes a set of standard percussion sounds. Here:

C3 → 36 Electric Bass Drum (Kick)
C#3 → 40 Electric Snare
D3 → 42 Closed Hi-hat (Cymbal)
D#3 → 51 Ride (Cymbal)
E3 → 53 Ride (Bell)

GainPan provides a gain and pan value for each voice. Here you can see that the kick is on the right (1), the snare is on the left (-1) and the hi-hat is in the center. When not provided, notes will appear in the center.

Gain specifies the master gain for the FluidSynth node.

Right-click to copy examples to your workspace

home .. topics .. interface .. reference .. examples .. tipjar