Part One: Getting Started

Thursday 18 April 2013, 12:40pm BST

This is the first in a series of articles that aim to provide some guidance on how to get started making use of the Professional Audio tools and capabilities of a Fedora system. This article covers playing notes using the JACK audio server, the ZynAddSubFX software synthesiser, and a virtual MIDI keyboard controller.

Introduction

In the last few years Linux has made great strides forward in the provision of professional applications for the creation, manipulation, and recording of audio and music. It is now possible to create a professional level Digital Audio Workstation (DAW) using only Free Software. For a number of years audio applications for Red Hat Linux and Fedora have been packaged by Fernando Lopez-Lezcano in the Planet CCRMA repository, recently a Fedora SIG has been created for audio, along with a mailing list. This has led to a number of audio packages appearing in the Fedora repositories and a growing cooperation with Fernando regarding the future direction of audio package creation and distribution.

With the addition of applications such as JACK, ZynAddSubFX, and Rosegarden, to Fedora, it is now possible to convert a standard Fedora Workstation install into a full-blown DAW using only a single YUM command. An unfortunate downside is that many of these applications have slow or stopped development, little documentation, and the mailing lists and forums are quiet. These articles are an attempt to document my experiences in starting to use audio applications on Fedora to create music.

In the last few months there has been a reorganisation of one of the main Linux Audio websites which now supports a number of active mailing lists for users of audio applications, including the linux-audio-users list, you can also view the list archives. There are corresponding announcement and developer lists available as well.

Jack Audio Connection Kit

The Jack Audio Connection Kit (JACK) is the core of any professional audio system on Linux. The best description of the role JACK plays comes from the JACK FAQ:

JACK is a system for sending audio between applications as well as allowing them to all share an audio interface. Each application is run in exact sample sync with each other, and the entire system is designed to run at very low latencies (as low as your hardware will allow).

From a users perspective JACK is a server that runs the background that your audio applications interact with to move sounds around the system in a timely manner. JACK can be run from the command-line, but this is not very friendly for the users of modern of graphical desktops. A better method for users to interact with JACK is by using the Qjackctl tool. This tools provides a graphical user interface for controlling the JACK server.

Installation

To install JACK and Qjackctl you can use the YUM command:

[root@fedora ~]# yum install qjackctl

The magic of the YUM dependency solver will take care of installing all of the packages that Qjackctl requires including JACK itself.

To achieve its low latency aims, and to obtain audio of the highest quality, JACK needs to run with near real-time privileges. It is possible for applications running with realtime privileges to crash the system or starve other users of resources. To prevent this from happening Linux has a security mechanism in place to limit which applications can run with these privileges. To enable your user to run JACK with realtime privieges you need to add your username to the jackuser group. You can do this by running the User Manager tool from the menu System -> Administration -> Users and Groups menu. After you have made these changes you will need to log out and then log back in before they will take effect.

Running Qjackctl

To start Qjackctl simply select it from the desktop menu: Applications -> Sound & Video -> Qjackctl. The application opens with a window that looks like this:

Qjackctl JACK stopped screenshot

Qjackctl after start up before JACK has been started.

The various button functions should be quite obvious:

Qjackctl start button Starts the JACK server
Qjackctl stop button Stops the JACK server
Qjackctl messages button Opens a window displaying messages from the JACK server
Qjackctl status button Opens a window with the status of the JACK server
Qjackctl connect button Opens a window showing audio and MIDI connections
Qjackctl patchbay button I don't know what this does...
Qjackctl quit button Quits Qjackctl, prompts to stop the JACK server as well
Qjackctl setup button Opens the JACK server configuration window
Qjackctl about button Opens the Qjackctl about window
Qjackctl control buttons Controls the JACK Transport. This is a method of synchonising different applications that are using JACK

If you are following along with this article, go ahead and click the Start Button now. Qjackctl should change to look something like this screen shot:

Qjackctl JACK started screenshot

Qjackctl once the JACK server has been started.

You should notice that the Stop Button is no longer greyed out, the LCD style screen has come to life, and some of the Control Buttons are no longer greyed out.

A final point before we move on to actually making some sounds. The use of the JACK server is all about reducing the latencies experienced by audio as it passes through your system. You can tune the JACK server to reduce latencies as much as possible by clicking on the Setup Button which will open a window that looks like this:

Qjackctl JACK setup window screenshot

Qjackctl setup window

In the bottom right corner of this screen is a box showing the latency (5.33 msec in my screen shot) that the system is operating at, by changing values on this screen you can cause the latency value to increase or decrease, lower values are better. Beware that if you aim for too low a value you will get XRUNS. These occur when your system is unable to keep up the with latency you have requested and may cause sound drop outs and other glitches. XRUNS are displayed in the LCD part of the Qjackctl GUI:

Qjackctl showing XRUNS

