oreilly.comSafari Books Online.Conferences.


Linux Audio Plug-Ins: A Look Into LADSPA
Pages: 1, 2, 3, 4


Alexander König describes his terminatorX as "a real-time audio synthesizer that allows you to 'scratch' on digitally sampled audio data the way hiphop DJs scratch on vinyl records." Featuring multiple turntables, real-time effects, a sequencer, and a Gtk+ GUI, TerminatorX provides graphic controls for its own lowpass filter, echo, pitch, and pan settings. It also supplies the same sort of controls for LADSPA plug-ins.

Figure 4 shows terminatorX in its start-up state. In the control panel at the left of the display (the virtual turntable) you see a strip of controls for the built-in effects, plus a button labelled FX. Pressing that button will call a menu of the permissible LADSPA plug-ins (terminatorX currently supports only mono plug-ins), and selecting a plug-in will create a set of controls for it directly beneath the built-in effects controls. Note that multiple plug-ins can be installed per turntable.

terminatorX sets up virtual turntables for looping sound files and assigns various functions to the left-right/up-down movements of the mouse over a selected turntable's display. The mouse's virtual scratching then controls the sound's speed, volume, and pitch, as well as the parameters for the lowpass filter and the echo effect. Figure 5 shows a single turntable with a sound file loaded, the built-in effects minimized, and the delay_5s LADSPA plug-in installed and enabled.

You can create some very interesting sounds by combining the built-in effects with LADSPA plug-ins. In Figure 6 I've set up three turntables, assigned various functions to the mouse movements, and added a LADSPA plug-in for each turntable. This arrangement made for some wild sounds, and it must be noted that terminatorX handled the complexity without a hitch. Of course, running a Linux kernel patched for low-latency doesn't hurt performance.

As with Snd and ecasound, terminatorX is worthy of much deeper exploration. I highly recommend it to anyone interested in Linux audio applications: After all, there's a little Linux DJ in all of us, right?

Making a plug-in with GDAM

By this point we've taken a good look at LADSPA. You've met the API, analyzed a typical plug-in's C code, and installed a plug-in collection or two. We've seen how different hosts manage, present, and apply LADSPA plug-ins. Now let's write one of our own.

Did I hear you say that you're not an audio software programmer, or any kind of programmer at all? Or that you have no degrees in advanced mathematics and digital signal processing? Well, the authors of GDAM have provided just the thing for budding plug-in builders with other skillsets.

Programmers David Benson and Geoff Matters have created a graphic LADSPA plug-in designer called mininet. The mininet tool is part of Dave and Geoff's GDAM, a powerful DJ-style audio mixer and signal processor. It would be easy to spend the next few hours exploring GDAM's features, but for now we'll focus on its support for LADSPA.

As an audio processor, GDAM is a natural candidate as a LADSPA-friendly host. On startup GDAM looks in the default LADSPA_PATH and automatically loads the plug-ins it finds there. Those plug-ins are then available for use within GDAM's various players and processors.

GDAM's player windows include a strip of icons and buttons representing the native and LADSPA plug-in effects. The mininet utility is the next-to-last icon before the buttons [Figure 7]. This tool lets you connect various nodes together to create a signal processing path. The audio input and output nodes are hard-wired into the network, and it is not possible to add to or remove them. The other nodes can be signal modifiers such as delay lines and ring modulators, signal generators such as the noise and wavetable nodes, or signal mixing and balancing nodes. Any number of those nodes may be added or deleted from a network. Clicking on some nodes will open a set of parameter controls, others have fixed functions with no user-definable controls available. When you have arranged the nodes in the patterns you want, the mini-network is saved as a simple XML file. Finally, an external utility (ladspapluginmaker) converts the XML specifications into a C program (foo.c) and its associated header (foo.h) then directly compiles the C program into the new LADSPA plug-in object (

Figure 8 illustrates a simple network designed to apply a fixed delay of 1 second to an input signal and send the delayed and original signals to the output. The delay node was added by left-clicking on the Delay button to the right of the workspace, then left-clicking again in the workspace to drop it there. Connections are made by dragging wires from outputs to inputs. Wires can be freely added and deleted, and as you can see in our example, a single input or output port accepts multiple connections.

Our simple example takes a single parameter value, the fixed amount of delay time applied to the input. The other nodes take no user-supplied values. After setting the delay time, all that's left to do here is press the Save button, name our new XML file, and save it. Next, open an xterm window, move to the directory where we saved the fixed_delay.xml file (you may want to create a directory just for your mininet XML files), and call ladspapluginmaker with the following command line:

ladspapluginmaker --input fixed_delay.xml 
    --output dp_fixed_delay_dir \
    --basename dp_fixed_delay --class FixedDelay \
    --description "1s Fixed Delay" --unique-id 100 \

Now we have a new directory named dp_fixed_delay_dir that contains dp_fixed_delay.c, dp_fixed_delay.h, and Copy the shared object file to your LADSPA_PATH directory and it's ready for use by your favorite LADSPA-friendly hosts. Incidentally, you can create only the C files by leaving off the --build option. All other options shown are mandatory.

The analyseplugin utility tells us these facts about our plug-in masterpiece:

[dlphilp@localhost gdam-0.933]$ analyseplugin

Plugin Name: "1s Fixed Delay"
Plugin Label: "FixedDelay"
Plugin Unique ID: 100
Maker: "gdam ladspa plugin maker"
Copyright: "None"
Must Run Real-Time: No
Has activate() Function: Yes
Has deativate() Function: No
Has run_adding() Function: No
Environment: Normal
Ports:  "Input" input, audio
        "Output" output, audio

I plugged this effect into the virtual rack in Reiner Klenk's neat ladspaToy [Figure 9], ran a WAV file through it, and the plug-in worked perfectly. Far more complex networks can be created with the mininet tool, but I must leave that study as an exercise for the interested reader.

Recent LADSPA development issues

The LAD mailing list is the principal forum for the presentation and discussion of LADSPA development issues. Recent LADSPA-specific traffic has discussed issues concerning the possibility of non-sequential actions in a plug-in (for reverse or varispeed operations), the use of run_adding() versus run() in buffer scaling operations, the limitations of the HARD_RT_CAPABLE flag, and the use of LADSPA hints.

In the first section of this article, I mentioned the popularity of the Steinberg VST plug-in architecture on the Windows and Mac platforms. It has been pointed out that at least part of VST's success is due to the availability of a standard GUI tool kit on each of those platforms, simplifying the provision of hooks into the native graphic interface. Given the free availability of Motif, GTK, Qt, and other powerful Linux GUI toolkits, matters regarding graphic interfaces are more complicated for LADSPA developers.

The prospect of rewriting plug-ins to accommodate different tool kits defeats the purpose of the API. However, the use of XML as a descriptive medium has been discussed by LADSPA developers, and Paul Davis has proposed an XML DTD (document type definition) for approval by members of the LAD group. The discussions can be read in the LAD mailing list archives; Paul's DTD proposal can be read here.

Other Linux audio plug-in APIs

LADSPA is not the only player in the Linux audio plug-in world. The aRts project and David Olofson's MAIA are friendly competitors developing a more professional (i.e., more complex) audio plug-in API for Linux.

MAIA's developer has stated that his intention is to create an advanced Linux audio API equivalent to and surpassing the capabilities of the VST2 specification (an expansion of the original Steinberg VST API). However, at this time MAIA is still under heavy development; preliminary specifications may be read in the event.h file of the currently available software.

aRts is already well-known as the sound server for KDE2, but developer Stefan Westerfeld points out that the aRts plug-in API is a truly generalized interface independent of KDE. It must be noted though that aRts does depend upon another layer of abstraction (MCOP, the Multimedia Communications Protocol), and its success with plug-in writers remains to be seen.

Pulling the plug...

LADSPA has proven itself successful at implementing a simple and useful specification for Linux audio plug-ins, and the API continues to evolve. An excellent selection of LADSPA-based software already exists, more friendly hosts are on the way, and the simplicity of the API should promote development of new plug-in collections. I encourage developers to consider adding LADSPA support to their Linux audio software: As we have seen, the API is indeed a simple plug-in specification, easily implemented, and capable of real power and flexibility (see especially Steve Harris's Hermes Filter and Jezar's Freeverb3).

Fortunately there's no need for me to wait for all those new plug-ins: I'm heading off to a session with GDAM's mininet to build a collection of my own. You know, given that all the Linux software mentioned in this article is free and open-source, you could quickly be building yours too.

(And please, notify me if you do write any cool new plug-ins or a LADSPA-friendly host. I'll be happy to announce and list your software on the Linux Music & Sound Applications web site.)

LADSPA resources list

Other indispensable Linux audio resources

Dave Phillips maintains the Linux Music & Sound Applications Web site and has been a performing musician for more than 30 years.

Sponsored by: