2 interfaces, 2 jackd, couple them

Optimize your system for ultimate performance.

Moderators: MattKingUSA, khz

User avatar
khz
Established Member
Posts: 1648
Joined: Thu Apr 17, 2008 6:29 am
Location: German
Has thanked: 42 times
Been thanked: 92 times

Re: 2 interfaces, 2 jackd, couple them

Post by khz »

The different audio/MIDI interfaces must be synchronized with each other.
khz wrote:Synchronisation your cards: with SPDIF, word clock or an internal sync port.
Is there anything about this in the manual of your used sound card?
(Personal, unverified and possibly false assumption: "? I think you need to synchronize the soundcards over one of the possibilities mentioned above. If it doesn't offer your sound card it won't work. The audioadapter does not do this. ?") IMHO
https://en.wikipedia.org/wiki/Word_clock
https://www.rme-audio.de/english/techinfo/sync.htm (German: https://www.rme-audio.de/techinfo/sync.htm); (https://www.rme-audio.de/download/hdspeaio_e.pdf)
http://manual.ardour.org/synchronization/
. . . FZ - Does humor belongs in Music?
. . GNU/LINUX@AUDIO ~ /Wiki $ Howto.Info && GNU/Linux Debian installing >> Linux Audio Workstation LAW
  • I don't care about the freedom of speech because I have nothing to say.
merlyn
Established Member
Posts: 1392
Joined: Thu Oct 11, 2018 4:13 pm
Has thanked: 168 times
Been thanked: 247 times

Re: 2 interfaces, 2 jackd, couple them

Post by merlyn »

khz wrote:The different audio/MIDI interfaces must be synchronized with each other.
Not many soundcards have that option, especially not budget USB cards. alsa_in, zita-a2j and audioadapter are ways of using multiple soundcards that don't have word clock or S/PDIF sync.

I have found that alsa_in is quite rubbish, zita-a2j is better and audioadapter so far has been usable, even for recording. zita-a2j is OK for a simple monitor, but fell down when I tried to use it as an input to Ardour. audioadapter works as an Xrun free input to Ardour so far. I've had three soundcards going at the same time -- one PCI card as the master, a USB synth through audioadapter and a USB interface with zita-a2j.

How can two or more cards that don't have a sync input be synced? -- They can't.

The solution is to let them drift out of sync and resample the slave card. That is what those three bits of software do with varying degrees of success.
tavasti
Established Member
Posts: 2056
Joined: Tue Feb 16, 2016 6:56 am
Location: Kangasala, Finland
Has thanked: 372 times
Been thanked: 209 times
Contact:

Re: 2 interfaces, 2 jackd, couple them

Post by tavasti »

merlyn wrote:zita-a2j is better and audioadapter so far has been usable, even for recording.
...
The solution is to let them drift out of sync and resample the slave card. That is what those three bits of software do with varying degrees of success.
1) Is audioadapter also doing resample?
2) what happens if clocks run out of sync?

Linux veteran & Novice musician

Latest track: https://www.youtube.com/watch?v=ycVrgGtrBmM

merlyn
Established Member
Posts: 1392
Joined: Thu Oct 11, 2018 4:13 pm
Has thanked: 168 times
Been thanked: 247 times

Re: 2 interfaces, 2 jackd, couple them

Post by merlyn »

First of all I should probably say that audioadapter does not turn two Scarlett Solos into a 2i2 :D

If you want four inputs a four input soundcard is the best solution. If you already have two soundcards and want to use them together audioadapter lets you do that. I use audioadapter to allow me to record my guitar synth over USB. The alternative would be to use the synth's analogue outs into my soundcard's analogue ins. There is no option for sync with my guitar synth.
tavasti wrote:1) Is audioadapter also doing resample?
Yes. It uses Secret Rabbit Code. To avoid using an anti-aliasing filter I set the master and slave cards at the same sample rate, so the quality of the filter is not relevant.
tavasti wrote:2) what happens if clocks run out of sync?
I think the developers would assume the clocks are out of sync. The two clocks are running at a fractionally different speed and phase. The rate will be (very nearly) constant on both, so all three implementations have a calibration stage at the start, where the difference is measured and calculated out. In addition to the JACK buffer there is now a resampling buffer on the slave input introducing extra latency.
User avatar
Primeval_Mudd
Established Member
Posts: 55
Joined: Fri Feb 11, 2022 10:46 pm
Location: Garlinge, Kent, UK
Has thanked: 31 times
Been thanked: 12 times
Contact:

Re: 2 interfaces, 2 jackd, couple them

Post by Primeval_Mudd »

Hi @khz,

As mentioned elsewhere I'm running two Behringer (grr) interfaces - a FLOW8 (F8) and UMC404HD (U192k) - using alsa_in with the FLOW8 as the 'master' and the U192k as the 'slave'.