Qjackctl showing XRUNS (the red numbers)

Qjackctl showing no XRUNS

Qjackctl showing no XRUNS (numbers are all green)

Now that JACK is up and running we are ready to produce some audio through the system.

Making some noise

To make some noise with our system we need a sound source. There are number of applications available to act as sound sources in Fedora Distribution. I have chosen ZynAddSubFX, a software sound synthesis application that provides a simple beginners interface that can be quickly used to produce sounds.

Installing ZynAddSubFX

As with installing JACK we can use the YUM command to install ZynAddSubFX and any required dependencies:

[root@fedora ~]# yum install zynaddsubfx

After the install has finished you should see a new entry in the menus (Applications -> Sound & Video -> ZynAddSubFX) that will start the application. If you try to launch ZynAddSubFX and nothing happens then check, using Qjackctl, that the JACK server is running. Unfortunately most applications that use JACK fail silently if they cannot connect to the JACK server.

If you try to run ZynAddSubFX from the command-line. without a JACK server running, this is the output you should expect:

[user@fedora ~]$ zynaddsubfx
lash_open_socket: could not look up host 'localhost': Servname not supported for ai_socktype
lash_open_socket: could not connect to host 'localhost', service '14541'
lash_comm_connect_to_server: could not create server connection
lash_init: could not connect to server 'localhost' - disabling LASH
lash_init: LASH_START_SERVER unset, not attempting to start server automatically

ZynAddSubFX - Copyright (c) 2002-2005 Nasca Octavian Paul
Compiled: Sep 3 2006 01:18:16
This program is free software (GNU GPL v.2) and
it comes with ABSOLUTELY NO WARRANTY.

Try 'zynaddsubfx --help' for command-line options.
Sound Buffer Size = 256 samples
Internal latency = 5.8 ms
ADsynth Oscil.Size = 512 samples

ERROR: Cannot make a jack client (possible reasons: JACK server is not running or jackd is launched by root and zynaddsubfx by another user.).

There are two things to note about the output. First, you can ignore the lines referring to LASH, the Linux Audio Session Handler, this is a system to save complex combinations of JACK applications as a session so that they can be easily restarted at a later date. Secondly, the last line is telling us that ZynAddSubFX cannot start because JACK is not running, or it is running under a different user ID. This is an important point, the JACK server and the applications using it must all be running as the same user, if you start JACK as root and then try to run an application such as ZynAddSubFX as yourself it will not work!

Running ZynAddSubFX

At this point go ahead and fix the problem with JACK, either using Qjackctl to start it up as discussed previously, or by starting JACK as the same user that you plan to use for ZynAddSubFX. Now try to start ZynAddSubFX again, you should see a window open asking you to choose which type of user interface you would like to use:

Choose a user interface type for ZynAddSubFX

Choose a user interface type for ZynAddSubFX

For the purposes of this article choose the Beginner option, I'll show you how to switch to the advanced option before we finish. You should now be looking at a window with a number of switches, dials. and other controls, as well as a piano style keyboard:

ZynAddSubFX simple window

The simple user interface for ZynAddSubFX

The window is divided into three sections, top to bottom. At the top, just below the menus are the switches and dials that control the sounds made by ZynAddSubFX. From here you can make all sorts of adjustments to the type of sounds created, the volume it is played at, and effects applied to it. Below these controls you will see a piano style keyboard, clicking on a key with the mouse will cause that note to be played. If you are impatient you will have done this already to see what happens, the answer is probably not a lot. When you clicked on a key you should have seen that in the final section of the window, at the bottom, is an audio meter measured in decibels. Clicking and holding a key on the piano keyboard should cause the meters to twitch, but most likely no sound was emitted from your sound card.

Connecting ZynAddSubFX to JACK

To understand why ZynAddSubFX is not producing any sounds we need to go back to JACK and examine the applications that are connected to the server. To do this click on the Connect Button in the Qjackctl window. This should open a window that looks something like:

Qjackctl audio connections window with the audio disconnected

The Qjackctl connections window showing the audio tab

Your window may look slightly different depending on how your sound card presents itself to JACK, indeed depending on how many sound cards you have in your system. The key point about this screen is that the tree of devices on the left represent audio sources and the tree of devices on the right represent audio sinks. By source I mean anything capable of generating audio within your computer, so you can see the stereo microphone inputs of my sound card listed as capture_1 and capture_2 under the alsa_pcm heading and the stereo outputs of ZynAddSubFX listed as out_1 and out_2 below the ZynAddSubFX heading. A sink is an object that can accept audio input and do something with it, so in the screen shot you can see the output devices provided by my sound card, playback_1 through playback_6 under the alsa_pcm heading.

From this window you can connect audio sources to audio sinks. You do this by clicking on the source object in the tree and the sink object in the tree, the Connect Button should now be active and clicking on it will connect the source to the sink. Below is a screen shot of the Connections Window once I have connected ZynAddSubFX to my sound cards outputs:

