Hello to all Zynthianers,
after spending some hours on this issue, I want to share some informations as things are far from being as easy as it seems, if you want to activate cutoff and resonance control in a SF2 file for FluidSynth.
The SF2 modulators are really a complex thing and I spent hours in order to edit my SF2 file so the Zynthian can modulate the filter as I wanted.
First of all, there are two main things to understand when you deal with MIDI control :
- SF2 files do not use MIDI value range (0…127) but 0…1 or -1…1 value ranges (in other terms, FluidSynth scales all incoming MIDI values whatever input is 7 bits or 14 bits…)
- Most parameters in SF2 are expressed in real units. For example, cutoff frequency is in Hz not in % or anything like that.
The first mistake I made has been to send directly MIDI value to the filter cutoff… which meant that I had a filter with a cutoff frequency from 1Hz to 128Hz…
Second important thing to understand : modulators are LAYERED !!!
The way they act on a sound depends directly of the layer they are declared : values defined at INSTRUMENT level are absolute.
For example, the cutoff defined here for “Dance synth 1” is 19Hz. Cutoff computed by modulators will be added to this value.
If you want now to control cutoff from MIDI Control Change (CC74 for example), you will have to create a modulator like this following one
Note how the values are scaled before the multiplier : with the selected curve, it goes from 0 to 1 while MIDI CC goes from 0 to 127. Note also that Sound Font defines that lowest cutoff frequency is 8.176Hz (under the rightmost selection list), so when CC changes from 0 to 127, then scaled from 0 to 1, then multiplied by 13500 gives a frequency control range from 8.176 Hz to 19912Hz. Easy, no ?
(No operation means “equal”, by the way…)
When this SoundFont is uploaded in the Zynthian, the Cutoff knob has finally an effect! Yayyyy
You think things are still too simple ?
Then you have to know that ALL modulators going to the same parameter (cutoff here) are added! So if you define a second modulator driven by another MIDI Control Change or the Note Velocity or anything else, the Cutoff frequency becomes driven by the two parameters
And the SoundFont specification says that there is no limit (in theory…) to the number of modulators for a given parameter…
Last but not least, you can also define a modulator at the PRESET level. But try to guess what happens then ?
Modulators declared at PRESET level have a relative effect
Modulators at PRESET level multiply the instrument modulator output by their own output! (that’s why you see a “x” rather than “Hz”)
So, you have to be careful about the layer where you declare your modulator (in most cases, it will be at Instrument level, while you keep modulators at Presets level to default definition)
And finally, I have to say that I am now in love with the modulation scheme available in FluidSynth, as it is incredibly powerful when you know how to use it