Experimenting Jack on Ubuntu Studio

UbuntuStudio has three basic parts, audio, video, and graphics. This is about UbuntuStudio-audio exclusively.

Ubuntu Studio comes with the Jack Audio Connection Kit which is designed for one thing only, quality tools for professionals in the music business. This is a powerful utility that sits on top of the hardware drivers and provides connection and control services and real time priority for jack aware applications whose demands are time critical like for live recording and performance. With it you can synchronize playback and recording across multiple jack aware applications. One common use is to sync ardour with rosegarden and hydrogen for easy playback/recording of multiple midi and audio sources at the same time on multiple tracks. Jack and jack applications are used in many environments, from garages and basements to high end studios that charge $100s per hour, from internet DJs wth tiny audiences to live performance with audiences in the thousands. Jack performs, jack delivers.

If you are using jackd and are not using UbuntuStudio you should at least install:
ubuntustudio-audio-plugins
jackd (the jack daemon)
qjackctl (Jack Control)
jackeq (Jack EQ)
jack-rack(effects rack)
jack-tools(command line tools)
patchage (patchbay)
linuxrt (real time kernel)

Getting UbuntuStudio
If you want a real recording setup just get the ubuntustudio-audio and ubuntustudio-audio-plugins metapackages available in the repositories, ubuntustudio-audio includes jack and the rt kernel and all kinds of audio production applications. (It is a big download, took about an hour on my dsl connection.)

Warning Ubuntu Studio for Intrepid 8.10 has some serious problems with the rt kernel, among them are no support for multiple core cpus. It is strongly recommended that Ubuntu Studio users stay with or install 8.04 Hardy until these issues are resolved though many users have reported no problems with using Intrepid for sound mixing and editing.

If you are installing the rt kernel and are using the ati or nvidia restricted drivers that you downloaded directly from ati or nvidia, it is highly recommended that you remove these drivers from your system and replace your etc/X11/xorg.conf with the original generic version. If you are not sure which file that is, copy the xorg.conf.failsafe file into xorg.conf. You can reinstall the driver after the rt kernel is working and should have no problems with it in Hardy or Intrepid. NOTE: The ati 9.1 driver build for Hardy is missing a patch for the rt kernel and so should be avoided by rt kernel users for now. There are scattered reports of similar issues with some nvidia drivers with certain nvidia cards. You can try these drivers, just be prepared to remove them and reinstall previous ones that worked.

If you are having basic jack setup problems, or you just want to know where to start:

http://en.wikipedia.org/wiki/JACK_Audio_Connection_Kit

If you are having trouble setting up jack in UbuntuStudio:

http://en.wikipedia.org/wiki/JACK_Audio_Connection_Kit

https://help.ubuntu.com/community/Ub…GettingStarted

http://hubpages.com/hub/Recording-in…io-Workstation

Excellent ardour tutorial here:

http://out-of-order.nfshost.com/tutorials/ardour/

If you are wondering how to sync applications together through jack:

https://help.ubuntu.com/community/Ho…CtlConnections

http://www.ubustu.com/globe/2007/09/…n-with-ardour/

http://www.rosegardenmusic.com/

Unlocking memory and setting priority for audio applications
UbuntuStudio in Intrepid and Jaunty now comes with an UnbuntuStudio settings manager to control these options but if you are using previous versions…
and you are getting memory limit or memory lock messages when running any audio application, try this:
Edit /etc/security/limits.conf and add or modify these lines

Code:
@audio - memlock unlimited
@audio - nice -10
@audio - rtprio 99

* The ‘memlock’ line determines the amount of memory available to users in the group “audio”.
* The ‘nice’ line, has to do with how long the processor will wait for processes queued from group “audio”.
* The ‘rtprio’ line assigns an extremely high priority to the group “audio”.

The nice and rtprio settings will basically give your audio top priority at the cpu which is a necessity for live work.

jack and Pulse Audio with more than one sound card
If you have more than one sound card, you can configure jack to use one of them exclusively with Jack Control and set Pulse Audio to use the other one In the Pulse Audio Volume Control. They should both work at the same time if they are using different hardware devices and when you close jack, Pulse Audio can use that card again. Make sure you do not have any application using the Pulse Audio sink for the sound card you configured jack to use or jack will not start.

Unless you are using professional quality sound cards that are made to share clocks, using two sound cards together can be problematic as their clocks/timing will drift apart. Pulse Audio, through the module combine can hold two cards in sync fairly well but some deviation is inevitable and glitches will occur as the clocks are periodically resynchronized. This is not a big problem with playback only but is not recommended for recording or live performance unless you have actually tested this with your hardware and are satisfied with it. I have not yet figured out how to get this to work with jack but it seems promising. If you have figured this out, please make a post.

