Jacking Pd and Ardour - a tootorial
written by Reiner Klenk
A typical audio application reads data from the soundcard input, does something to it, and plays it back over the soundcard outputs. Fine. But what if we want to use several different programs at the same time to mangle our audio data? Well, no problem, provided our programs support input/output via JACK. In the following we will demonstrate how Pure-Data (Pd) and Ardour can work together.
In addition to JACK and Ardour we need to build Pd with JACK support. Jackification of Pd is work in progress, several approaches are available. I started with Pd-0.35-0 which you can find here:
After unpacking the source I applied the patch mentioned in this message:
NB. This patch will only work with a version before jackd 0.40.0 - Please see the Pd mailing list and website for the latest JACK patches.
After patching, build and install Pd as usual. Later on we will use the plugin~ external to incorporate LADSPA plugins in our setup. Find the plugin~ here:
I have also provided a couple of patches to get you started quickly in Pd. Just copy and paste the text and save as the filename in the URL. An explanation of how to load them is included further down.
Start jackd, then Ardour. In Ardour, create a new session, add two diskstreams with mixerstrips and record something or import an audio file so that we have something to work with. Next, start Pd with the -jack option. List the ports that are now available in JACK:
[root@gin root]# jack_lsp alsa_pcm:in_1 alsa_pcm:in_2 alsa_pcm:out_1 alsa_pcm:out_2 ardour:auditioner/out 1 ardour:auditioner/out 2 ardour:Track 1/in ardour:Audio 2/out 1 PureData2256:input0 ardour:Audio 1/out 1 ardour:Track 2/in PureData2256:input1 PureData2256:output0 PureData2256:output1 [root@gin root]#
By default the Pd ports are connected to the ALSA ports which is not what we want here. Let's disconnect them:
[root@gin root]# jack_disconnect alsa_pcm:in_1 PureData2256:input0 engine sample rate: 48000 [root@gin root]# jack_disconnect alsa_pcm:in_2 PureData2256:input1 engine sample rate: 48000 [root@gin root]# jack_disconnect PureData2256:output0 alsa_pcm:out_1 engine sample rate: 48000 [root@gin root]# jack_disconnect PureData2256:output1 alsa_pcm:out_2 engine sample rate: 48000
Now we are going to pipe an audio stream from Ardour to Pd. Go to the mixer window, right-click in the black box above the left fader, select send. Ardour's connection editor will pop up. Click the out 1 button. The connection editor shows the available destination ports:
Select the PureData2256 tab, then click input0, click OK. In the same way, add a send to the right mixer strip, selecting PureData2256:input1 as destination. Activate the sends by clicking on them in the mixer window. Activation is indicated by colour change. The mixer strips now should look like this:
Within Pd, the audio send from Ardour is now available via the standard adc~ object. We can manipulate the data using any of Pd's objects, then feed the data to the dac~ object where it leaves Pd. In this example we will use a slightly modified example from the Pd documentation, the piano reverb patch. Load patch 1, (Go to the file menu and choose open), then activate audio processing in Pd. Activate transport in Ardour and you can see the level meters in the Pd window moving:
Now add a route in Ardour to receive the data from Pd. Go to the mixer window, press the input button of the new route, select edit. This will again pop-up the Ardour connection editor where you can now choose PureData:output0. We are now free to use the effect return stream within Ardour. To keep this example simple we will just route it to the soundcard outputs. Press the output button at the bottom of the third mixer strip, choose edit, assign alsa_pcm:out_1, add another outlet, connect it to alsa_pcm:out_2. The dry signal is now on faders 1 and 2, the effect is on fader 3 and can be positioned with the pan widget. Recording the combined signal is left as an exercise to the reader.
LADSPA plugins can be used directly in Ardour's channel strips. This is useful for simple layouts because we can then include them in Ardour automation. However, if you want to combine LADSPA directly with other Pd objects, or if you want to realise complex networks of LADSPA plugins, you can also host the plugins in Pd where you can wire them up in arbitrary fashion. Remember to set LADSPA_PATH in your environment, otherwise plugin~ will not be able to find the plugins. The following example has three outlets (start Pd with -outchannels 3), one for the reverberated signal, one for the output of the LADSPA multivoice chorus, and a third one where the signal passes first through the reverb, then through the chorus. You could then create three effect returns in Ardour to capture each of the streams. The patch looks like this:
Hints: use listplugins to find out which plugins are available on your system and what their names are. Sending a print command to the left inlet of plugin~ shows the control parameters and their value range. Note how parameters are set by control commands sent to the same inlet. Click and drag in the number boxes to change the parameters. The loadbang object is used to initialise plugin parameters when loading the patch. Using the -inchannels and -outchannels options for Pd you can create patches with many seperate inlets and outlets. You can use some channels for connection to Ardour, other channels could be hooked up to Freqtweak, Meterbridge, softsynths...
I sincerely appreciate the hard work of those who are making free audio processing tools a reality. I believe the introduction of JACK is a key feature because it allows us to do things the UNIX way: using, instead of one monolithic application, several independently developed programs and have them feed data to each other. It is currently a little bit more complicated than using the | symbol in the shell but it provides the same flexibility.