One thing that keeps annoying me about Soundfonts is that there is no
way to specify the initial pitch of an instrument in the instrument
itself. The spec defines generators for an "initial attenuation",
"initial filter Q and FC", and many more. But there is no such thing
when it comes to the initial pitch wheel sensitivity or pitch bend
range. Everything completely relies on the default initialization of
MIDI RPN0, which is defined to be 2 semitones.

Yet, in order to override it in the soundfont itself, people recommend
that one should override the default pitch modulator. This is not an
adequate solution! For example, if we have an instrument that should
have an initial pitch bend range of +- 4 semitones (rather than the
+-2 default), we should go ahead, overriding the default pitch
modulator in the instrument's global zone, by doubling its original
amount, i.e. giving it an amount of 25400 cents.

This works great, as long as there is no MIDI that overrides the
default value of RPN0 with anything but 2. Overriding RPN0, in this
case, would not lead to overriding the pitch bend range. No, it would
lead to a new, most likely bigger pitch bend range.

What's a possible solution to this? The soundfont spec has many unused
generators. Just take one of them, let's say "unused1", and use it for
storing the initial pitch bend range of that particular instrument -
relative cents should be used as units, stored as signed int16. Every
time when fluidsynth would change the program of a channel, it would
read that value and update the fluid_chan::pitch_wheel_sensitivity
accordingly.

But why is that value signed? To keep backward compatibility with the
default value of RPN0 in sync. I.e. To set a default pitch bend range
of 5 semitones, the value stored would be 500 cents - 200 cents = 300
cents. Likewise, when there should only be 1 semitone initial bend
range, the value stored would be 100 - 200 = -100 cents. Note how
nicely this solution would be backward compatible: Soundfonts that do
not use this technique would just continue to keep this field 0.
Reading back this value and adding 2 semitones would magically result
in the default RPN0 initialization as per MIDI spec.

Any opinions or comments?
Tom

_______________________________________________
fluid-dev mailing list
fluid-dev@nongnu.org
https://lists.nongnu.org/mailman/listinfo/fluid-dev

Reply via email to