Qjackctl audio connectsion window with audio connected

The Qjackctl connections window showing the audio tab with connections

You can also disconnect audio connections by selecting the source and sink objects and clicking the Disconnect Button, or you can click the Disconnect All Button to remove all audio connections. Now that you have the audio connections in place you should be able to click on the piano keys in the ZynAddSubFX window and notes should be played by your sound card.

Troubleshooting

You have got this far and it is still not working? Here are some things you can try to isolate the problem:

  • Shutdown ZynAddSubFX, JACK, and Qjackctl, and then run the sound card configuration tool, from the menus: System -> Administration -> Soundcard Detection. You will need to enter the root password when prompted. This application should detect your sound card and allow you to play the demo sound. If you cannot hear the demo sound then the problem is with your sound card or with the amplifier, speakers, or headphones, that you have connected to your sound card.
  • Try running a non-JACK audio application such as Totem (Applications -> Sound & Video -> Movie Player) and playing an MP3 or OGG file.
  • Install the alsamixergui application and ensure that the ALSA output levels are set high enough for you to hear.
  • Try running the various applications from a terminal command line and look to see if they output anything that may help in diagnosing the problem.

There are a two places you can ask for help if you are still stuck: the linux-audio-users list and the fedora-list. If you are not used to asking questions on mailing lists then you might like to read How To Ask Questions The Smart Way by Eric Raymond before you post.

Adding MIDI Control

In todays world of professional audio electronic instruments, effects units, and recording devices, are connected together using a standard control mechanism called the Musical Instrument Digital Interface (MIDI). In addition to supporting audio, the ALSA project also supports MIDI. This means that it is possible to control multiple software applications, and even external devices, from a single application or device. To get you started using MIDI I will take you through installing, configuring, and using a virtual MIDI controller called Vkeybd to control ZynAddSubFX.

Installing Vkeybd

You can install this package by using the following YUM command:

[root@fedora ~]# yum install vkeybd

Configuring ZynAddSubFX

When we first started ZynAddSubFX we were asked if we wanted the Beginner or Advanced user interface. We selected the beginners interface because it gave us a simple keyboard that we could use to produce sounds. Now that we are adding a MIDI keyboard to control the production of sound we can switch to the advanced interface of ZynAddSubFX. To change the interface use the menu option: Misc -> Switch User Interface Mode, click yes to switch to advanced mode. Your window should now look like:

ZynAddSubFX advanced window

The advanced user interface for ZynAddSubFX

You can switch back to the simple interface at any time by using the Misc -> Switch User Interface Mode menu option. At this point you might want to check that the audio connections for ZynAddSubFX are still configured correctly in Qjackctl.

Running Vkeybd

Once installed you should be able to launch Vkeybd from the menu: Applications -> Sound & Video -> Vkeybd. The Vkeybd window looks like:

Vkeybd window

The Vkeybd window

VKeybd works in the same manner as the ZynAddSubFX keyboard - click the mouse on the piano keys to play a note. If you try this now it will not work. This is because we need to connect our MIDI devices together in the same way that we connected our audio devices. Go back to the Qjackctl window and click on the Connect Button again, in the connections window select the MIDI tab in the top left corner rather than the Audio tab. You should have a window that looks like this:

Qjackctl connections window, MIDI tab

The Qjackctl connections window showing the MIDI tab

The MIDI tab works the same way as the audio tab. On the left we have sources of MIDI events and on the right we have applications and devices that can consume MIDI events. We need to connect the Vkeybd MIDI event source to the ZynAddSubFX MIDI event sink, this is done by selecting the appropriate objects in the trees and clicking the Connect Button. You should then have a window that looks like:

Qjackctl connections window, MIDI tab

The Qjackctl connections window showing the MIDI tab with connections made

The disconnect function works in the same way as on the audio tab. Now that the MIDI connection has been made clicking the mouse on a key in the Vkeybd window should cause ZynAddSubFX to produce a note. As well as hearing the note from your sound card you should see the decibel level meters move in the ZynAddSubFX window.

Conclusion

Congratulations on making it this far! If you have been following along then you should now have a system where a software synthesiser, ZynAddSubFX, controlled by a virtual MIDI keyboard, Vkeybd, is playing notes through a low latency audio server, JACK, which is launched and configured using a simple graphical user interface, Qjackctl. Understanding this combination of components will provide you with the building blocks to create a complete Digital Audio Workstation using only Free Software provided by Fedora Core and Fedora Extras.

Other articles in this series will cover enhancing your audio system with a MIDI and audio sequencer, adding other software synthesisers as sound sources, adding a drum machine, and recording your audio.

Feedback on this, and other Fedora articles written by Keith Sharp, is always welcome. Please email any comments to <kms@passback.co.uk>.