Code: Select all

alsa_in -j umc -d hw:U192k -c 4
I want to have a bash at using audioadapter but my ignorance has stumped me at the first hurdle*.

When you say:
edit:

Code: Select all

nano /etc/modprobe.d/alsa.conf
Example, take what "/proc/asound/cards" says!
I'm not sure which bits of the /proc/asound/cards list I should use.

Code: Select all

primevalmudd@primevalmudd-laptop:~$ cat /proc/asound/cards
 0 [U192k          ]: USB-Audio - UMC404HD 192k
                      BEHRINGER UMC404HD 192k at usb-0000:00:15.0-2.1.2, high speed
 1 [LPD8           ]: USB-Audio - LPD8
                      AKAI professional LLC LPD8 at usb-0000:00:15.0-2.2, full speed
 2 [PCH            ]: HDA-Intel - HDA Intel PCH
                      HDA Intel PCH at 0x91318000 irq 131
 3 [RD6            ]: USB-Audio - RHYTHM DESIGNER RD-6
                      Behringer RHYTHM DESIGNER RD-6 at usb-0000:00:15.0-2.1.3, full speed
 4 [APRO           ]: USB-Audio - A-PRO
                      Roland A-PRO at usb-0000:00:15.0-2.3, full speed
 5 [F8             ]: USB-Audio - FLOW 8
                      Behringer FLOW 8 at usb-0000:00:15.0-2.4, high speed
 6 [monologue      ]: USB-Audio - monologue
                      KORG INC. monologue at usb-0000:00:15.0-2.1.4, full speed
Can you please help?

* when it comes to mixing metaphors I have no shame.

Dave Plummer/Primeval Mudd*

Ubuntu Studio | Reaper (Linux native)

Facebook | YouTube

  • Should you be wondering, Primeval Mudd is an anagram of David Plummer.
User avatar
khz
Established Member
Posts: 1648
Joined: Thu Apr 17, 2008 6:29 am
Location: German
Has thanked: 42 times
Been thanked: 92 times

Re: 2 interfaces, 2 jackd, couple them

Post by khz »

The only thing that worked reliably for me was the audio adapter. All other methods (alsa_in/...) were unsuccessful.
@USB The USB boot order might be rather random. I have used PCI/PCIe cards where the boot order always remains the same. Therefore it should be difficult.
Since I use only one PCIe card I don't use it anymore.
. . . FZ - Does humor belongs in Music?
. . GNU/LINUX@AUDIO ~ /Wiki $ Howto.Info && GNU/Linux Debian installing >> Linux Audio Workstation LAW
  • I don't care about the freedom of speech because I have nothing to say.
j_e_f_f_g
Established Member
Posts: 2032
Joined: Fri Aug 10, 2012 10:48 pm
Been thanked: 358 times

Re: 2 interfaces, 2 jackd, couple them

Post by j_e_f_f_g »

linuxmusician, here's your red meat.

Author of BackupBand at https://sourceforge.net/projects/backupband/files/
My fans show their support by mentioning my name in their signature.

tavasti
Established Member
Posts: 2056
Joined: Tue Feb 16, 2016 6:56 am
Location: Kangasala, Finland
Has thanked: 372 times
Been thanked: 209 times
Contact:

Re: 2 interfaces, 2 jackd, couple them

Post by tavasti »

khz wrote: Mon Jul 23, 2018 7:37 am

audioadapter:

Code: Select all

jack_load -i "-d hw:1 -i16 -o16" 9632 audioadapter && jack_bufsize 128 &

-d <-- you want to merge (sound card) (hw:1/hw:0/...)
-i <-- your number of sound card inputs
-o <-- your number of sound card outputs
9632 <-- as you want to call them (jackport name)
jack_bufsize <-- set the JACK buffer size
<== Optional: For safety, possibly not mandatory.

I've been using alsa_in when needed, but now hit wall with it: need both alsa_in and alsa_out from same 'extra' interface, and that is not possible: what ever is launched first, will lock the interface, so can't start another.

Therefor I needed to use jack load. But for me, use is not all the time, but when needed, so I run when needed

Code: Select all

jack_load -i "-d hw:Ultra -i6 -o6" ultra audioadapter

Works great, but when running

Code: Select all

jack_unload ultra

whole jack stops. Bit annoying, but I suppose have to live with it.

