Turning QWERTY Into Music

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:

  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

Play:

  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.

Enjoy!

Comments

It was in Linux Journal Weekly Newsletter!

I submitted this to Linux Journal and they published it in their August 1st issue of the weekly newsletter!

I am waiting for the T-shirt!

Isn't this wonderful?

After installation, when I

After installation, when I try timidity following error will occur

[root@elib dulina]# timidity -iA
esd: No such file or directory
Couldn't open Enlightened sound daemon (`e')
[root@elib dulina]#

[root@elib dulina]# cat /proc/asound/seq/clients
Client info
cur clients : 3
peak clients : 3
max clients : 192

Client 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
[root@elib dulina]#

Fedora 7?

Hi Ekanayake,

There are at least two ways to resolve this:

1. To specify ALSA output mode, add another option to timidity. Execute 'timidity -iA -Os' instead of 'timidity -iA'. Note the case of the letters.

2. Get a terminal and just type 'esd'. Then run 'timitidy -iA' in another terminal. This worked in Fedora 7.

I have updated the above blog entry with this information.

Regards,
Kamal

 

coool. I read it.

coool. I read it.

Timidity

I just downloaded a new SOundFont (.sf2) that I want to use it to replace the current fonts in Timidity. What do I have to do to make the new SoundFont file work with Timidity?

timidity.cfg file to help

Hi Randy,

'man timidity.cfg' gives you the exact details. Either you can edit the default timidity configuration file (/etc/timidity.cfg) or create a new config file and use -c option of timidity to load the new file as well. As said in 'man timidity', you can also invoke timidity with -x option and provide configuration strings directly. For example, the following command can simply be used (Note that if the file name doesn't include spaces, you don't have to use double quotes):

timidity -iA -x'soundfont "HS Strings.sf2"'

A great source of soundfonts is HammerSound (http://www.hammersound.net/).

Kamal

 

Here's aa test

Here's aa test

Thanks

Hi kamal,
Well brother, your idea worked fine with my fedora 7 box.
Thanks a lot...

Tharaka

Great!

Good to here that it worked and you are happy with it!

Regards,
Kamal

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.