Project
Raspberry Pi Tips
Fluidsynth
Environment: Raspberry Pi 3 Model B V1.2
FluidSynth is a real-time software synthesizer based on the SoundFont 2 specifications and has reached widespread distribution. FluidSynth itself does not have a graphical user interface, but due to its powerful API several applications utilize it and it has even found its way onto embedded systems and is used in some mobile apps.
Qsynth is a fluidsynth GUI front-end application written in C++ around the Qt framework using Qt Designer. Eventually it may evolve into a softsynth management application allowing the user to control and manage a variety of command line softsynth but for the moment it wraps the excellent FluidSynth.
Compotision
MIDI sequencer (eg. Qtractor, Rosegarden or any keyboard) > Synthesizer (Fluidsynth) > Sound server (jackd) > Linux Kernel (ALSA) > Hardware (sound card)
I tried several synthsizer that are runnable on Rpi(synthv1, bristle, timidy etc). Fluid synth looks to be good that it embed basic MIDI sound source and run both by commandline and GUI (qsynth)
Install fluidsynth and qsynth
$ sudo apt-get install fluidsynth $ sudo apt-get install qsynth
Sound font
Through above command, you shoud get basic sound fonts of
- FluidR3_GM.sf2: A General MIDI sound set
- FluidR3_GS.sf2: A Roland GS-compatible sound set
Play MIDI file by commandline
$ fluidsynth -a alsa -n -i /usr/share/sounds/sf2/FluidR3_GM.sf2 "midi file"
For example, following command works without running qjackctl.
$ cd ~/repo/taoflam/python_audio $ fluidsynth -a alsa -n -i /usr/share/sounds/sf2/FluidR3_GM.sf2 The_Castle_of_Dromore.mid
Play MIDI keyboard (and automatic setup)
Using my test keyboard (KORT microKEY), I setup as follows.
# set audio device: alsa and gain: 5 $ fluidsynth -a alsa -g 5 /usr/share/sounds/sf2/FluidR3_GM.sf2 # check MIDI port $ aconnect -o client 14: 'Midi Through' [type=カーネル] 0 'Midi Through Port-0' client 24: 'microKEY-25' [type=カーネル,card=2] 0 'microKEY-25 MIDI 1' client 129: 'FLUID Synth (2359)' [type=ユーザ,pid=2359] 0 'Synth input port (2359:0)' # connect microKEY-25 to fluidsynth $ aconnect 24:0 129:0
In my environment, qjack panel does not work well. However above alsa command of aconnect loooks to be finely working. Also, I setup above command as following shell script
run-piano.sh
#!bin/bash fluidsynth -is --audio-driver=alsa --gain 3 /usr/share/sounds/sf2/FluidR3_GM.sf2 & sleep 10 aconnect 24:0 129:0 # set the priority of pi user to 18 (max is 19) sudo renice -n 18 -u pi
Play jack-keyboard via qsynth
Installed jack-keyboard from "add or delete application" on RPi.
2. start qjack control
$ qjackctl &
3. start jack-keyboard
$ jack-keyboard
4. start qsynth
qsynth is GUI interface for fluidsynth
$ qsynth
5. Configuration (Qsynth)
Qsynth - Setup
- MIDI > Enable MIDI Input
- MIDI > MIDI Driver: Jack
- Audio > Audio Driver: alsa
- Soundfonts > FluidR3_GM.sf2
6. Configuration (qjack)
qjack - Connect
- MIDI > connect jack-keyboard - fluidsynth-midi
- For input from software synthsize(jack-keyboard), I did not need to connect devices at Audio or ALSA tabs on qjack control.