Author Topic: HowTO: PulseAudio and JACK with AV Linux 2016  (Read 42062 times)

0 Members and 1 Guest are viewing this topic.

Offline GMaq

  • Administrator
  • Hero Member
  • *****
  • Posts: 2995
  • Karma: +33/-0
  • A/V 'Nixer
    • www.bandshed.net
HowTO: PulseAudio and JACK with AV Linux 2016
« on: March 11, 2017, 03:34:42 PM »
*This HowTO has been improved and edited since it's initial posting!

Hi,

AV Linux 2016 comes out of the box with an Audio and MIDI Loopback routing system set up to work independently without PulseAudio and provide similar routing capabilities. For many people this is an ideal setup so if you are one of those people there is no need to change anything on your AV Linux 2016 install. However as time moves on PulseAudio has become a dependent package in most Linux Distribution's packaging of Desktop Environments, some web browsers (ie Firefox 52+) and some important 3rd party applications (ie Skype) will only work on a system with PulseAudio installed. Moving forward PulseAudio and JACK will have to be set up to coexist peacefully on AV Linux and this guide will show you how to get this up and running (if needed) on an existing AV Linux 2016 system. Note this Audio routing setup will be the default on all future '2017' versions of AV Linux.

First off the original reference for this is here, HUGE thanks to 'tramp' over at linuxmusicians.com who also has made further improvements in enabling systemd Suspend as well:
https://linuxmusicians.com/viewtopic.php?f=19&t=13234&hilit=pajackconnect&sid=ae038fca6314be05328950b060d530a4#p58043

STEP 1: Disable the 'snd-aloop' module

The current Audio routing system on AV Linux requires a kernel module called 'snd-aloop' to be loaded at boot, this will no longer be required and will only confuse the number of Audio devices that appear on the system so we need to tell the system not to load that module any longer at boot, this is done by editing the 'etc/modules' text file as Root.

Open a Root Terminal and type (or copy and paste) this command:

Code: [Select]
mousepad /etc/modules
This will open the 'Mousepad' text editor so we can comment out 'snd-aloop' with a hash (shown on line 6), Once you have done this Save the 'etc/modules' text file in Mousepad.



STEP 2: INSTALL PULSEAUDIO + DEPENDENCIES:

Before you install the pajackconnect script you need to have PulseAudio and a few dependencies installed, these are not included in AV Linux 2016 so you will need to install them first before installing and using pajackconnect.

As Root in a terminal (or use Synaptic):

Code: [Select]
apt-get install pulseaudio pulseaudio-utils pulseaudio-module-jack pavucontrol
*For AV Linux 2016 or if you use XFCE4 as a Desktop on Debian or Ubuntu you may want to optionally install the xfce4-pulseaudio-plugin to run the PulseAudio Mixer from your Panel..

As Root in a terminal (or use Synaptic):

Code: [Select]
apt-get install xfce4-pulseaudio-plugin
Now download the 'pajackconnect' script package and install it on your system, Get the package here:

http://www.bandshed.net/packages/pajackconnect/pajackconnect_0.1_all.deb

STEP 3: Modify Qjackctl 'Options' to use the new pajackconnect script.

Open the Qjackctl UI, then click on 'Setup' and go to the 'Options' tab. Look at the picture below and eliminate any existing text pertaining to the previous 'jackutils' scripts and enter the new script commands exactly like you see in the picture below. You can also copy and paste them from here:

Quote
/usr/bin/pajackconnect start && a2jmidid -e &

/usr/bin/pajackconnect stop &

/usr/bin/pajackconnect reset &


*IMPORTANT if you have Qjackctl set to automatically launch when you login, disable it for now, on our next boot we want to run Qjackctl manually.



STEP 4: Reboot your system to ensure it starts without the 'snd-aloop' module, then we can see if our system changes are working.

On your fresh boot launch the Qjackctl UI and click 'Start', you may want to check in Qjackctl if the Audio device you normally use is selected since the removal of the 'Loopback' device will change the numbering of the Audio devices. Once you start JACK it will take the pajackconnect script a few seconds to start, it is possible on the first run it will not create the PulseAudio jack ports properly and fail, if this happens close the Qjackctl UI completely and try it a second time if this happens.

If JACK starts properly you should see this in the 'Connect' Window.



As you can see, there are now PulseAudio JACK 'Sink' and 'Source' ports, this means applications using PulseAudio are being routed through whichever device you have selected to run with JACK. This is similar to the previous AV Linux aloop-daemon, however instead of ALSA/JACK we are using PulseAudio/JACK.

STEP 5: OPTIONAL: Add the mixer control to your panel.

If you want the PulseAudio volume control on your Panel you can add it by right-clicking on your Panel and 'Panel'-->'Add New Items' then find the PulseAudio plugin and add it.



STEP 6:
Clean up unused packages.

If you are happy with how this new routing system is working and are sure you don't want to return to an ALSA Loopback system you can use Synaptic to remove the 'aloop-daemon' and 'jackutils-script' packages from AV Linux 2016 as they are no longer needed. The 'aloop-daemon' will no longer work with the 'snd-aloop' module disabled.

*IMPORTANT!
-This may not work with starting Qjackctl at login, Now that PulseAudio routes all the usual Desktop stuff I personally only launch Qjackctl when I want to do Audio work.. YMMV.
-I am using this script with JACK2, it should work either way but AV Linux 2017 will come with JACK2 so that is why I have set it up this way.
« Last Edit: April 01, 2017, 10:50:29 AM by GMaq »

Offline jiff41

  • Sr. Member
  • ****
  • Posts: 54
  • Karma: +3/-0
  • AVLinux User (Getting there bit by bit!.)
Re: HowTO: PulseAudio and JACK with AV Linux 2016
« Reply #1 on: March 12, 2017, 12:08:34 PM »
Done, Works fine
Thanks Glen :cool:
I started out with nothing & I still have most of it left!. (Seasick Steve)

Offline GMaq

  • Administrator
  • Hero Member
  • *****
  • Posts: 2995
  • Karma: +33/-0
  • A/V 'Nixer
    • www.bandshed.net
Re: HowTO: PulseAudio and JACK with AV Linux 2016
« Reply #2 on: March 12, 2017, 02:08:58 PM »
Done, Works fine
Thanks Glen :cool:

Hi jiff41,

Thanks for trying it out and confirming that it worked for you.

Offline nik gnomic

  • Jr. Member
  • **
  • Posts: 10
  • Karma: +0/-0
  • AVLinux User
Re: HowTO: PulseAudio and JACK with AV Linux 2016
« Reply #3 on: March 14, 2017, 11:24:14 AM »
I only came back to using avlinux couple of months ago. been helping a friend with pulseaudio bridges as they couldn't get alsa loopbacks working right, same reason i moved to other distros

I been using pulseaudio with jack to run idjc for couple of years, because of a certain voip app that everybody has to have  :(

My use case is different to what most folks on here may want. I have Pulseaudio left on and use QjackCtl with D-Bus enabled. that uses the Pulseaudio module jackdbus detect and would give you the same connection layout as in OP with no script required.

If Pulse is only to be on with JACK to run the sink and source, suggest there is an edit to comment out this part of /etc/pulse/default.pa:
### Automatically load driver modules depending on the hardware available
.ifexists module-udev-detect.so
load-module module-udev-detect
.else
### Use the static hardware detection module (for systems that lack udev support)
load-module module-detect
.endif

Offline nik gnomic

  • Jr. Member
  • **
  • Posts: 10
  • Karma: +0/-0
  • AVLinux User
Re: HowTO: PulseAudio and JACK with AV Linux 2016
« Reply #4 on: March 14, 2017, 12:17:49 PM »
(continued from prev post)
...Then Pulse will not detect any hardware devices and will only use the Pulseaudio sink/source

I also suggest using Pulseaudio Mixer pavucontrol rather than panel control as it has more options available for sound routing than panel control

Since Pulseaudio v6 there is also the option for more than one sink/source by repeating lines:
     pacmd load-module module-jack-sink channels=2
      pacmd load-module module-jack-source channels=2

Either in script or terminal as required

Pulseaudio can be changed from default timer scheduling to realtime using options in /etc/pulse/daemon.conf, but this would need setting to specific hardware requirements (not quite worked that out yet)

The pajackconnect script looks like very similar command to my own bash scripts - should work excellent  :cool:  :cool:  :cool:

Offline GMaq

  • Administrator
  • Hero Member
  • *****
  • Posts: 2995
  • Karma: +33/-0
  • A/V 'Nixer
    • www.bandshed.net
Re: HowTO: PulseAudio and JACK with AV Linux 2016
« Reply #5 on: March 14, 2017, 12:59:38 PM »
@nik gnomic

Thanks for the added info, I personally have avoided P.A. like the plague for as long as possible and am still very much a newb at configuring it so 'power user' tips are welcomed.

Offline brummer

  • Newbie
  • *
  • Posts: 8
  • Karma: +0/-0
Re: HowTO: PulseAudio and JACK with AV Linux 2016
« Reply #6 on: March 20, 2017, 04:02:09 AM »

*IMPORTANT!
-This script will properly switch PulseAudio on and off with Qjackctl when you launch and close Qjackctl, as-is it does not work with Suspend, that takes some extra systemd hacking

Hi GMaq

Making it work on suspend as well isn't as hard. No really hack is needed. All we need is a systemd.service file included.
I've updated the github repository so that it now contain anything needed to build a debian package with the systemd.service file included and handling the enable on install /disable on uninstall calls. Check out:
https://github.com/brummer10/pajackconnect

Offline GMaq

  • Administrator
  • Hero Member
  • *****
  • Posts: 2995
  • Karma: +33/-0
  • A/V 'Nixer
    • www.bandshed.net
Re: HowTO: PulseAudio and JACK with AV Linux 2016
« Reply #7 on: March 20, 2017, 01:40:22 PM »
Hi brummer!

Wow, thanks!! The last piece of the puzzle is solved!

I pulled your GIT repo and everything looks good, I had to modify the 'Description' line in the Debian control file to get it to build the package though...

The current Debian Control file gives me this error:

Code: [Select]
tester@avlinux64box:/media/DATA1/Packaging/PAJACKCONNECT/GIT/pajackconnect$ dpkg-buildpackage -rfakeroot -uc -b
dpkg-buildpackage: info: source package pajackconnect
dpkg-buildpackage: info: source version 0.1
dpkg-buildpackage: info: source distribution unstable
dpkg-buildpackage: info: source changed by hermann <brummer@org>
dpkg-buildpackage: info: host architecture amd64
 dpkg-source --before-build pajackconnect
dpkg-source: error: syntax error in pajackconnect/debian/control at line 15: line with unknown format (not field-colon-value)
dpkg-buildpackage: error: dpkg-source --before-build pajackconnect gave error exit status 25
tester@avlinux64box:/media/DATA1/Packaging/PAJACKCONNECT/GIT/pajackconnect$

If I modify the Debian Control file to look like this then it builds fine:

Quote
Source: pajackconnect
Section: unknown
Priority: optional
Maintainer: hermann <brummer@org>
Build-Depends: debhelper (>= 9)
Standards-Version: 3.9.8
Homepage: https://github.com/brummer10/pajackconnect
#Vcs-Git: https://anonscm.debian.org/collab-maint/pajackconnect.git
#Vcs-Browser: https://anonscm.debian.org/cgit/collab-maint/pajackconnect.git

Package: pajackconnect
Architecture: any
Depends: ${shlibs:Depends}, ${misc:Depends}, dh-systemd (>= 1.5)
Description: Start/stop JACK on a system running PulseAudio via QjackCtl, includes systemd service file for Suspend.

Since these are only text-based scripts I changed 'Architecture:' 'any' to 'all' so I can compile both architectures on one system.

Thanks very much again for the finishing touches!
« Last Edit: March 20, 2017, 02:12:28 PM by GMaq »

Offline brummer

  • Newbie
  • *
  • Posts: 8
  • Karma: +0/-0
Re: HowTO: PulseAudio and JACK with AV Linux 2016
« Reply #8 on: March 21, 2017, 12:41:08 AM »

If I modify the Debian Control file to look like this then it builds fine:


Ups, thanks, I've updated the repository with your changes,  :smile:

regards
hermann

Offline sambaji

  • Newbie
  • *
  • Posts: 1
  • Karma: +0/-0
  • AVLinux User
Re: HowTO: PulseAudio and JACK with AV Linux 2016
« Reply #9 on: April 08, 2017, 09:37:54 PM »
Thanks so much for sharing. I wasn't able to get any audio through Firefox with my internal soundcard on my laptop until I followed your tutorial.

Offline Ahumada

  • Newbie
  • *
  • Posts: 1
  • Karma: +0/-0
  • AVLinux User
Re: HowTO: PulseAudio and JACK with AV Linux 2016
« Reply #10 on: November 17, 2017, 07:17:46 AM »
Thanks so much for sharing. I wasn't able to get any audio through Firefox with my internal soundcard on my laptop until I followed your tutorial.

Same, I followed this guide yesterday and it fixed my sound issue however today there's no sound again.  :angry: