Mini-guide for networking with Jack

Unofficial support for the KXStudio Linux distribution and applications.
More info at http://kxstudio.linuxaudio.org/

Moderators: MattKingUSA, khz

Post Reply
tangerine
Established Member
Posts: 66
Joined: Tue Jul 29, 2014 12:08 pm

Mini-guide for networking with Jack

Post by tangerine »

This guide builds on my personal experience in making such a networking setup. It doesn't aim to cover every corner case. Basically it is to tell you what works for me and a bit about what doesn't and where are the pitfalls.

Prerequisites and general considerations:

This guide assumes you have some experience with and basic understanding of the following: linux, jack, tcp/ip networking. Or that you know how to google and read manuals.

Before attempting Jack networking, make sure you have a functioning wired network between your machines. This _might_ work with wireless, but I doubt this can be any good for serious processing, esp. multichannel. You are welcome to prove me wrong.

By Jack I mean Jack2, as this is what I'm working with. This guide won't work for Jack1 (but it might give you some general idea).
Please note that Jack2 may have it's own caveats, so if unsure, please go read a bit about it and then judge by yourself if you're into it. Personally I'm fine with it.

You will need at least one master and one slave computer with Jack2 set up. In case you have jack1 installed, jack2 will replace it.

You can in fact mix Windows and Linux computers in jack networking, and that's exactly what I have in my setup. I don't have a Mac, but perhaps you can also employ one here, too.

On Linux machines, make sure you are working with the dbus version of jack, as the "normal" jackd probably won't do everything you want it to and because some tools are strictly jackdbus-oriented. This especially applies to manually-compiled versions of jack, you need to make sure that you enable dbus support when you configure the build. If you run the pre-compiled repository version of Jack, chances are it supports dbus already out-of-the-box.

On Linux machines, forget the qjackctl, it doesn't play nicely with jackdbus. Use Cadence from the KXstudio toolset instead to start and stop Jack. At the time of this writing, Cadence does not feature configuration of Jack network drivers, but otherwise it is handy and solid. Configure Jack through jack_control command-line tool which is a part of jack2 package. jack_control is not incredibly easy to use, but as soon as you have it configured, it will store your settings and Cadence will start jack with these settings applied. First time after you change config from jack_control, you will need to stop jack, quit Cadence, kill jackdbus, and then start Cadence again in order to have jackdbus loaded with the configuration you made through jack_control.
jack_control is a userland tool, so don't run it with sudo. your settings will be stored in

Code: Select all

~/.config/jack/conf.xml
As of this writing, there is no Cadence for Windows machines, as Cadence depends on dbus framework and Windows doesn't come with dbus (however there is in fact dbus for windows, so hopefully things will change). I'm using qjackctl there instead.

For numerous reasons, it is perhaps preferable in such a cross-platform configuration to have Windows machine as a master and Linux machines as slaves. At least I figure this is the easier and more robust way to do it, so I didn't try it the other way around.

Please note that networked slaves in the basic jack setup play the role of processing extensions of the master machine. They do not need to have an audio interface of their own, at least it won't be employed in jack. The only machine that is going to perform any kind of A/D and D/A is your master. The slaves run "net" jack driver instead of the regular audio driver.
Through additional loadable jack modules ("internals" as they're called in jack slang), it is possible to use your slaves' audio interfaces in a network setup, but this will usually require audio resampling on the slave machine. Resampling does not fit into professional-quality audio processing as I see it. As a sidenote, it _might_ be possible to use slave's audio interface without resampling, _if_ slave's and master's audio interfaces are physically synchronized (like with a wordclock cable), however you'll need to make further research on how and if it is possible to actually disable resampling in jack's modules. If you come up with something, I'd be glad to hear.

On Windows Jack employs Portaudio to communicate with the ASIO system. Portaudio is like a "proxy" driver which is there to transparently connect jack to the asio framework. The windows version of Jack comes with the Portaudio driver out-of-the-box. If you're using a windows machine as a master for Jack networking, you just need to choose "portaudio" for driver in qjackctl, and then choose your "real" asio driver for your hardware for "input" and "output". Don't bother trying the other drivers from the menu, they do nothing on Windows. Except for the "net" driver, which is for the slave side.

Finally, take into consideration that maximal audio resolution in Jack (1 and 2) is 32 bits floating-point. Meaning that if you send audio in 64-bit resolution to Jack, the less significant 32 bits will be truncated. There is no way to change it. This is _not_ related to 64 vs 32-bit architectures, this is _only_ about the audio engine resolution. Frankly I'm not sure if there is any audible difference with 64-bit resolution, and in case you have some expertise on this, you are most welcome to drop a line in comments.

-----------------------------------------------------------------------------------------------------------------------------------

Here is how my system is configured. If you need to use any deviations from this setup, you'll have to work them out by yourself, as I only tried to do it this way.

How to set up Windows Master:
1) Set up wired network interface properly. If needed, give it a static IP address.
1) run qjackctl, make sure to set it up properly with your audio interface, then run the engine, make sure it is running.
2) in the command prompt, go to your jack installation folder (for instance, c:\program files (x86)\jack) and run this command:

Code: Select all

jack_load netmanager
This is to load the networking master module of jack, called Netmanager. Once loaded, it will continuously attempt to establish connections with slaves, simultaneously on all existing network interfaces.

How to set up Linux slaves:
1) In Cadence, make sure audio bridges are disabled and not running (pulseaudio, alsa).
2) Stop Jack, exit Cadence and every other application that might be using Jack.
3) Optional: Set up jack to communicate directly with master by configuring driver parameters:

Code: Select all

jack_control ds net
jack_control dps multicast-ip xxx.xxx.xxx.xxx
(where xxx.xxx.xxx.xxx is your master's ip)
This is not absolutely necessary for every case, but this is better in cases when the slave has more than one network card in place.
4) In Network Manager, properly configure the wired config for the connection you want to use with jack. If necessary, set up static IP address (this is beyond the scope of this guide). Note that there is some weird bug in current Network Manager that, as soon as you introduce changes to your interface settings for the first time, might require a reboot before it will actually let you use the interface. If required, reboot and then double-check that the interface is set up properly.
4.1) Optional: In case you have more than one network card and you want to use the wired connection exclusively for jack communication, while simultaneously having the other network card do every other network communication (such as connecting to the Internet), it might be required to do the following:
In Network Manager, in the wired connection's properties, go to "IPv4" tab, click on "Routes", and enable "Use only for resources on this connection".
If you do this, you will absolutely need to do (3) too, otherwise your client won't connect to your master.
5) Kill jackdbus or reboot
6) Start Cadence and make sure that the "Net" driver is selected. Start jack.

Your slave should now show on master's list of connections. If it doesn't, try restarting jack on your master machine (remember to jack_load netmanger after you restart jack).

You still need to connect everything through Jack interface on the Master and slave/s to have the actual signal flowing.

Notes:
1) I'm no guru. This guide might or might not work for you. I might try to help when I have time. But RTFM first.
2) Your Jack networking might work out of the box in some cases, yet in others you might need to adjust your network setup, which requires understanding of some basic principles of TCP/IP communication and correctly setting up network services, incl. things like firewall. It won't hurt to see what your network interface is capable of and maybe adjust it's buffer sizes etc. This topic is beyond the scope of this guide and in most cases I will not attempt to provide assistance on this. Anyway, if you cannot ping master from slave and backwards, then you need to take care of your network setup before trying networking with jack.
3) You might need to set up relatively large buffer sizes on both master and slave/s. This depends on the number of channels vs available network bandwidth, and on processing load on the slave [and, to a lesser degree, on the master]. Experiment and see what fits you best.
4) If you have gigabit-capable network cards, you might get better performance with jack if set up correctly. Read through the available information in jack_control and google.
5) Networking requires processing power. If your network card is capable of checksum offload, your CPU will have more cpu cycles left to process audio. Just make sure checksum offloading is enabled.
6) Only enable as many channels between master and slaves as necessary. Each additional channel will increase system and network load. You can change the number of channels in jack_control.
7) Jack2 on windows may need to be run with the -S switch. Read about synchronous and asynchronous modes in jack2, esp. in the context of Windows.
8 ) Every time you restart jack on your master machine, you will have to jack_load netmanager from the command line. Until auto-loading jack modules is implemented in jack, in Cadence or elsewhere.
9) If this little guide helped you, I'll be glad to hear from you and what's your setup and tasks
10) If you have anything to add or to correct in this guide, please write about it in comments
11) Peace! :P
User avatar
Michael Z Freeman
Established Member
Posts: 43
Joined: Thu Dec 17, 2009 1:49 pm
Location: England
Contact:

Re: Mini-guide for networking with Jack

Post by Michael Z Freeman »

Don't know why no one has replied to this as this is a great guide ! Very clearly worded. It got Netjack2 working for me between a Linux and Windows machine. I never got it working following the, frankly, badly written guide on the Jack site ...

WalkThrough_User_NetJack2: https://github.com/jackaudio/jackaudio. ... r_NetJack2.

It does not really walk you through it at all and I actually put in a bug report.

https://github.com/jackaudio/jackaudio. ... /issues/55

So, thanks again man :mrgreen:
Post Reply