JACK, netjack and remote nodes for active crossover

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view

JACK, netjack and remote nodes for active crossover

Jasper Mackenzie
Good day,

I am building a JACK/NetJACK based crossover (eq/compressors/limiters/etc.) which sources audio from a NetJACK instance, our sinks to active speakers running a netjack client. This is as a POC to replace my friends traditional DBX crossovers and arrays of heavy iron AMPS together with masses of cable with a single laptop, a network switch, and a bunch of powered speakers.

The POC topology is:
    ├── high-l
    │   └── netjack-sink
    │       └── soundcard
    │           └── amplifier
    │               └── speaker
    ├── high-r
    │   └── netjack-sink
    │       └── soundcard
    │           └── amplifier
    │               └── speaker
    ├── input
    │   └── netjack-source
    │       └── soundcard
    │           └── SPDIF-input
    ├── JACK-master
    │   ├── cadence
    │   └── jackd
    │       ├── compressor
    │       ├── crossover
    │       ├── equalizer
    │       ├── etc.
    │       ├── jack-dummy
    │       ├── limiter
    │       └── netmanager
    ├── low-l
    │   └── netjack-sink
    │       └── soundcard
    │           └── amplifier
    │               └── speaker
    ├── low-r
    │   └── netjack-sink
    │       └── soundcard
    │           └── amplifier
    │               └── speaker
    ├── mid-l
    │   └── netjack-sink
    │       └── soundcard
    │           └── amplifier
    │               └── speaker
    ├── mid-r
    │   └── netjack-sink
    │       └── soundcard
    │           └── amplifier
    │               └── speaker
    ├── mixer-in
    │   ├── netjack-sink
    │   │   └── soundcard
    │   │       └── amplifier
    │   │           └── speaker
    │   └── netjack-source
    ├── sub-l
    │   └── netjack-sink
    │       └── soundcard
    │           └── amplifier
    │               └── speaker
    └── sub-r
        └── netjack-sink
            └── soundcard
                └── amplifier
                    └── speaker

I have thus far built a mock example with four atom based laptops as sinks, and normal laptop (KXStudio 18.04) as JACK master, which has brought me here, to ask many questions 8)

1. Documentation
I used the `NetJACK walkthrough` as a starting point, yet as pointed out in https://github.com/jackaudio/jackaudio.github.com/issues/55 it is hardly a complete document.
I will gladly embellish it with my learning from this project, coming in completely cold to the quite phenomenal world of JACK.
If I was to do this, how would I please? As it is a wiki item I cannot do the usual github PR process.
If I did this are there reviewers who can correct and comment?

2. Time Alignment
At the heart of this project is time alignment - I need to be guaranteed that the audio sent from the JACK master is reproduced at exactly the same time at each speaker attached to the slave, or at least that the audio exits the sound card at the same time.

The NetJACK WIKI walkthrough gives two methods for starting a NetJACK slave but is _very_ vague (from the point of view of a novice) as to the differences between the methods. I tried both starting JACK as:
jackd -R -P 90 -I netadapter -C /etc/jackd/jackd-internal-session-file -d alsa -d hw:Intel,0 -r 480000 -D false -o 2 -i 0 -S true

jackd -R -P 90 -I audioadapter -C /etc/jackd/jackd-internal-session-file -d net

* I am running jackd _not_ as jackdbus as jackd is started via a systemd unit on the headless slaves
* JACK_NO_AUDIO_RESERVATION=1 is required to avoid weirdness as "audio device XXX cannot be acquired"
* I am using /etc/jackd/jackd-internal-session-file to connect the dots:
c netadapter:capture_1 system:playback_1
c netadapter:capture_2 system:playback_2
c system:capture_1 audioadapter:playback_1
c system:capture_2 audioadapter:playback_2
Works in both scenarios as they are mutually exclusive 8)

From a listening test alone b) produced consistent sound in the output, but not always, sometimes there was an appreciable delay, especially from NetJACK clients connecting after the others are already playing an audio stream.

So what is the correct way to do this please? I read about master clocks and the difficulties of every sound card having their own clock, and also seen papers by Intel and PulseAudio which claim ridiculous time aligment in sound reproduction over a network - so I assume it can be done 8)

The other side of this is the JACK plugin to give a simple delay. Is there one? I could not find one in Claudia. The Calf Crossover I was using had a delay, but would like _just_ a delay if such a plugin exists, with GUI if possible 8)

I first tried `jacktrip` as this gave me the first results without audio device permissions. I had to modify it to use arbitrary rtaudio devices etc. then tried to overcome its .... connection model ... before going back to NetJACK and issuing a huge sigh of relief in the _rightness_ of NetJACK for my scenario 8)

3. Important parameters for this scenario
I have spent most of my time just trying to get the NetJACK thing going that I have not really had time to consider all the other parameters that are important in this scenario, such as `period`, `nperiods`, `latency` etc. etc.
Please can someone advise as to what I should be using. Audio arriving on time, every time, without jitter or noise at the speakers is more important than a slight delay between input from the mixer and output from the speaker.

The Xiph.org video/infos https://xiph.org/video/vid2.shtml really blew our minds with such a clear definitive answer for audio output quality that I believe 44.1kHz/16bit is the way to go, and the only reason to go near 48k is if the soundcard won't do 44.1 or the source is 48 (checking in here 8)

4. Measuring full loop latency
I saw somewhere (cannot find it now) a JACK plugin/application to measure full loop latency. How could this be practically done in my scenario, especially for automatic time alignment?
I am *not* an audio engineer, but enjoying fiddling, my PA friend is more used to what his hardware gives him. JACK feels like a massive world of freedom and possibilities. What other useful meters/tests/etc. are there that could help us make the most awesome sounding soundstages? Automagic frequency based delays?

5. `audioadapter` settings
In scenario (b) above, `audioadapter` worked fine on most of my slaves where there was only one sound card and nothing much to configure, but in other situations I could not find the parameters or how to set them anywhere in the documentation I looked at. (I am sure it is there!)
But what are the parameters for `audioadapter` and can I set them in the `internal-session-file` as
`l audioadapter <blah> <blah>`
For example I have a USB soundcard which I was trying to use, but could not as I could not set the device - hence I used a modified version of jacktrip initially.

6. I2S vs USB
Another aim of this project is to have _no_ analogue pathways at all. This means Class-D amplifier with digital frontents (harder to find than they should be!)

There are solutions that can take I2S input and equivalently modulator chips which can interface with USB. In terms of ALSA drivers I have found a few I2S projects - mostly for rPi (similar to my final target platform) which all claim to be somewhat incomplete. My experience with the X-FI suggests that USB drivers are not without their issues.

In terms of latency I would assume that I2S offers lower latency due to the reduction in stages compared with USB.

Can anyone comment as to whether any of this matters? An USB->I2S solution seems the most bug free and reliable to me at this stage.

7. Weird errors
On my silly little atom laptops I get strange errors and no audio output if I do not have activity in a physical tty. This is solved by `while true; do dmesg; done` or similar. Is there something that can be done in kernel or similar to avoid hardware sleep (or whatever it is) when no activity?

8. Some other things I have forgotten
And many things I _just don't know_, please point me in the right direction if there are things I have  not even considered yet.
I wish there were more vids by the Xiph guy...


Reply | Threaded
Open this post in threaded view

Re: JACK, netjack and remote nodes for active crossover

Jasper Mackenzie
I can add a little to this for the record:

5. `audioadapter` settings

Probably obvious to some that it is essentially the some/most that is is the same settings as for the other drivers... For the `alsa` settings they are as follows using the source: https://github.com/jackaudio/jack2/blob/master/linux/alsa/JackAlsaAdapter.cpp as reference:

-i  Capture/input channels
-o  Playback/output channels
-P  Playback interface name i.e hw:S51,0
-C Capture interface name - Note: For cards/configurations with _only_ playback this can/should be 'null'
-n Period
-d Card name, i.e hw:PCH
-r Frequency, i.e. 44100
-p Buffer, i.e. 1024
-q Quality, i.e. WTF? no idea, always best?
-g Ring buffer size

 * The settings must quoted as:
jack_load audioadapter -i "-i 0 -o 6 -n 48000 -p 1024 -C null -d dca:S51,0"

 * If the driver is 'net' then '-i' and '-o' are ignored and the number of channels in and out on the master is used. Big PITA!

 * Like any `jack_load` the settings can be placed in an _internal session file_

 * So the quality thing... It is an integer from 0 to 4 for the resampler (default is 0):
I will leave it to the imagination as to what this means 8)