(Made bug report https://github.com/jackaudio/jack2/issues/933 )

Linux veteran & Novice musician

Latest track: https://www.youtube.com/watch?v=ycVrgGtrBmM

tavasti
Established Member
Posts: 2056
Joined: Tue Feb 16, 2016 6:56 am
Location: Kangasala, Finland
Has thanked: 372 times
Been thanked: 209 times
Contact:

Re: 2 interfaces, 2 jackd, couple them

Post by tavasti »

tavasti wrote: Thu May 11, 2023 6:49 am

I've been using alsa_in when needed, but now hit wall with it: need both alsa_in and alsa_out from same 'extra' interface, and that is not possible: what ever is launched first, will lock the interface, so can't start another.

Therefor I needed to use jack load. But for me, use is not all the time, but when needed, so I run when needed

Code: Select all

jack_load -i "-d hw:Ultra -i6 -o6" ultra audioadapter

Works great, but when running

Code: Select all

jack_unload ultra

whole jack stops. Bit annoying, but I suppose have to live with it.

Oh it does not work that great. When started recording, I am getting just noise, and there is error in logs:

../linux/alsa/JackAlsaAdapter.h:327, unable to set format to either 32-bits or 16-bits : Invalid argument(-22)

So there might be options to pass for audioadapter, but because there isn't too much documentation about it, hard to say :-(

Edit: bug created https://github.com/jackaudio/jack2/issues/934

Last edited by tavasti on Thu May 11, 2023 5:31 pm, edited 1 time in total.

Linux veteran & Novice musician

Latest track: https://www.youtube.com/watch?v=ycVrgGtrBmM

tavasti
Established Member
Posts: 2056
Joined: Tue Feb 16, 2016 6:56 am
Location: Kangasala, Finland
Has thanked: 372 times
Been thanked: 209 times
Contact:

Re: 2 interfaces, 2 jackd, couple them

Post by tavasti »

tavasti wrote: Thu May 11, 2023 4:25 pm

So there might be options to pass for audioadapter, but because there isn't too much documentation about it, hard to say :-(

Ok, use the source: https://github.com/jackaudio/jack2/blob ... r.cpp#L194

Here is from code what params are available. Nothing to say 'use X bits'

Code: Select all

"capture",      'C', "Provide capture ports.  Optionally set device"
"playback",     'P', "Provide playback ports.  Optionally set device"
"device",       'd', "ALSA device name"
"rate",         'r', "Sample rate"
"periodsize",   'p', "Period size"
"nperiods",     'n', "Number of periods of playback latency"
"duplex",       'D', "Provide both capture and playback ports"
"in-channels",  'i', "Number of capture channels (defaults to hardware max)"
"out-channels", 'o', "Number of playback channels (defaults to hardware max)"
"quality",      'q', "Resample algorithm quality (0 - 4)"
"ring-buffer",  'g', "Fixed ringbuffer size"

Linux veteran & Novice musician

Latest track: https://www.youtube.com/watch?v=ycVrgGtrBmM

tavasti
Established Member
Posts: 2056
Joined: Tue Feb 16, 2016 6:56 am
Location: Kangasala, Finland
Has thanked: 372 times
Been thanked: 209 times
Contact:

Re: 2 interfaces, 2 jackd, couple them

Post by tavasti »

Ok, bit more digging, I think I now have answer how this is done.

In jack2 1.9.18 there is new additions, modules zalsa_in and zalsa_out, which are zita-a2j/j2a as jack2 modules. See https://jackaudio.org/news/2021/04/15/j ... lease.html

Then, by mistake (I assume) falktx removed them, and also jack_load in version 1.9.22. So before he adds them back, get git version 1.9.21, and build it:

Code: Select all

./waf configure --prefix=/usr/local/stow/jack2-git --zalsa=yes --dbus --example-tools  --enable-pkg-config-dbus-service-dir
./waf build
./waf clean
cd /usr/local/stow/; sudo stow -v jack2-git ; cd -  

If you don't use stow for keeping your /usr/local clean, then adapt those commands a bit.

If you use jackdbus, you need to restart dbus (or is there way to say it refresh config without restart?) to get new version running. Note that restarting dbus may kill your session (did for me).

Then on usage goes like this:

Code: Select all

jack_load  -i "-d hw:Ultra -c6" ultra-out zalsa_out
jack_load  -i "-d hw:Ultra -c6" ultra-in zalsa_in

Options available for those modules can be seen with

Code: Select all

jack_load  -i "-d hw:Ultra -h" zalsa_in

Options will be shown in jack log, for me it is .log/jack/jackdbus.log

Here is what I found in log:

Code: Select all

zalsa_in-0.4.0
(C) 2012-2018 Fons Adriaensen  <fons@linuxaudio.org> 
Use ALSA capture device as a Jack client.
Options:
  -h                 Display this text
  -j <jackname>      Name as Jack client [zalsa_in] 
  -d <device>        ALSA capture device [none]
  -r <rate>          Sample rate [48000]       
-p <period> Period size [256] -n <nfrags> Number of fragments [2]
-c <nchannels> Number of channels [2] -S Word clock sync, no resampling -Q <quality> Resampling quality, 16..96 [auto] -I <samples> Latency adjustment [0] -L Force 16-bit and 2 channels [off] -w Wait until soundcard is available [off] -v Print tracing information [off]

Linux veteran & Novice musician

Latest track: https://www.youtube.com/watch?v=ycVrgGtrBmM

tavasti
Established Member
Posts: 2056
Joined: Tue Feb 16, 2016 6:56 am
Location: Kangasala, Finland
Has thanked: 372 times
Been thanked: 209 times
Contact:

Re: 2 interfaces, 2 jackd, couple them

Post by tavasti »

tavasti wrote: Thu May 11, 2023 8:14 pm

In jack2 1.9.18 there is new additions, modules zalsa_in and zalsa_out, which are zita-a2j/j2a as jack2 modules. See https://jackaudio.org/news/2021/04/15/j ... lease.html

Then, by mistake (I assume) falktx removed them, and also jack_load in version 1.9.22. So before he adds them back, get git version 1.9.21, and build it:

Ok, it was not mistake, jack_load and also those zalsa-modules were moved to repo https://github.com/jackaudio/jack-example-tools

So solution would be building that, but I don't start trying if that works and what is needed for building it.

Linux veteran & Novice musician

Latest track: https://www.youtube.com/watch?v=ycVrgGtrBmM

merlyn
Established Member
Posts: 1392
Joined: Thu Oct 11, 2018 4:13 pm
Has thanked: 168 times
Been thanked: 247 times

Re: 2 interfaces, 2 jackd, couple them

Post by merlyn »

It's possible to use jack_control to do this.

Code: Select all

$ jack_control
Usage: jack_control [command] [command] ...
Commands:
    shell                      - execute commands from stdin until End Of File (Ctrl+D in terminal)
    exit                       - exit jack dbus service (stops jack server if currently running)
    help                       - print this help text
    status                     - check whether jack server is started, return value is 0 if running and 1 otherwise
    start                      - start jack server if not currently started
    stop                       - stop jack server if currently started
    sm                         - switch master to currently selected driver
    dl                         - get list of available drivers
    dg                         - get currently selected driver
    ds <driver>                - select driver
    dp                         - get parameters of currently selected driver
    dpd <param>                - get long description for driver parameter
    dps <param> <value>        - set driver parameter
    dpr <param>                - reset driver parameter to its default value
    asd <driver>               - add slave driver
    rsd <driver>               - remove slave driver
    il                         - get list of available internals
    ip <name>                  - get parameters of given internal
    ipd <name> <param>         - get long description for internal parameter
    ips <name> <param> <value> - set internal parameter
    ipr <name> <param>         - reset internal parameter to its default value
    iload <name>               - load internal
    iunload <name>             - unload internal
    ep                         - get engine parameters
    epd <param>                - get long description for engine parameter
    eps <param> <value>        - set engine parameter
    epr <param>                - reset engine parameter to its default value

Again, jack_control is something that there is not a lot of documentation for. In fact hardly anyone seems to know it even exists, but I found the output above enough to figure it out.

tavasti
Established Member
Posts: 2056
Joined: Tue Feb 16, 2016 6:56 am
Location: Kangasala, Finland
Has thanked: 372 times
Been thanked: 209 times
Contact:

Re: 2 interfaces, 2 jackd, couple them

Post by tavasti »

merlyn wrote: Fri May 12, 2023 11:29 am

It's possible to use jack_control to do this.

Code: Select all

$ jack_control
Usage: jack_control [command] [command] ...
Commands:
    il                         - get list of available internals
    ip <name>                  - get parameters of given internal

Again, jack_control is something that there is not a lot of documentation for. In fact hardly anyone seems to know it even exists, but I found the output above enough to figure it out.

But for some reason it does not cover zalsa-modules:

Code: Select all

tavasti@hermo:~$ jack_control il
--- internals list
audioadapter
profiler
netadapter
netmanager
tavasti@hermo:~$ jack_control ip zalsa_in
--- get internal parameters (type:isset:default:value)
DBus exception: org.jackaudio.Error.InvalidArgs: Invalid container address 'internals':'zalsa_in':'(null)' supplied to method 'GetParametersInfo'.
tavasti@hermo:~$ jack_load -i "-d hw:Ultra" zalsa_in
zalsa_in is running.
client name = zalsa_in

Linux veteran & Novice musician

Latest track: https://www.youtube.com/watch?v=ycVrgGtrBmM

merlyn
Established Member
Posts: 1392
Joined: Thu Oct 11, 2018 4:13 pm
Has thanked: 168 times
Been thanked: 247 times

Re: 2 interfaces, 2 jackd, couple them

Post by merlyn »

Does this work?

Code: Select all

$ jack_control ip audioadapter
Locked