61

Whenever I launch hydrogen it breaks my audio in all other applications which use Pulse, for example, I can no longer play videos in Chrome after having launched Hydrogen once, until I restart my PC or do sudo alsa force-reload. I have found people with similar issues, but no actual guide to fix this, often there are links to http://jackaudio.org/pulseaudio_and_jack (which has moved to http://jackaudio.org/faq/pulseaudio_and_jack.html ) I am using Ubuntu Studio 14.04 64bit.

ALTERNATIVELY if this is truly impossible to achieve, can someone tell me how to use Jack on one soundcard and Pulse on another? This way I could plug in a USB sound card only when I need JACK.

Please don't make me use windows.

2
  • 1
    After more research, there appear to be a few ways to get this to work, see here: github.com/jackaudio/jackaudio.github.com/wiki/… However in my case all of these kill all Audio output permanently. Jan 10, 2015 at 18:25
  • When using qsynth, (a fluidsynth front-end), I just changed it's settings to use pulseaudio!
    – kristianp
    Nov 17, 2023 at 1:05

11 Answers 11

59

As of 16.04, things become a lot simpler :)

Just install qjackctl and pulseaudio-module-jack module:

apt-get install qjackctl pulseaudio-module-jack

Then configure qjackctl to run the following command after startup. Copy it into "Setup..." > "Options" > "Execute script after Startup":

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

And that's it. Pulseaudio will recognize (through D-Bus) that JACK started, and automatically will route audio to it. When JACK is stopped Pulseaudio will revert to normal routing and start sending audio directly to card again.

So (almost) by default Pulseaudio implements the setup detailed above by mmv-ru.

12
  • 9
    pactl set-default-sink jack_out -> "Failure: No such entity" Aug 20, 2016 at 15:46
  • 2
    The correct command is 'pacmd set-default-sink jack_out'. Unfortunately I can't correct the answer because an edit must be more than 6 characters! :-( Apr 7, 2017 at 17:46
  • 10
    @KarlMorrison, you probably need to execute pactl load-module module-jack-sink channels=2 and pactl load-module module-jack-source before that, see @kim-tucker answer.
    – naktinis
    Jul 13, 2018 at 14:43
  • 4
    None of these combinations are working over here on Debian, with pactl or pacmd. I say we all report pulseaudio as broken software, as some of these distro maintainers obviously took it on as default before it was ready. Feb 12, 2019 at 8:55
  • 2
    Ubuntu 20.04. I had to go for pactl load-module module-jack-sink channels=2; pactl load-module module-jack-source; pacmd set-default-sink jack_out. Detailed answer below Jun 10, 2020 at 8:11
21

This Youtube video: "Jack and PulseAudio Together as Friends - Linux" seemed to have some answers:

The key to the solution appeared to be making sure pulseaudio-module-jack is installed with:

aptitude install pulseaudio-module-jack

then sudo editing the /etc/pulse/default.pa file to include two lines under the load audio drivers manually section:

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

then - I think - restarting pulseaudio. I just restarted the PC (lazy, I know) and it worked a treat... firing up Ardour no longer killed pulseaudio, they played happily together.

2
  • BTW, you can also add the modules on the fly, using pactl load-module ...
    – 0__
    Sep 21, 2017 at 11:55
  • As the top accepted answer by @José Micó siggests, no editing of files is required. Set `pacmd set-default-sink jack_out´ and activate D-Bus in JACK's Settings. Works perfectly in 2022. Oh, and make sure the Jack sink is selected in your PC's Volume Control for devices and applications.
    – Mark Lee
    Jun 7, 2022 at 22:45
11

My solution working on Fedora 23.

dnf install jack-audio-connection-kit jack-audio-connection-kit-dbus qjackctl

Don't touch /etc/pulse/default.pa !

Configure qjackctl

Settings

The relevant fragment of ~/.config/rncbc.org/QjackCtl.conf:

[Settings]
Server=jack_control start
Driver=alsa
InDevice="hw:PCH,0"
OutDevice="hw:PCH,0"

Options

The names of the sinks for pactl can be found by:

pacmd list-sinks

Here's one more fragment of ~/.config/rncbc.org/QjackCtl.conf to show the full commands

[Options]
...
StartupScript=true
StartupScriptShell=pactl suspend-sink alsa_output.pci-0000_00_1b.0.analog-stereo 1
PostStartupScript=true
PostStartupScriptShell=pactl set-default-sink jack_out
ShutdownScript=false
ShutdownScriptShell="pactl unload-module module-jack-sink; pactl load-module module-jack-source"
PostShutdownScript=true
PostShutdownScriptShell="pactl suspend-sink alsa_output.pci-0000_00_1b.0.analog-stereo 0; pactl set-default-sink alsa_output.pci-0000_00_1b.0.analog-stereo"

Misc "Enable D-Bus interface" is important for Qjackctl itself.

How it works

Now on boot the PC runs with PulseAudio only, everything automatically works as without Jack.

After launching Qjackctl,

  1. The Qjackctl startup script suspends the primary audio card in Pulseaudio and allows Jack to get access to it: pactl suspend-sink alsa_output.pci-0000_00_1b.0.analog-stereo 1
  2. Jack is started over d-bus: jack_control start
  3. Pulse automatically detects jack start over D-Bus and loads jack sink and jack source.
  4. Qjackctl after the startup script changes the default sink in Pulse to jack_out: pactl set-default-sink jack_out (at first it looks unnecessary, as all running PA clients are switched to the new sink, but new apps will get stuck on the suspended sink without this command)

So the system is reconfigured to use "Pulse on top of Jack". (I skip hardware input suspend, because I don't use it anyway)

If "Stop JACK audio server on application exit" is not checked, I can close Qjackctl and rerun it without disturbing the setup.

After stopping Jack by Qjackctl, everything returns to plain uncluttered Pulse!

  1. Jackd stopped by Qjackctl over dbus - "Enable D-bus interface" option.
  2. jack-source and jack-sink are removed from Pulseaudio automatically by d-bus
  3. the default sink in Pulse audio is switched to audio card because jack-out disappears
  4. Qjackctl after Shutdown script re-activates the audio card in Pulseaudio: pactl suspend-sink alsa_output.pci-0000_00_1b.0.analog-stereo 1

Tools Used

  1. jackd (from package pulseaudio-utils)
  2. jack_control (from package ack-audio-connection-kit-dbus)
  3. Qjackctl (from package pulseaudio-utils)
  4. pactl to control Pulseaudio from scripts (from package pulseaudio-utils)
  5. LANG=C pacmd list-sinks|grep -E "index:|name:|alsa.long_card_name =|alsa.name =" or LANG=C pactl list sinks|grep -E "(Sink #|Name:|alsa.long_card_name =|alsa.name =)" to detect alsa device name
9
  • This answer is not explicit about how the configuration is done. Is it solely done via Qjackctl? If so, what files are the config settings in, and how are they set? Mar 11, 2016 at 16:42
  • Initial configuration made via package manager. jackg start/stop reconfiguration via jack-audio-connection-kit-dbus and Qjackctl scripts.
    – mmv-ru
    Mar 11, 2016 at 16:48
  • I see. Some details along those lines would be extremely helpful. These details are notably missing from other answers, and information on the net. I'd prefer not to configure things via a GUI if possible. Are you usually in AU chat? If so, we can discuss it there. Mar 11, 2016 at 16:57
  • Qjackctl can be configured via gui as screenshots show. In Reply I show parts of .config/rncbc.org/QjackCtl.conf to show full lines of script.
    – mmv-ru
    Mar 11, 2016 at 16:57
  • 1
    This worked for me! Thanks. However I had to change the name of the sound card alsa_output.pci-****_**_**.*. Use pactl list to list available cards and figure out the name of the one you need. Jun 13, 2021 at 8:26
8
  • The problem is Hydrogen (as Ardour) launch jackd at startup but don't close it at exit:
    But you can run killall jackd in a terminal after Hydrogen exit.

  • A complicated way to use Jack and pulseaudio software at the same time is to install "pulseaudio-module-jack" (also install qjackctl (gui for jackd) and pavucontrol if not present). Restart pulseaudio pulseaudio -k.
    Now close audio apps (Jack and pulseaudio),
    run jackd using qjackctl (click start button) (dbus option must be selected in qjackctl settings last tab).
    In Pavucontrol "output device" tab, clic green "default device" button near "jack sink"
    Now pulseaudio software and Hydrogen should run at the same time.

  • Using qjackctl, in the first "settings" tab, you can change Jackd audio device .

8

Ubuntu 20.04, I found it to be a mix of various answers

  1. Install JACK and QJackCtl as well as the pulseaudio sink and source for JACK
sudo apt-get install qjackctl pulseaudio-module-jack
  1. Start QJackCtl and in Setup...--> Options--> Execute script after Startup paste the following:
pactl load-module module-jack-sink channels=2; pactl load-module module-jack-source; pacmd set-default-sink jack_out

enter image description here

  1. Start JACK, in QJackCtl the PulseAudio Sink and Source should be connected to the system enter image description here

  2. In Ubuntu Settings, Select the JACK Sink as Output

enter image description here

1
  • This worked without additional modifications! One suggestion is to add pacmd set-default-source jack_in to the end of that startup scrip
    – jpaugh
    Jan 13, 2021 at 2:09
7

2020 update. Debian Buster. Hopefully applicable to Ubuntu as well.

No need to use any script anymore.

Install pulseaudio-module-jack. It contains a module responsible for detecting when jack starts and sourcing/sinking from/into it.

You can check that in pulseaudio config file:

/etc/pulse/default.pa

### Automatically connect sink and source if JACK server is present
.ifexists module-jackdbus-detect.so
.nofail
load-module module-jackdbus-detect channels=2
.fail
.endif

Make sure jackdbus is started. If using qjackctl to launch jack, check dbus tickbox in Setup -> Misc.

This should be all it takes.

7

The easiest way to route all system to run with jack:

Install

sudo apt-get install qjackctl pulseaudio-module-jack

Open qjackctl. In Setup>Options>

Check Execute script after Startup and paste this:

pacmd load-module module-jack-source channels=2; pacmd load-module module-jack-sink channels=2;

Check Execute script after Shutdown and paste this:

killall jackd

Now start qjack and open your sound settings. You will find Pulse Audio Jack Sink Output port. Select it and all system will sync. If you stop Jack server/qjack, sound will go back to your Default port again.

[Here is the overall view]

enter image description here

1
  • works as a charm for me, Ubuntu 18.04.4 LTS
    – BCArg
    Feb 29, 2020 at 9:42
5

It might be much easier now. What worked for me today, to satisfy my really basic needs, after a fresh install of Linux Mint 18.2 (Ubuntu 16.04 package base) was:

  1. Use Synaptic to install QSynth and QJackCtl.

  2. Copy required sound font(s) into an appropriate folder such as /usr/share/sounds/sf2/

  3. In QSynth Setup: under Audio tab change Audio Driver to pulseaudio.

  4. In QSynth Setup: under SoundFonts: Open... and select one as required.

  5. In QJackCtl Setup > Settings > Advanced:

    Server Prefix: pasuspsender -- /usr/bin/jackd

  6. In QJackCtl Setup > Options:

    Execute script after startup:

    pactl load-module module-jack-sink channels=2; pactl load-module module-jack-source; pacmd set-default-sink jack_out
    
  7. In QJackCtl Connect: ALSA: join the keyboard entry on the left to FLUID Synth on the right.

  8. In the main System Settings for Sound, select the required output device.

Now I can play the keyboard while watching a video (e.g. on YouTube using Firefox for example) - previously I could only do one of these at a time without a lot of tweaks I could seldom keep track of.

Hope that helps someone, or encourages them to try again :-).

1
  • I only did step 3 "In QSynth Setup: under Audio tab change Audio Driver to pulseaudio." and that seemingly worked for Qsynth and Chrome at the same time. Apr 21, 2020 at 1:17
5

There is two ways to answer this question.

  1. Either try to make jack work with pulseaudio... the rest of this question will explain how to do that.
  2. Or... don't try to use both pulseaudio and jack, just replace them with pipewire: pipewire is supposed to be "the new pulseaudio" (it should replace pulseaudio at some points I think, and is already much less buggy than pulseaudio and supports more Bluetooth options). Pipewire emulates both pulseaudio and jack at the same time, and can seamlessly be used with pulseaudio/qjackctl/... to connect pulseaudio and jack applications together (basically pipewire does not make much difference between pulseaudio applications and jack… most of the time I'm not even sure if the application I'm using is running jack or pulseaudio). If you really want to have pain and use pulseaudio + jack... the rest of this question is for you.

A while ago I wrote a command, and someone reported me that after trying all solutions here he was out of luck. But this solution worked for him, so I'll post it here in case someone else can be helped. NB: I'm not claiming this solution is the most elegant one, but it did the job quite well for me:

  • I can start/stop jack by just clicking the start/stop button and the switch is automatic between pulseaudio and pavucontrol
  • it automatically connects all current playing softwares to jack (that's why there is this ugly grep, let me know if you have a better solution)
  • it also makes sure that pulseaudio application can also use the microphones

This solution may be slighly improved by unloading correctly the modules when quitting Jack, maybe using the ugly grep proposed here, but I didn't really found any benefit for me.

Note also that I give quite detailed instructions on how to debug such issues.

My solution (see theory below to understand why it works/fails and debug any potential issue)

Install:

$ sudo apt install jack2 pavucontrol qjackctl pulseaudio-module-jack. 

Run qjackctl:

$ qjackctl

enter image description here

Click on Setup, and check that the output Interface is the correct one (if you have an HDMI output for example this check may be important). In my case, I'll just use the default and I'll come back here if I've some issues later. enter image description here

Then, in the advanced tab, I replaced the Server Prefix jackd with pasuspender -- jackd. This is supposed to tell pulseaudio to temporarily let jack manage the sound card. I'm not sure if it's really required, but I guess it cannot hurt: enter image description here

Then, in the tab "Options", put in the Execute script after Startup the following code:

pactl load-module module-jack-sink && pactl load-module module-jack-source && pactl set-default-sink jack_out && pacmd set-default-source jack_in && pacmd list-sink-inputs | grep index | sed 's/ *index: *//g' | xargs -I{} pacmd move-sink-input "{}" jack_out

The goal of this command is to create new outputs (sink) to pulseaudio that points to jack, to enable this new sink by default (all newly open applications will write to jack), and it also change the output of all the existing applications to make sure they point to jack.

Then, to make sure pulseaudio restarts when jack is closed, I also added in the field Execute script after Shutdown :

pacmd suspend false

enter image description here

That's it! Now, you just need to save by clicking on Apply and to click on Start to start jack:

enter image description here You should see something like that if it works (and of course no errors): enter image description here

A bit of theory to understand why it works, or why it fails

So basically, you can't play sound because only one program can play sound at the same time on the same sound card. So when Jack is playing, pulseaudio is blocked. Now, it also turns out that most desktop applications can talk to pulseaudio but not to Jack. So when Jack is on, you just don't have sound anymore. The trick is to route the pulseaudio trafic to Jack with something like that:

application -> pulseaudio -> Jack -> sound card

Note that all links must be correctly configured. We will see now how they are configured and how to check if they are configured correctly.

So to create the link pulseaudio -> Jack we are going to load a module that creates a new pulseaudio sink (i.e. a virtual output device) called Jack sink: that way any applications writing in that sink will be redirected on Jack. You could have several already existing sinks, like one for the internal audio, and if you have a bluetooth headset, you can have one sink for it too. To check on which sink an application is actually playing, install and run pavucontrol (pavucontrol is super useful anyway for all sound-related stuff, since you can control basically everything from it). You can see the list of sinks in a tab named like Input devices (sorry if the translation is bad), in my case I have right now 2 sinks (jack is not yet loaded): enter image description here

If you just have one sink, you may not see anything interesting, but if you have several sinks, you can check in the first tab which application is playing on which sink (here you see that firefox is playing on my bluetooth headset), and you can change it if needed:

enter image description here

So if you have some issues, you can:

  1. link pulseaudio -> jack: check that you have a sink corresponding to jack (if not, try to run manually the command pactl load-module module-jack-sink that was supposed to be run automatically. If it fails, make sure you installed the pulseaudio-module-jack, and eventually restart pulseaudio by simply killing it killall pulseaudio. No worries, no need to restart pulseaudio, it respawn automatically.). Also make sure that the volume is not 0%, and that the channel is not muted: enter image description here
  2. link application -> pulseaudio: check that your applications are writing on that sink. If not, you can manually change the sink (but the startup script was supposed to change the sink automatically) that way: enter image description here
  3. link jack -> sound card: If you still have troubles (this part could also concern a trouble you have with the softwares that write on jack directly like zynaddsubfx), check out the Graph part of jack:

enter image description here

You should start will all nodes packed together, but you can move them to make them easier to see. Then make sure that all applications you want to ear are connected to system (in my case zynaddsubfx was not connected automatically). NB: if you have an older version of QJackctl, then you may have tabs instead of this. But it's the same: you will have green inputs/outputs in the "Jack" tab that you can manually connect, the violet ones will be in the "Alsa" tab, and the red ones in the "MIDI" tab... but in fact all external MIDI devices that you plug will appear in the Alsa tab: the reason is that there are two kinds of "MIDI": the legacy Alsa Midi (ports are global to the system), and the more recent Jack Midi (each application can have its own midi input/outputs).

enter image description here

  1. Troubles with MIDI: In theory, to get midi, you can just connect the violet inputs to violet inputs (or in the Alsa tab in the older version, yes I know it's strange that you need to go in Alsa tab and not Midi to get Midi(!!!) but it's because of the difference between Alsa MIDI vs the more recent but less used Jack Midi). However, it turns out that for some strange reasons, zynaddsubfx has some strange defaults values and will appear as "Midi/red" instead of "Alsa/green", making it impossible to connect to an external midi device. More precisely, if you run zynaddsubfx from the command line without any option or with:
zynaddsubfx -I alsa -O jack

(which means input from Alsa MIDI, output to jack) it should not be a problem, you will be able to connect the MIDI devices:

enter image description here

However, if you run it in a graphical way, the default Jack entry automatically runs zynaddsubfx -I jack -O jack instead... And it will have the issue that the zynaddsubfx input will be created in red/MIDI tab, while the actual external MIDI device is in violet/Alsa tab. So it means that you won't be able to map your external midi keyboard to zynaddsubfx:

enter image description here

The solution is therefore to run zynaddsubfx using command line without options, or with zynaddsubfx -I alsa -O midi and everything should work!

5
  • 1
    Though this has a low number of upvotes, I want to note that this worked perfectly for me. Thanks for writing in such detail!
    – Jim
    Nov 24, 2021 at 0:51
  • @Jim Thanks. I also added at the very beginning a short sentence: don't use jack/pulseaudio anymore, you'd better install pipewire everything is so much simpler there as it emulates both jack and pulseaudio (pipewire should replace pulseaudio at some points).
    – tobiasBora
    Nov 24, 2021 at 1:15
  • 1
    Ha! I just got things working, so I'm going to roll with this, but when I next run into a problem, I'll giver pipewire a shot!
    – Jim
    Nov 26, 2021 at 18:25
  • In your first code block, should the package be jackd2 rather than jack2? If not, how would I go about installing jack2 if it's not available via my package manager? Their website recommends using the package manager, but it doesnt seem to be available on my Zorin OS
    – devklick
    Apr 10, 2023 at 16:38
  • @devklick yes, I read jack2 in an old documentation, but seems like it's called jackd2 on most distributions.
    – tobiasBora
    Apr 11, 2023 at 11:59
0

Of course one will want both pulseaudio and jack running if they got to the point where they need jack as most browser media players don't know jack! ..unfortunately.

I kept seeing the suggestion of having just one of them running at a time which seems to me like such a terrible compromise. It's a bit tragic in my opinion that these two services i.e. jack and pulseaudio although both functional on their own are so poorly managed by kxstudio at least which is what I'm using.

So what happens is:

  • jack cannot start while pulseaudio is running (and using the soundcard driver it wants to use which is fair enough) so it needs to be started first

  • pulseaudio needs to be pointed to jack once both up and running

Pretty simple..ey? For certain reasons, I had endless grief with it cuz..

First I think because pulseaudio 4.0 seems be buggy and mess up the alsa driver so that in some situations it leaves it locked and therefore jack cannot start even though pulseaudio is not running. (Says failed to set capture parameters or smtg like that)

What I deed in the end was

  • removed both jack and pulseaudio completely (with find and rm -rf :D after apt-get purge)
  • installed pulseaudio 11 (from sources)
  • installed jack and it's libs (libjack-dev)

in this order and then I finally got them running normally through qjackctl which makes sure they start in the correct manner (loads the jack sink in pulseaudio, and sets it as default).

Btw, I saw Cadence is recommended instead and I don't understand why as to me it seems rubbish compared to qjackctl.

Anyway, problem is starting jack using qjackctl takes a while and to avoid the waiting times at each boot you can use this life saver feature of kde which is to load previous session. Make sure you don't have qjackctl in autostart though as you will end up with one more instance at each reboot regardless of the singleton = true setting (buggy buggy all night long).

This is because I didn't feel fiddling around with it any longer such as writing a smart script that will make sure pulseaudio is down (or suspended) start jack and check that it started properly, then start pulseaudio, load jack module etc.

Otherwise relying on the OS to start the daemons and load config correctly would be the normal (healthy) scenario however it doesn't seem to be happening.

Have fun..

1
  • Very incomplete and vague hacking about in the wilderness answer. There are better.
    – RichieHH
    Jul 2, 2020 at 5:53
0

I am running Linux Mint 19.1. After trying all the various solutions, things still wouldn't work smoothly for me.

Finally, I was able to solve all my issues by following the steps/instructions in the video: Link

Basically, it installs applications from the Kxstudio repositories. and they have a script to configure everything perfectly at startup.

My end goal was to be able to record input through my interface(Scarlett solo) while being able to run/record sound from other applications (desktop, browser)

You must log in to answer this question.

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