Comment 22 for bug 178895

Revision history for this message
Stephen Irons (stephen-irons) wrote :

Using pasuspender works for me -- if a PulseAudio application is already playing (eg Totem or Rhythmbox), then it stops while Audacity is running and automatically starts again when Audacity ends. Great.

However, it does not solve the problem of bug 202791 or 231651, in which Audacity cannot open the sound device. I think the problem there is related to JACK.

Audacity supports lots of different sound drivers: OSS, ALSA and in the new version, also JACK. When Audacity starts up, it automatically starts jackd, the JACK daemon with a bunch of standard settings: 48000 samples per second using the default ALSA sound device.

So JACK has grabbed the sound device, meaning that neither ALSA nor OSS can use it, and you get 'cannot open device' error.

The further problem is that JACK can ONLY work at its configured sample rate, so if your Audacity project is anything other than 48000, it will not play, but gives the 'cannot open device' error.

So you have a few options:

1. Change the Audacity project sample rate to the JACK sample rate (default 48000)
2. Change the JACK sample rate to match your Audacity project rate
3. Disable JACK and use ALSA or OSS for audio input and output.

1. is easy to do. However, you have to have JACK configured correctly, especially if you have an older PC, otherwise you will get clicks and noises, caused by JACK 'xruns'.

To change the JACK configuration, you need to have a file /etc/jackdrc (a system wide setting that overrides the jackd built in settings) or ~/.jackdrc (a per-user setting that overrides the built-in defaults and /etc/jackdrc).

To change the JACK sample rate, create a file called /etc/jackdrc or ~/.jackdrc containing the one line:

/usr/bin/jackd -R -T -d alsa -d hw:0 -r 48000 -p 128 -n 3

The number following the -r sets the sample rate. man jackd will get more details about the other options.

There are two ways to disable jackd: you can either prevent jackd from starting at all, or you can make jackd use a dummy sound card.

To prevent jackd from starting, ensure that /etc/jackdrc or ~/.jackdrc contains an illegal command: my jackdrc contains the line:
#/usr/bin/jackd -R -T -d alsa -d hw:0 -r 48000 -p 128 -n 3

Then, in Audacity you will have access to all your ALSA and OSS sound devices, and there will be no JACK device.

To make jackd use a dummy sound card, /etc/jackdrc or ~/.jackdrc should contain the line:
/usr/bin/jackd -T -d dummy -C 2 -P 2 -r 48000 -p 128

This makes JACK pretend to have a sound card with two inputs (-C 2) and two outputs (-P 2) running at 48000 samples per second.

Then in Audacity you will have access to all your ALSA and OSS sound devices, and there will be a JACK device. It will be set to 48000 samples per second and, if your Audacity project sample rate matches this, then you can play and record from this device. Of course, you will not actually hear anything...