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.
As of 16.04, things become a lot simpler :)
Just install
qjackctl
andpulseaudio-module-jack
module:Then configure
qjackctl
to run the following command after startup. Copy it into "Setup..." > "Options" > "Execute script after Startup":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.
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:
then sudo editing the /etc/pulse/default.pa file to include two lines under the load audio drivers manually section:
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.
My solution working on Fedora 23.
Don't touch /etc/pulse/default.pa !
Configure qjackctl
The relevant fragment of ~/.config/rncbc.org/QjackCtl.conf:
The names of the sinks for pactl can be found by:
Here's one more fragment of ~/.config/rncbc.org/QjackCtl.conf to show the full commands
"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,
pactl suspend-sink alsa_output.pci-0000_00_1b.0.analog-stereo 1
jack_control start
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!
pactl suspend-sink alsa_output.pci-0000_00_1b.0.analog-stereo 1
Tools Used
LANG=C pacmd list-sinks|grep -E "index:|name:|alsa.long_card_name =|alsa.name ="
orLANG=C pactl list sinks|grep -E "(Sink #|Name:|alsa.long_card_name =|alsa.name =)"
to detect alsa device nameThe 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 .
The easiest way to route all system to run with jack:
Install
Open qjackctl. In Setup>Options>
Check Execute script after Startup and paste this:
Check Execute script after Shutdown and paste this:
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]
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
Make sure jackdbus is started. If using qjackctl to launch jack, check dbus tickbox in Setup -> Misc.
This should be all it takes.
Ubuntu 20.04, I found it to be a mix of various answers
Setup...
-->Options
-->Execute script after Startup
paste the following:Start JACK, in QJackCtl the PulseAudio Sink and Source should be connected to the system
In Ubuntu Settings, Select the JACK Sink as Output
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:
Use Synaptic to install QSynth and QJackCtl.
Copy required sound font(s) into an appropriate folder such as
/usr/share/sounds/sf2/
In QSynth Setup: under Audio tab change Audio Driver to pulseaudio.
In QSynth Setup: under SoundFonts: Open... and select one as required.
In QJackCtl Setup > Settings > Advanced:
Server Prefix: pasuspsender --
/usr/bin/jackd
In QJackCtl Setup > Options:
Execute script after startup:
In QJackCtl Connect: ALSA: join the keyboard entry on the left to FLUID Synth on the right.
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 :-).
There is two ways to answer this question.
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:
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:
Run qjackctl:
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.Then, in the advanced tab, I replaced the Server Prefix
jackd
withpasuspender -- 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:Then, in the tab "Options", put in the
Execute script after Startup
the following code: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
:That's it! Now, you just need to save by clicking on
Apply
and to click onStart
to start jack:You should see something like that if it works (and of course no errors):
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:
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) calledJack 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 runpavucontrol
(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 likeInput devices
(sorry if the translation is bad), in my case I have right now 2 sinks (jack is not yet loaded):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:
So if you have some issues, you can:
pulseaudio -> jack
: check that you have a sink corresponding to jack (if not, try to run manually the commandpactl load-module module-jack-sink
that was supposed to be run automatically. If it fails, make sure you installed thepulseaudio-module-jack
, and eventually restart pulseaudio by simply killing itkillall 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: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: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 likezynaddsubfx
), check out theGraph
part of jack: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 casezynaddsubfx
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).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 runzynaddsubfx
from the command line without any option or with:(which means input from Alsa MIDI, output to jack) it should not be a problem, you will be able to connect the MIDI devices:
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 thezynaddsubfx
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 tozynaddsubfx
:The solution is therefore to run
zynaddsubfx
using command line without options, or withzynaddsubfx -I alsa -O midi
and everything should work!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
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..