Gentoo Wiki




Musicians nowadays use computers to compose their songs. Linux has had tools for creating music for quite some time, but not every part of setting up a working musician's studio seems to be obvious. This tutorial will try to help you setting up a music studio ready for mixing, effects processing and composing of music.

The keyword in linux music studios is jackd. jackd (part of media-sound/jack-audio-connection-kit) is a server which aims to virtualize the world of jack connections. In practice, it provides you low-latency interfaces to audio hardware and software. jackd is a server to which clients (both audio-in and audio-out) connect to exchange their sounds. jackd then sends sounds to alsa's drivers as needed to actually get you some music.

Note: Yes, directly to alsa's drivers. You could also theoretically use dmix, but that'd defeat the point of jackd. For those interested, append -d dmix or whatever your alsa dmix device is to the jackd commands.

Of course, we'll also need some audio software (just a virtual jack plugging device doesn't suffice ;-)). For example, Rosegarden, Ardour and vkeybd could be useful. If your audio card lacks a midi device, we'll need to add some timidity magic. A little bit of kernel configuration will probably be mandatory.


Your everyday user is called john, and he's in the audio group. ALSA works and is compiled into the kernel. You have followed the official gentoo realtime guide and user john has those discussed realtime capabilities. Your ALSA configuration is in /etc/asound.conf (as opposed to ~/.asoundrc).


Configuring your kernel

There's not a lot to configure about your kernel, except for the discussed realtime capabilities and your midi hardware devices, if you have any. For example, a piano keyboard which is connected to your computer is a midi device. If you don't know, you can probably skip this step.

If your midi device is a USB device:

Linux Kernel Configuration: USB Midi device configuration
Device Drivers  --->
    [*] USB support  --->
    Sound  --->
        Advanced Linux Sound Architecture  --->
            <M> Advanced Linux Sound Architecture #module or compiled into your kernel, i don't care, as long as it's usable.
            USB devices  --->
                <M> USB Audio/MIDI driver #again, i don't care how you build it, as long as you can use it.

If your midi device is not a usb device and has a normal midi connector:

Linux Kernel Configuration: Analog Midi device configuration
Device Drivers  --->
    #Something should be configured here, but I don't have a friggen idea what.
FIXME: normal midi device kernel config
Note: If you don't know whether you should build these options as modules or into your kernel, just build them into your kernel, that's the easiest solution.

If you have a MIDI hardware device, you should now be able to use it. Rosegarden (will be discussed later) will automagically recognize it, but you may have to connect it to Rosegarden in qjackctl.

Giving the right users the right permissions

You will need to get some special realtime permissions to get better performance out of jack. We'll be using PAM (Pluggable Authentication Modules) to specify what we need, and make a new group for the users needing good jack timings and latencies. Let's start with emerging pam, if you don't already have it:

# emerge -av sys-libs/pam

Now place the following content in /etc/security/limits.conf:

File: /etc/security/limits.conf
 @realtime       -       rtprio          99
 @realtime       -       nice            -10
 @realtime       -       memlock         unlimited

Add a group for our realtime users:

# groupadd realtime

And add our user john to this group:

# gpasswd -a john realtime

Relogin and you're done!

Installing jack

Installing jack is quite easy:

# emerge -av media-sound/jack-audio-connection-kit

For those who like GUIs, consider installing qjackctl:

# emerge -av media-sound/qjackctl

Please make sure you have the jack USE flag enabled globally, unless you know what you're doing (and are being an optimization *ss)

Installing alsa plugins

For jack to work, we'll need media-plugins/alsa-plugins to be installed.

Note: Please check again that the jack USE flag is enabled!
# emerge -av media-plugins/alsa-plugins

Installing editing software

There is tons of software for doing audio work in linux, much of it in Portage. Below is a shortlist of things generally considered good.

NameDescriptionCompare withOverlay
ArdourVery powerful hard disk multi-track recording softwareProtools
AudacityEasy-to-use audio editor and recorder
CsoundAudio programming language with a bajillion opcodesSuperColliderpro-audio
HydrogenLinux advanced drum machine
Jack-rackEffects rack that works over JACK
JaminReal-time jack audio mastering
LilypondThe stand-out sheet music typesetterFinale, Sibelus
MeterbridgeJack meter app using SDL
RosegardenMIDI sequencer with a gentler learning curve
Sox"The swiss army knife of sound processing programs"

Note that much of this software in portage has a other versions in the overlay (including a number of live ebuilds for those that like to live on the edge).

FIXME: Find more useful apps.

Setting up ALSA

We'll need to add a small section for ALSA clients to connect to jackd:

File: /etc/asound.conf
pcm.jackplug {
    type plug
    slave { pcm "jack" }

pcm.jack {
    type jack
    playback_ports {
        0 alsa_pcm:playback_1
        1 alsa_pcm:playback_2
    capture_ports {
        0 alsa_pcm:capture_1
        1 alsa_pcm:capture_2

There's no need to restart ALSA, this file is read at play time (if you like to restart stuff though, this is your party!).

Starting jackd

Option 1: starting jackd manually

Obviously, what we want is a setup in which we only need to start one application to launch the entire studio, but for troubleshooting purposes we will first try to launch on a per-program basis.

$ jackd -R -d alsa

If you can't start jackd, please make sure no application is currently using ALSA, as jackd will, depending on whether you have hardware mixing (if you do you're lucky!), want exclusive access to your ALSA hardware device.

Option 2: Getting a bit of magic from QjackCtl

You can also get a helping hand from QjackCtl. Find it in your start menu or launch it from the terminal:

$ qjackctl

And simply press the play button.

Starting Rosegarden

Now, we're basically done with configuring our setup. If you are using gnome, you can find Rosegarden in Applications->Sound & Video->Rosegarden.

FIXME: Where can this be found in KDE/XFCE/anything?

Of course, you can also simply start rosegarden from your terminal:

$ rosegarden

Does everything work all right? You'll probably get messages about XML-Twig missing, as well as KDialog. Those packages are needed for certain exporting features. If you want those, feel free to emerge them:

# emerge -av dev-perl/XML-Twig kde-base/KDialog

Now that Rosegarden itself works, you might already be there. If you only want to compose music, and have hardware with everything you need, you should basically be done now. However, if you don't have midi hardware, for example, you'll need some software emulation of that. Keep on reading.

Virtual MIDI output

You will not need timidity if you have an audio device which can play midi. However, most audio hardware doesn't and therefore you probably need timidity. If you don't you can skip this step. For virtual MIDI output, we'll use timidity++. There's an official guide about this, but that's only useful when you don't use jack. We DO use jack, so we'll need a different approach. Get started by emerging timidity++

# emerge media-sound/timidity++

Normally, timidity++ is used to play one midi file. However, we want to use it as a kind of daemon. To do this, simply run (with jackd running!):

$ timidity -iA -Oj -B2,8

Yep, that's it. Virtual MIDI output should be setup for you now. If you have a global ALSA timidity daemon running as well, please make sure to select the right one in rosegarden.

Virtual MIDI Piano

If you don't have a real MIDI piano (it's a real pleasure if you're serious about music composing), you can use media-sound/vkeybd instead.

# emerge -av vkeybd

If you're using Gnome, you can now find vkeybd in Applications->Sound & Video->vkeybd. Make sure jackd is running before launching vkeybd. Controlling vkeybd isn't unusual, but it's not obvious either. It assumes that you are using the qwerty keyboard layout. Check its man page for more information (man vkeybd).

FIXME: Where can this be found in KDE/XFCE/anything?

Starting the entire studio at once

Make a new file called musicstudio wherever you want in your normal user's home directory (I chose to install it in ~/bin/). In it, put the following:

File: ~/bin/musicstudio
jackd -R -d alsa & #or you can make qjackctl start jackd, of course.
sleep 1 #it takes a little bit of time to start jackd
timidity -iA -Oj -B2,8 #comment out if not needed
vkeybd & #same as for timidity
rosegarden & #i guess you'll need this, unless you don't want to compose melodies
qjackctl & #might be interesting to check everything's in place. no need to launch this if you already have it on line 1
echo "Happy composing, my friendly musician!"

Now make it executable:

$ chmod a+x ~/bin/musicstudio

And of course, try it!

$ ~/bin/musicstudio
Retrieved from ""

Last modified: Sat, 11 Oct 2008 23:02:00 +0000 Hits: 2,523