I bought a Raspberry Pi 3 for the speed/memory upgrade. Since the GPIO header is the same as the Pi 2 I was able to just swap it out with the Pi 3. With the faster processor I was able to tweak fluidsynth's settings (audio.period-size: 64, audio.periods: 3) to get even less latency. I didn't really notice a delay before, but playing through the jamPi definitely "feels" more responsive now.
A couple other minor points of progress:
- Updated pyfluidsynth with bindings to fluid_midi_router.c - router rules can be set up in config_jampi.yaml
- Expanded structure of config_jampi.yaml and how it is interpreted by jampi.py:
- settings:soundfont: global soundfont to use in patches if per-channel soundfont isn't specified
- settings:fluidsettings: passes options to fluidsynth
- router rules can be specified globally (in settings) on a per-patch, or per-channel basis
- I read the soundfont 2.1 spec a bit more carefully and realized that modulators can be used to allow CC messages to control things like filter cutoff, resonance, etc. Fluidsynth already understands modulators, so I can use the built-in synth capability of soundfonts without rewriting fluidsynth. To test this, I used Polyphone to make a soundfont with one saw wave preset and modulators tying the filter resonance and cutoff to CC 71 and 74, and it works! Boss.