Note: [Mar 23, 2017] This website was migrated to a new platform recently. Some linked content may not be accessible until all the links are configured properly,

Turning QWERTY Into Music

Submitted by Kamal Wickramanayake on February 15, 2007 - 07:00

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:


  1. timidity++ - This can turn MIDI into audio (A synthesizer).
  2. vkeybd - A virtual keyboard for your X desktop.

To install in Fedora Core 6, just type the following command:

$ yum -y install timidity++ vkeybd


  1. 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.

  2. Start vkeybd:

    $ vkeybd 

  3. 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 : 0

    This 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.