Sunday, October 06, 2013

Jackd and pulse audio

I need not to forget this again:

Best resource I found here:
https://wiki.archlinux.org/index.php/PulseAudio/Examples#Pulseaudio_through_JACK_the_old_way

For UbuntuStudio users:
https://help.ubuntu.com/community/UbuntuStudio/ProAudioIntro/1204#The_Pulse_Audio_to_Jack_Bridge_-_using_both_at_once

PulseAudio and Jack working together

Thanks to Jack and Pulse Audio packagers, there is now a very easy way to get PulseAudio and Jack working together. First of all, install the package pulseaudio-module-jack
sudo apt-get install pulseaudio-module-jack
If the dbus option is checked in Qjackctl (Jack Control) setup, it should work without any other tweak : as soon you start jackd, a new Jack virtual sound card is created in the Unity sound preferences, and Pulse Audio inputs and outputs are available for Jack.
It means you should see virtual "Jack Sink" outputs and inputs in Audio preferences, and "PulseAudio" Sink (outputs) and Source (inputs) in jack (use Qjackctl or Patchage).

To have sound with PulseAudio applications (Totem, Rhythmbox, Firefox, etc...) and your jackd sound card, just connect PulseAudio JACK Sink to the sound card outputs with Patchage. Then in PulseAudio preferences, choose "Jack Sink" as output. That's it.


---
And...

Pulseaudio through JACK the old way

The JACK-Audio-Connection-Kit is popular for audio work, and is widely supported by Linux audio applications. It fills a similar niche as Pulseaudio, but with more of an emphasis on professional audio work. In particular, audio applications such as Ardour and Audacity (recently) work well with Jack.
Pulseaudio provides module-jack-source and module-jack-sink which allow Pulseaudio to be run as a sound server above the JACK daemon. This allows the usage of per-volume adjustments and the like for the apps which need it, play-back apps for movies and audio, while allowing low-latency and inter-app connectivity for sound-processing apps which connect to JACK. However, this will prevent Pulseaudio from directly writing to the sound card buffers, which will increase overall CPU usage.
To just try PA on top of jack, have PA load the necessary modules on start:
pulseaudio -L module-jack-sink -L module-jack-source
To use pulseaudio with JACK, JACK must be started up before Pulseaudio, using whichever method one prefers. sPulseaudio then needs to be started loading the 2 relevant modules. Edit /etc/pulse/default.pa, and change the following region:
### Load audio drivers statically (it is probably better to not load
### these drivers manually, but instead use module-hal-detect --
### see below -- for doing this automatically)
#load-module module-alsa-sink
#load-module module-alsa-source device=hw:1,0
#load-module module-oss device="/dev/dsp" sink_name=output source_name=input
#load-module module-oss-mmap device="/dev/dsp" sink_name=output source_name=input
#load-module module-null-sink
#load-module module-pipe-sink

### Automatically load driver modules depending on the hardware available
.ifexists module-udev-detect.so
load-module module-udev-detect
.else
### Alternatively use the static hardware detection module (for systems that
### lack udev support)
load-module module-detect
.endif
to the following:
### Load audio drivers statically (it is probably better to not load
### these drivers manually, but instead use module-hal-detect --
### see below -- for doing this automatically)
#load-module module-alsa-sink
#load-module module-alsa-source device=hw:1,0
#load-module module-oss device="/dev/dsp" sink_name=output source_name=input
#load-module module-oss-mmap device="/dev/dsp" sink_name=output source_name=input
#load-module module-null-sink
#load-module module-pipe-sink
load-module module-jack-source
load-module module-jack-sink

### Automatically load driver modules depending on the hardware available
#.ifexists module-udev-detect.so
#load-module module-udev-detect
#.else
### Alternatively use the static hardware detection module (for systems that
### lack udev support)
#load-module module-detect
#.endif
Basically, this prevents module-udev-detect from loading. module-udev-detect will always try to grab the sound-card (JACK has already done that, so this will cause an error). Also, the jack source and sink must be explicitly loaded.

No comments: