Tag Archives: midi

JACK and Fluidsynth, the command line way!

I posted an entry about using Gentoo with a MIDI keyboard. In this post I used GUI apps to run jackd and fluidsynth… here is how to do it without these pesky GUI apps.

Follow the other post’s instructions for installing and setting up JACK and the snd_usb_audio kernel module. There is no need to install qjackctl or qsynth! I am using the init script on the Gentoo wiki to start JACK (here), as well as some other configurations to use JACK for all other sound (which I have posted here).

Now you have JACK started without qjackctl, it’s time to start Fluidsynth and connect everything together.

First start Fluidsynth with this command:

fluidsynth -a jack -g 1 -j ~/path/to/soundfont.sf2

“-a jack” makes fluidsynth use JACK.

“-g 1″ sets the gain to 1. This’ll boost the volume a bit. Play around, you may not need it. On my system it’s very quiet without this option set!

“-j” will automatically connect fluidsynth and JACK together.

Your soundfont will be loaded. Pay attention to any warnings about sample rates mismatching, this will cause tuning issues!

And finally we must connect your keyboard to fluidsynth. We will use ‘aconnect’, which comes with ALSA.

First get a list of all your input ports.

$ aconnect -i -l
client 0: 'System' [type=kernel]
    0 'Timer           '
    1 'Announce        '
	Connecting To: 15:0
client 14: 'Midi Through' [type=kernel]
    0 'Midi Through Port-0'
client 20: 'Keystation Pro 88' [type=kernel]
    0 'Keystation Pro 88 MIDI 1'
    1 'Keystation Pro 88 MIDI 2'
$

And a list of all your outputs.

$ aconnect -o -l
client 14: 'Midi Through' [type=kernel]
    0 'Midi Through Port-0'
client 20: 'Keystation Pro 88' [type=kernel]
    0 'Keystation Pro 88 MIDI 1'
client 128: 'FLUID Synth (22449)' [type=user]
    0 'Synth input port (22449:0)'
$

We can see our keyboard input on port 20 and fluidsynth output on port 128, so we connect them together using the command

$ aconnect 20 128

And we’re done! Enjoy.

Gentoo and MIDI keyboard

I recently purchased a M-Audio Keystation Pro-88 MIDI keyboard, so I could continue playing the piano while I am at uni. I got the keyboard working well under Windows using Reason and Reason Pianos – but being a Linux geek I couldn’t be booting into Windows every day just to play. Wine isn’t an option, sound work is intensive and I didn’t want to rely on Windows emulation. There must be a way to do this without Windows emulation and still get decent results.

After only an hour or so Googling and setting things up, my keyboard was up and running in Linux, and here’s how I did it.

Install and setup JACK
You’re going to need a decent sound server for audio work. When it comes to Linux, JACK is the only option. I used these instructions to get a JACK server up and running in no time at all. http://en.gentoo-wiki.com/wiki/JACK

Install snd_usb_audio kernel module
You will need the snd_usb_audio kernel module. This can be found:


Device Drivers --->
Sound card support --->
Advanced Linux Sound Architecture --->
[*] USB sound devices --->
USB Audio/MIDI driver

Install qjackctl and qsynth
qjackctl is the tool you will be using to start/stop JACK and setup the correct connections.
qsynth is a soundfont reader which will turn your MIDI input into a piano.

You can use JACK via command line and avoid using qjackctl. This is preferred but is more complicated and beyond the scope of this article. Maybe another time.

emerge -a qjackctl qsynth

Get the Acoustic Grand Piano soundfont
This can be found here: http://zenvoid.org/audio.html

wget http://zenvoid.org/audio/acoustic_grand_piano_ydp_20080910.sf2

Start qjackctl and qsynth
Do this however you want.

Start JACK sound server
ALSA will need to be free for this, so close Firefox and killall mpd. (mpd can use JACK, so can mplayer. Firefox can’t!)

Finally
Load the soundfont into qsynth, and using the qjackctl connections dialog connect the MIDI keyboard to qsynth, under the “ALSA” tab.

DONE

Let me know if you find any more decent free Piano soundfonts.