Intro: MIDI SoundFont Synthetizer With Intel Edison and Fluidsynth
By following the steps described here, you'll have a synthesizer that can play almost any SoundFont available on the Internet, so basically this is probably the latest synth you´ll need for the rest of your life :)
This is the second step of a bigger project started with this first Instructable.
At the end of the Instructable, there is a video with the SoundFont synth demo.
Step 1: What We Need
My MIDI Controller is a Behringer UMA25S, and it has an embedded Audio Card. You can use two separate devices to do the same. We'll also need an Intel Edison power supply and in my case I needed an active USB Hub (a powered USB Hub), to power the MIDI Controller. The specs for the Intel Edison Breakout Board power supply can be found here.
I also used an external speaker (I love it loud) and headphones during the process.
Step 2: Setting Up the Intel Edison Board, Installing Additional Packages and Configuring Audio
I really recommend you to follow all the steps of my latest Instructable here, because at the end you'll have your Edison board with audio configured and with Csound compiled and running (check the video at the end of the tutorial to see the great sound that we can have from Csound).
If you don't want to have Csound installed on your board, you just need to follow the Steps 1 to 3.
Step 3: Download, Compile and Install Fluidsynth
According to the Fluidsynth description on the project's website:
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.
The first thing we need is to download FluidSynth's source code from here (version 1.1.6).
Transfer that file to your Edison board (I usually use sftp to do that, using a software like Filezilla and the same credentials I use to login on my board).
Now we need to extract the source code, configure, compile, verify, install and clean up everything. This can easily be done with the following commands (at Edison board console):
Extract the source code:
#tar zxvf fluidsynth-1.1.6.tar.gz
Enter into the source folder:
Verify the compiled binaries:
Install the binaries:
Clean the mess :) :
Step 4: Download a SoundFont, a MIDI Song and Test Your FluidSynth Installation
To test my FluidSynth installation, I used the FluidR3_GM.sf2 SoundFont file, that is distributed with FluidSynth on most Linux distributions, usually on the fluid-soundfont-gm package. If you don't have a Linux box to borrow the SoundFont from, Google is your friend.
NOTE: There are several SoundFont files available on the Internet, but some of those files aren't for free (as in beer). Always double check that before using a SoundFont.
You will also need a MIDI song to test your installation. Again, Google is your friend, so google for "MIDI song" and choose the one you enjoy to use.
To run Fluidsynth using the SoundFont I mentioned to play your MIDI song, please run:
#fluidsynth -a alsa -g 3 FluidR3_GM.sf2 YourMidiSongFile.midi
If everything is fine, you should listen your song being played using the SoundFont.
Step 5: Running Fluidsynth and Connecting It With Your MIDI Controller
The final step of our Instructable is to run Fluidsynth connected with your MIDI controller.
The first thing we need is to have Fluidsynth running with the desired SoundFont. To launch Fluidsynth, execute the same command we used on the previous step, removing the .midi filename from it. Note that the -g 3 parameter is to set the gain of the SoundFont, so if the volume is to high or too low, tune it there. The command line will be something like this:
#fluidsynth -a alsa -g 3 FluidR3_GM.sf2
Now comes the tricky part.
Now you probably have the Fluidsynth shell in front of you, and if you quit it, you close the software. The idea here is to send Fluidsynth to the background, configure the MIDI connections and run it on the foreground again. You can imagine that as if we minimize Fluidsynth window, open a window to configure audio connections, and maximize Fluidsynth again.
To send Fluidsynth to background, simply press Ctrl+Z. You should see your Linux prompt back again (but the software still running on the background).
To connect Fluidsynth to your MIDI controller, run the alsa utility aconnect. First we will list all MIDI ports and later connect your MIDI keyboard output as a Fluidsynth input. To list all available MIDI ports, run the following command:
The output will be something like this:
client 20: 'UMA25S' [type=kernel] 0 'UMA25S MIDI 1 ' client 128: 'FLUID Synth (348)' [type=user] 0 'Synth input port (348:0)'
Please take note of the two client numbers (on this case 20 and 128), and also the port numbers (0 for my controller output and 0 for Fluidsynth input).
Now we connect both, using the command:
#aconnect 20:0 128:0
You should be back on the Linux prompt again, so now it is time to bring Fluidsynth shell back to the foreground with the command:
Check your keyboard, and if everything went fine, have fun !
The Fluidsynth shell can be used to set several things on the software, from the SoundFont used up to effects such as reverb and chorus, so please check the software documentation to learn how to do the stuff you need.
I really think that the easiest way to change SoundFonts is quitting Fluidsynth (just type quit and press the Enter key on the software's shell), and run the command line again using other SoundFont file. After that you`ll need to reconnect the software with the MIDI controller, as we did on the steps above, so in a nutshell, quit the software and repeat everything on this step using another SoundFont filename :)
If anything goes wrong or if your audio card stop responding, simply reboot your Edison board using the reboot command.