Recording Audio from JACK-Enabled Applications in Ardour
by
A. J. (Tony) Schiavone
The Jack Audio Connection Kit (JACK) provides a method for JACK-enabled Linux applications to share audio data. Some of the growing number of applications that are currently JACK-enabled include Alsaplayer (an audio player that uses the Linux ALSA sound interface), MusE (a MIDI sequencer with softsynth support) and Ardour (a multi-track digitial audio recorder and workstation). This tutorial describes the method for using Ardour to record audio output from external applications such as Alsaplayer and MusE.
Start Up JACK:
For any of this to work, JACK has to be running. As root, use the following command to start it:
jackd -R -d alsa -d hw:0 -r 44100 -p 1024 -n 2 &
This sets JACK in real-time mode using the ALSA audio interface and your first sound card. The -r, -p, and -n options are for output frequency (sample rate), number of frames per period, and number of periods per hardware buffer and can be set accordingly depending on your audio card's capabilities and the latency response you require. Once JACK is running (and for some people this may take two tries as sometimes JACK doesn't want to start the first time) the next step is to set up an output device.
Alsaplayer to Ardour:
Alsaplayer is the simpler of the two programs we want to get working with Ardour so we'll start with it. As root, bring up Alsaplayer by issuing the following command:
alsaplayer -o jack
This starts Alsaplayer with JACK as the default output. The Alsaplayer GUI will come up. Load your favorite MP3 or WAV file. The only other step is hitting the play button, but we'll do that once Ardour is set up for recording Alsaplayer's output.
Leave Alsaplayer for now and start Ardour as root by just typing 'ardour &' at the command prompt. Add two diskstreams with mixer strips. Select the Recorder window from the Windows pulldown menu and set inputs 1 and 2 to the outputs from Alsaplayer. Notice the tab for Alsaplayer is now shown since Alsaplayer is running as a JACK-enabled client. Next, record enable the inputs and hit Record and Play.
An alternative is to set up the outputs for Alsaplayer when you start it up. This is useful if you don't want the signal to be routed directly into alsa_pcm:out_1 and alsa_pcm:out_2. This way you only get output for Alsaplayer if you enable it in Ardour.
Once you have a route in an ardour session
alsaplayer -o jack -d "ardour:Audio 1/in","ardour:Audio 1/in"
Will connect the stereo signal from alsaplayer directly to Ardours first route input.
You can use "jack_lsp" to get a list of the available JACK ports.
Finally, press the play control on the Alsaplayer GUI and your Alsaplayer output will be recorded to the two diskstreams you created.
MusE to Ardour:
Now that MusE is JACK-enabled, a method for using MusE's MIDI and softsynth capabilities with Ardour is available. This provides the ability to record MusE MIDI tracks to Ardour audio tracks and to provide a real-time MIDI keyboard/softsynth input to Ardour.
The method for using Ardour to record MusE output is almost identical to the one used for Alsaplayer. However, MusE requires a few extra steps to set up the softsynth. First, compile MusE with the following command (note, MusE takes a long time to compile): configure --prefix=/usr –enable-suid-install --with-jack –with-iiwusynth This statement sets the base directory where MusE is to be installed to /usr, enables suid-install, and compiles MusE with JACK and softsynth support. Next, as root start MusE using the following command: muse -R & This tells MusE to use real-time mode. You now have two options: recording a MIDI file in Ardour or recording a live MIDI keyboard in Ardour. MusE MIDI File to Ardour: Import your favorite MIDI file into MusE.
Go to the Config dropdown menu and select iiwu for the softsynth by highlighting the Soft Synthesizer on the left and hitting the Add Instance button. Next, select Config Midi Ports and make sure that iiwu is used as its output.
Leave MusE for now and start Ardour as root by just typing ardour & at the command prompt. Add two diskstreams with mixer strips. Select the Recorder window from the Windows pulldown menu and set inputs 1 and 2 to the outputs from Alsaplayer. Notice the tab for MusE is now shown since MusE is running as a JACK-enabled client. Next, record enable the inputs and hit Record and Play. Real-time MIDI Keyboard from MusE to Ardour: Recording realtime MIDI keyboard input from MusE to Ardour is similar to recording a MIDI file. You bring up MusE and set up the softsynth the same as in the MIDI section above. But instead of loading a MIDI file, you create a track, select a patch, and record enable the track. Once you record enable a track you should hear the softsynth play when you hit a key on your MIDI keyboard. You then set up Ardour the same way as above and record to your heart's content. Conclusion: JACK provides a powerful method for allowing JACK-enabled applications to share audio data. This simple tutorial only scratches the surface of what JACK adds to the Linux audio environment. Now that MusE is JACK-enabled, using it and Ardour provides Linux with full-blown MIDI and digital audio workstation capability. However, bear in mind that these programs, as well as JACK, are in heavy development and you may encounter random crashes and some weird behaviors. Some problems you may run into when trying this out include: 1) As I mentioned above, sometimes JACK doesn't like to start on the first try. However, it usually starts the second time you issue the command. 2) Ardour may time out with JACK. This usually happens to me if I start Ardour first before setting up the output program. It may be entirely dependent on my setup since I have xrun problems when using any JACK-enabled application. When this happens you must stop and restart all JACK-enabled applications. 3) MusE occasionally crashes on me. Again, it may be my setup, but make sure you save frequently.