1

I've played around with jack in the past, but I have never really been successful with it because it feels overwhelming and it doesn't allow my computer audio output to continue functioning while jack is running. Trying to play songs in my media player has them hang at 0 seconds attempting to play them; presumably they are writing PCM or something to pulseaudio or alsa and that write is never completing.

Is there a way to have jack running most or all of the time in the background while still being able to hear computer audio output?

In my case, I have a USB audio interface (a Focusrite Scarlett) which is connected to a pair of speakers which I use as my default audio output, but I'm not sure whether the output type (i.e. USB or an internal sound card) matters here.

I'm on Ubuntu 20.04 LTS running the latest HWE kernel (actually elementary OS Odin, but based on Ubuntu 20.04).


EDIT: I was able to completely bypass all of this by using PipeWire.

PipeWire is a low-latency audio system which can speak PulseAudio, ALSA, and Jack protocols, and can easily replace both PulseAudio and Jack. I replaced my desktop's PulseAudio server with PipeWire, it isn't too hard, and enabled PipeWire for Jack as well, so now everything goes to one unified place and I don't need to do silly workarounds to make things work, they just do, and everything is none the wiser.

enter image description here

I've written up how to do this for my distribution, elementary OS 6, in this Gist.

3
  • What makes you believe you need jack ? (Achieving whatever pro-audio work ? You no longer need it ! ) And BTW, jackd being a daemon, it permanently "runs in the background"
    – MC68020
    Aug 14, 2022 at 11:35
  • @MC68020 people don't use jack anymore for audio work? Aug 30, 2022 at 19:17
  • I can't tell for "people". I can tell for Paul Davis (Jack's author) having said a couple of years ago that "you probably don't need jack any more". And for me… a looong & happy time jack-1 user. For the reason why, see my last comment as part of telcoM's answer. (Of course I don't run pulseaudio either).
    – MC68020
    Aug 30, 2022 at 19:51

1 Answer 1

0

The USB audio interface will probably accept only a single audio datastream at any time, and so you would need the audio from jack and the "computer audio output" to be mixed together in software.

On systems without jack, PulseAudio will usually be the component doing that, but since jack wants to provide absolutely minimum latency and sample synchronization, it needs exclusive access to the sound device.

You might want to read this webpage: https://jackaudio.org/faq/pulseaudio_and_jack.html

In particular, I'd consider option 3 on that page, which refers to another page: https://github.com/jackaudio/jackaudio.github.com/wiki/WalkThrough_User_PulseOnJack

In a nutshell: Ubuntu probably already has ALSA defaulting to PulseAudio, so you'll only need to ensure the pulseaudio-module-jack package is installed, and place this configuration into your ~/.config/pulse/default.pa if you intend to run jack all the time:

load-module module-native-protocol-unix
load-module module-jack-sink channels=2
load-module module-jack-source channels=2
load-module module-null-sink
load-module module-stream-restore
load-module module-rescue-streams
load-module module-always-sink
load-module module-suspend-on-idle
set-default-sink jack_out
set-default-source jack_in

Depending on the capabilities of your USB audio interface, you might need some or all of these settings in your ~/.config/pulse/daemon.conf:

default-sample-format = float32le
default-sample-rate = 48000
realtime-scheduling = yes
exit-idle-time = -1

(Most USB audio interfaces accept input at a fixed sample rate only - typically 48000 - so this makes sure Pulseaudio knows about this restriction and converts everything incoming from the desktop audio side to that format, to make jack's job easier.)

If you are using qjackctl to launch jackd, you'll need to configure a post-startup action like this to switch PulseAudio to jack:

pactl load-module module-jack-sink channels=2; pactl load-module module-jack-source channels=2; pacmd set-default-sink jack_out

If you only run jack some of the time, then this post-startup action will essentially do the job of the ~/.config/pulse/default.pa configuration above, telling PulseAudio to divert its output to jack when it has been started up.

4
  • 1
    Agreed with what you wrote. However, at the end of the day, isn't it just absurd to cascade two sound servers ? (especially if jack is running RT). Granted it is a difficult task to achieve however, if OP wants to use jack… they'd better plan removing (or bypassing Pulse)
    – MC68020
    Aug 14, 2022 at 11:33
  • Obviously it's less than ideal. On the webpage I linked, it says: "Option 1: don’t use PulseAudio with JACK - The most experienced and demanding users of JACK do not attempt to link PulseAudio and JACK." But as the OP says they've "played around with jack in the past but never been successful with it" does not exactly sound they are in the "experienced and demanding users of JACK" category - at least not yet. Having both PulseAudio and JACK APIs usable simultaneously should make the transition easier, should the OP choose to do so.
    – telcoM
    Aug 14, 2022 at 12:06
  • Of course, in the indefinite-but-bright future, there is Pipewire, which apparently provides PulseAudio, ALSA, JACK and GStreamer software interfaces natively, so it might obsolete both PulseAudio and Jack. But it seemed to me that the OP already had a mostly-working JACK setup, and Ubuntu 20.04 LTS does not seem to have Pipewire in the main distribution yet although PPAs exist.
    – telcoM
    Aug 14, 2022 at 12:20
  • 1
    Hmmm… in the finite present time ;-) You no longer need jack. Jack was essentially needed to route the data cascaded from tasks to other tasks to finally the hw. with the minimum latency and best possible sync between streams. Think for example a midi player -> software synths -> effects post processing -> mixing -> recording -> hw. My point is that considering the huge amount of LV plugins available, apps such as Ardour / Rosegarden are capable to achieve all that work internally, Hence providing even better syncs and latencies than jack would be capable of.
    – MC68020
    Aug 14, 2022 at 12:39

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .