Network sound between 2 computers via netjack2

Write tutorials here
There are more tutorials here http://community.linuxmint.com/tutorial/welcome
Forum rules
Please don't add support questions to tutorials,start your own thread in the appropriate sub-forum instead. Before you post please read this
wollymammoth
Level 1
Level 1
Posts: 5
Joined: Sat Feb 22, 2014 3:24 am

Network sound between 2 computers via netjack2

Postby wollymammoth » Mon Feb 24, 2014 6:25 am

Abstract:
following powerhouse's (awesome) guide on setting up a hardware-accelerated windows VM I wanted to get low latency audio from my windows PC (VM) to the linux mint host.
Although this method should be general to any 2 networked computers and in theory audio can be passed linux->windows by swapping the 'client' steps on each machine.

The plan is to get a basic install of the jack2 audio server on both PCs then go back and load jack clients to configure what audio to send where.

The guide is structured first as a somewhat generic setup of jackd2 on 2 PCs, then extra bits to get audio in-to jackd2 on windows (may be extended as necessary in the future)

note: my guide is based on various tutorials from jackd2 users - I just never found all the information presented in one place.

note2: I have no idea what I am doing in jack so if you know better (especially with the "config" of the jackd2 servers) please help me/us out!
So anyway here we go...



Software:
This guide assumes Linuxmint 16 x64 and windows 7 x64 although it should be possible on 32-bit/other OS versions with minimal modifications.
The latest version of jackd2 for windows can be downloaded from here (I used "Mixed 64/32 bit JACK 1.9.9" for win 7 x64 - which actually turned out to be v 1.9.9.5).
The latest version of jackd2 for linux can be grabbed from your repository or compiled from source.

Generally there is only the latest version of jackd2 for windows available for download (I have not found archived binaries anywhere), so if you want to connect between linux and windows you need the matching version in linux.
If the appropriate version is not available from the repositories you will need to compile from source (instructions at the end of the guide "Install jackd2 for linux from source")

The windows binaries version can be confirmed by installing them, running "jack Command" and entering:

Code: Select all

jackd.exe -V

The version number is printed at the top (at the time of writing "1.9.9.5")



jackd2 windows install and configure
Run the jackd2 installer - all options at their defaults are fine.
right-click "Jack control", go into "Properties"->"Compatiblity" and tick "run this program as an administrator", click OK.

start "Jack control"
This will bring up a small "JACK Audio Connection Kit" window, click "setup" and change the settings to those below (leave unmentioned ones at their defaults):
server prefix: jackd -S
realtime: <checked>
Timeout: 10000 ms

"save" the configuration and close the configure window.



jackd2 linux install and configure
note: in pervious versions of this guide I installed from source - the linux mint 16 repos have been updated in line with the latest windows release so this is no longer always necessary

Code: Select all

sudo apt-get install jackd2 qjackctl

run:

Code: Select all

jackd -V

If the version matches that of windows (or you are connecting 2 linux PCs) everything is good, else you may need to install from source :( - see "Install jackd2 for linux from source" below.

start qjackctl
This will bring up a small "JACK Audio Connection Kit" window, click "setup" and change the settings to those below (leave unmentioned ones at their defaults):
realtime: <checked>
Timeout: 10000 ms



master jackd2 server - no speakers attached (windows in my case)
Install jackd2 as above.

For windows: start "Jack control"
For linux: start "qjackctl"

click "setup"
change the "Driver" to "net"
'save' the configuration and close the configure window.
click "start" in the "Jack control"/qjackctl window.

The jackd2 server should <hopefully> start (you can open "messages" for detailed information)



Slave jackd2 server - has speakers attached (linux in my case)
Install jackd2 as above.

For windows: start "Jack control"
For linux: start "qjackctl"

click "setup"
For windows: change the "Driver" to "portaudio", and select the "interface" your speakers are connected to.
For linux: change the "Driver" to "alsa", and select the "interface" your speakers are connected to.

The jackd2 server should <hopefully> start (you can open "messages" for detailed information)

note: when I compiled from source, jackd2 complained about "/usr/local/lib/jack/jack_netone.so" so I simply deleted it and tried again

Code: Select all

sudo rm /usr/local/lib/jack/jack_netone.so


In linux: You can do a quick test and try playing a file with alsaplayer via jack to see that you get audio:

Code: Select all

sudo apt-get install alsaplayer alsaplayer-jack
alsaplayer -o jack path/to/test-file.mp3

you will then need to open the 'connect' window in qjackctl and drag-and-drop 'alsaplayer-XXXX' to 'system' - and audio will start playing (I hope!)



Slave jackd2 client (linux in my case)
For windows: open a new command window as administrator (right-click run as administrator) and run:

Code: Select all

cd "C:\Program Files (x86)\Jack"
jack_load.exe netmanager

For linux: with the jack server from earlier still running, open another terminal and run:

Code: Select all

jack_load netmanager


If the client compains that it cannot find the "jack server" ensure you are running the server and client as the same user (administrator for windows, normal-user for linux)

After a short period jackd2 should find your other PC and its "hostname" should appear in the jackd2 "connect" window (opened from qjackctl)

If instead the "Messages" window fills with "protocol" errors you will have to recheck the jackd2 versions and try a different combination :(

In qjackctl open the "connect" window and drag <master PC hostname> on the left to "system" on the right.

It should look a little like:
jack server and client linux.png

Note the (thin) line connecting the <master PC hostname> to "system" - this tells jackd2 to route any audio from <master PC hostname>-output (whatever was recorded/captured on the remote PC) to "system"-input (input from jackd2's point-of-view but actually the system output... i.e the speakers) - yes this terminology is confusing for me too!!! :?

Nearly there!



Master jackd2 client(windows in my case)
For windows: open a new command window as administrator (right-click run as administrator) and run:

Code: Select all

cd "C:\Program Files (x86)\Jack"
jack_load.exe audioadaptor

For linux: with the jack server from earlier still running, open another terminal and run:

Code: Select all

jack_load audioadaptor


If the client compains that it cannot find the "jack server" ensure you are running the server and client as the same user (administrator for windows, normal-user for linux)

then in the jackd2 server program ("jack control"/qjackctl)
open the "connect" window and drag "audioadaptor" from the left to "system" on the right

It should look a little like:
jack server and client windows.png


note: the jackd2 "audioadptor" will capture any audio from the system-default recording device.

Jackd2 configuration complete!



Getting sound from windows (as jackd2 master) into jackd2 (and so to the other PC):
install "VB-CABLE driver" from here (free alternative to 'virtual audio cable')
this will create a virtual soundcard and recording device that loopback to one-another then:
- Set the cable input to be the system-default output.
- Set the cable output to be the system-default input.

- the jackd2 "audioadptor" client will now capture all system audio from the "recording device", and the "netmanager" client on the remote PC will redirect this audio out of the remote speakers :)

If you are having issues, first try:
- open "recording devices" (right-click the "speaker" icon in the windows-system-tray in the right of the taskbar)
- start playing a music/video file (or a youtube video - whatever)
- check that the green/grey bar beside "CABLE Output" rises and falls in time (picture worth a thousand words?). This helps confirm if the problem lies within jackd2 or the cable.

If the problem is with jackd2:
- ensure the servers are still running and connecting with one-another
- ensure that the appropriate "connections" are drawn in the "connect" windows of each machine.

If the problem is with the "cable":
- check that the cable ends are both the default playback device and recording device
- I, err..., uhh...????



Compile jackd2 for linux from source
keep jackd2 installed from the repositories as it does some system-specific configuration to save you the hassle (and the compiled-from-source binaries will overwrite and repo-installed ones)

Code: Select all

sudo apt-get install jackd2 qjackctl


Now, get the basics:

Code: Select all

sudo apt-get install git build-essential


This step may not be necssary - depending on what is in your repositories - but the only way (that I know of) to check for custom-modes is trying to build jackd2 and seeing whether it fails or not...
build the opus 1.1 library with custom modes - the version in the repository does not have custom modes enabled :(
download the source package for libopus 1.1 from here.
unpack and open a terminal in the unpacked dir then:

Code: Select all

cd opus-1.1
./configure --enable-custom-modes
make
sudo make install


Get jack dependencies (inclomplete?):

Code: Select all

sudo apt-get install libffado-dev libreadline6-dev libsamplerate-dev libsndfile1-dev


I couldn't find "libfreebob-dev" in the repositories, so I grabbed the 1.0.11-ubuntu version from here (you will need both the libfreebob-dev and libfreebob packages)
then just double-click to install

The "celt" codec was likewise not in the repositories so grab the celt-0.11.1.tar.gz from here, unpack, and run

Code: Select all

cd celt-0.11.1
./configure
make
sudo make install


get the latest jack sources from git - the version in my repositories (at the time of writing) was out of date and incompatible with windows :(

Code: Select all

mkdir jack_source
cd jack_source
git clone git://github.com/jackaudio/jack2.git

and switch to the tagged version you installed in windows (1.9.9.5 for me)

Code: Select all

git checkout 1.9.9.5


build jack with alsa support:

Code: Select all

cd jack2
./waf configure --alsa
./waf build
sudo ./waf install

note: I can't remember what dependencies are required here - configure will tell you what it wants - please comment on extra requirements and I will add them.
note2: this will install over the top of any other/previous jack install



TODO/work-in-progress:
I have not looked into setting this up automatically on boot yet but if you are feeling adventurous:
- the qjackctl 'messages' window shows what command it used to start the jackd2 server
- jack_connect can be used to automate the 'drag this-to-that' in the 'connect' window(? - I have not played with this yet)

On the linuxmint PC, the jackd server 'takes over' the audio output whilst running so that non-jack programs can't use the speaker, but multiple jack applications can use the port simultaneously (ie alsaplayer and my windows PC)
- this could be fixed by making a loopback device in alsa similar to how the "VB-CABLE driver" works in windows



Hope you enjoyed the guide and got something useful from it :)
Last edited by wollymammoth on Wed Feb 26, 2014 2:33 am, edited 1 time in total.

powerhouse
Level 5
Level 5
Posts: 979
Joined: Thu May 03, 2012 3:54 am
Location: Israel
Contact:

Re: Network sound between 2 computers via netjack2

Postby powerhouse » Tue Feb 25, 2014 6:57 am

Thanks for contributing this tutorial. I've tried some of your steps (on the Linux side) and have some remarks:

1. When referring to jackd, you mean jackd2 ?
2. The jackd2 version in Linux Mint 16 is 1.9.9.5+20130622git7de15e7a-1 - I suppose this didn't work for you with jackd2 1.9.9.5 in Windows?
3. You can insert pictures/screen-shots by choosing the "upload attachment" tab underneath the compose window and add the picture, then insert it at the place of where the cursor is in the compose window.

I have tried to install the jack packages from the repository to see how it works with my hardware / configuration, mainly if it works with gmusicbrowser and ALSA (I don't use pulseaudio). I ran in to some problems with that and decided to not pursue it any further since my system works fine as it is, including sound coming from the Windows VM (via USB sound card).

I'm sure your instructions here are extremely helpful for most Xen VGA passthrough users. It's just that I had spent some time and effort to get my audio part into good shape (audiophile setup) and didn't want to screw it up with experimenting with other methods.

Again thanks and I'm sure your contribution will be appreciated by many users.
Asus Sabertooth X79, i7 3930K CPU, 8x4GB Kingston DDR3 RAM, Noctua NH-D14 CPU cooler, Gigabyte GTX 970 + PNY Quadro 2000 GPU, Asus Xonar Essence STX, Sandisk Extreme 120GB + Samsung EVO 850 250GB SSD + 5 HDD, Corsair 500R case, SeaSonic 660W Gold X PS

wollymammoth
Level 1
Level 1
Posts: 5
Joined: Sat Feb 22, 2014 3:24 am

Re: Network sound between 2 computers via netjack2

Postby wollymammoth » Tue Feb 25, 2014 3:33 pm

No problems, this is just the start for me too - I am still trying to get the setup exactly as I want it :)

1. Yes, I was using jackd2 package, but the actual binary is still called 'jackd' - perhaps I need to be a little clearer when I am referring to the package vs the binary.
2. hopefully the version has been bumped in the repo (I will check tonight), but it didn't work for me when I was experimenting earlier (hence this how-to).

3. Thanks for that - I will fix the images when I get back tonight.

As for Alsa and non-jack apps - I am currently experimenting with making a loopback device in Alsa (the tutorials I have tried so far seem to fail for the version of Alsa I have installed) so that jack can capture (and redirect) audio in linux similar to how I have configured windows.

Anyway thanks for the feedback :)


Return to “Tutorials”

Who is online

Users browsing this forum: No registered users and 7 guests