It is extremely easy to get a tiny little keyboard to generate melody in your Linux box. In fact, you can play hundreds of instruments. Here’s how I did it in my Fedora Core 6 and 7 laptops:
Software:
- timidity++ - This can turn MIDI into audio (A synthesizer).
- vkeybd - A virtual keyboard for your X desktop.
To install in Fedora Core 6, just type the following command:
$ yum -y install timidity++ vkeybd
Play:
- Start timidity (and connect to ALSA) :
$ timidity -iA
In Fedora 7, you can try 'timidity -iA -Os'. Or else, 'esd' in another terminal before 'timidity -iA' also worked for me.
- Start vkeybd:
$ vkeybd
- Join the keyboard output and the synthesizer input together:
Identify the correct client and port numbers of the keyboard and the synthesizer:
$ cat /proc/asound/seq/clients
The following is the output in my laptop:Client info
cur clients : 5
peak clients : 5
max clients : 192Client 0 : “System” [Kernel]
Port 0 : “Timer” (Rwe-)
Port 1 : “Announce” (R-e-)
Connecting To: 15:0
Client 14 : “Midi Through” [Kernel]
Port 0 : “Midi Through Port-0″ (RWe-)
Client 15 : “OSS sequencer” [Kernel]
Port 0 : “Receiver” (-we-)
Connected From: 0:1
Client 128 : “TiMidity” [User]
Port 0 : “TiMidity port 0″ (-We-)
Port 1 : “TiMidity port 1″ (-We-)
Port 2 : “TiMidity port 2″ (-We-)
Port 3 : “TiMidity port 3″ (-We-)
Output pool :
Pool size : 500
Cells in use : 0
Peak cells in use : 0
Alloc success : 0
Alloc failures : 0
Input pool :
Pool size : 1000
Cells in use : 0
Peak cells in use : 0
Alloc success : 0
Alloc failures : 0
Client 129 : “Virtual Keyboard” [User]
Port 0 : “Virtual Keyboard” (R-e-)
Output pool :
Pool size : 500
Cells in use : 0
Peak cells in use : 0
Alloc success : 0
Alloc failures : 0This reveals that I can join the keyboard with the synthesizer by issuing the following command with the correct addresses used as arguments to aconnect and in correct order (MIDI source first, then the sink):
$ aconnect 129:0 128:0
Now you can play. To change the instrument, see the Virtual Keyboard options (View->Program List). If required, increase the volume by using timidity option ‘-An’ (e.g.: $ timidity -A300 -iA).
timidity and vkeybd have many options to get different behaviors. See the manual pages for details.
Instead of timidity, you can use fluidsynth (but eats lots of cpu cycles). Instead of vkeybd, you can connect an external MIDI keyboard to the computer and make sound through timidity by providing the correct arguments to aconnect in the same way.
If you like complexity for reason, professional sound manipulation programs like Jack and/or Rosegarden can also be incorporated into the picture. In whatever the scenario, vkeybd and timidity will prove to be useful.
Enjoy!