Pulse Audio through jack
If you want to set up Pulse Audio to play through jack you can do so. This has been tested on Hardy 386, amd64 generic and Ubuntu Studio and on Intrepid 386, amd64 and Intrepid Studio ( it is from debian of course which is the base of Ubuntu).

First of all, you need to install the pulseaudio-module-jack from the debian lenny repository:

http://packages.debian.org/lenny/sou…io-module-jack

If you are using Jaunty 9.04 and you are using pulseaudio0.9.14, the pulseaudio-module-jack in Debian unstable has been removed so you will need to build it from source. It would be better if you upgraded to pulseaudio 0,9,15 which is much improved from Pulseaudio0.9.14 (which the pulse devs actually did not recommend for distribution use). There is a link at the beginning of this post to Luke Yelavich,s PPA for Pulseaudio 0.9.15 which also includes ALSA1.0.19 which you will need.

The pulseaudio-module-jack is no longer included in luke Yelavich’s PPA for pulseaudio 0.9.15 so you need to get it from Debian sid

http://packages.debian.org/sid/pulseaudio-module-jack

Download the appropriate deb by clicking on one of the mirror sites and install it with the gdebi package manager ( 386 and amd64 versions work for both Hardy and Intrepid).

Then you need to make a little script. I keep mine in a /scripts directory in my /home directory. Just make a new file with Natilus called jack_startup and make it executable and put these lines in it.

Code:
#load pulseaudio jack modules
#!/bin/bash

pactl load-module module-jack-sink
pactl load-module module-jack-source

Then start up jack control and go to Setup/Options/Execute script after Startup. click on the… box and go to where the script is and click open. and then after you make sure the path is correct click the box on the left so it has an x in it. Click OK at the bottom and make sure no application is using the sound card before you start jack or jack will not start.

If the jack sink disappears from the Pulse Audio Volume Control after a few seconds or you do not see it, adjust the timeout in the jack control setup menu to 1000-5000. Applications that just play back audio streams through Pulse Audio are very lazy about talking to their sound server and this will prevent jack from timing out the connection. (Read the pactl and modules links above to change the default options which should work for most people. It has been reported that the m-audio 1010 card needs the channels=2 option)

You should now have jack sinks and sources in the Pulse Audio Volume Control and in the Volume Control on the panel. And a Pulse Audio JACK Sink and Pulse Audio JACK Source in the jack connection bay in the Audio section all connected up to system playback and system source automatically. When you close jack, the jack sinks and sources will automatically go away.

You can now start up any non-jack application and it will play through the pulseaudio-jack sink if you select it with move stream in the Pulse Audio Volume Control. And all your jack applications should work too, at the same time. You can connect the pulse audio sink to any jack application in the jack connections bay and record, add effects, eq, pretty much anything you want that jack can hook you up with.

You can also route the mic/line inputs from the sound card by setting the jack control/setup/Input Device to the hardware device ie hw:0 or hw:1, etc. They will show up in the connections box as system capture inputs. You should hear them through the speakers. If you do not want to hear your mic in the speakers you can mute the mic input in the playback tab of your volume control and leave the captures on so you will still be able to record. If you have a usb mic, you can make that the default in the PA Volume Control and it will show up in jack/connections/audio/system capture and you will not hear it through the speakers unless you hook it to an output.

If you change the input, you will have to shut down jack, close jack control and restart. You will also have to make sure the input you are trying to use is properly enabled and turned up in whatever alsa-mixer you are using.

Now that you have pulse-jack working you can try these quick and easy fun projects to learn about using the pulse audio sinks and sources with jack:

http://ubuntuforums.org/showthread.php?t=986966

Closing jack
If you close jack before you stop or close any application playing through the Pulse Audio jack sink, Pulse Audio may crash and need to be restarted if you do not disconnect the pulseaudio sink and source before closing jack. You can go to connections and choose disconnect all before stopping jack and your applications should not crash when you stop jack.

Jack and Pulse on one sound device
If you have only one sound device your pulse applications may be orphaned when you close jack and their connection to pulseaudio may fail. You can try adding a null-sink and module-rescue-streams should move them to that when the jack sink closes and then they can be moved again when pulse regains control of the sound card. However, this does not seem to be a surefire thing and may not work for you so you may need to restart your pulseaudio applications after closing jack and after pulseaudio regains the sound device sink. There is a pulse audio module, module-always-sink, that would alleviate this problem but this module does not seem to be available in the Hardy and Intrepid pulse audio 0.9.10 but should be available in Jaunty which is using 0.9.14.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: