Jackd: Create one ALSA Stereo out from 3 channels

Optimize your system for ultimate performance.

Moderators: MattKingUSA, khz

Post Reply
Babyyoda72
Posts: 2
Joined: Wed Feb 03, 2021 9:55 am

Jackd: Create one ALSA Stereo out from 3 channels

Post by Babyyoda72 »

Hi,

I'm new to audio on Linux, but highly motivated since I discovered "Jamulus, the online Jam software. Jamulus works fine on server side and on macOS, but I'm trying to set up a solution for our drummer who is neither familiar with MacOS nor with Linux. And Windows doesn't work obviously as latency is far too high.

As input for Jamulus I need a Jack Alsa interface which is stereo, but I'd like to have a Mic and stereo drums. I did configure a raspberry PI 4B with a realtime kernel, jamulus and jackd which works fine. It is headless, no desktop. I can only work with shell commands.
Now I'd like to generate a mixed virtual device for jackd with the stereo input from one soundcard and the mono imput from another one (both connected via usb to the RPI). Mono shall be linked on both inputs. For output, I'd like to use just one of the two interfaces, doesn't matter which ones. Or both in parallel...

Soundcard 1 input: L-----------+-------- L: Virtual sound card input
Soundcard 1 input: R -----+------------- R: Virtual sound card input
Soundcard 2 input: L------|----|

Soundcard 1 output L--------------------L: Virtual sound card output (maybe in parallel to Soundard 2 output L)
Soundcard 1 output R--------------------R: Virtual sound card output (maybe in parallel to Soundard 2 output R)

The whole thing is used in a latency critical application.

I found similar problems and solution based on a configuration with .asoundrc. But nothing which is the same to my problem. Also I don't really understand the syntax in that file and couldn't find a good documentation.

I'd be very glad if you could point me in the right direction.

Thanks
Christof
Babyyoda72
Posts: 2
Joined: Wed Feb 03, 2021 9:55 am

Re: Jackd: Create one ALSA Stereo out from 3 channels

Post by Babyyoda72 »

I've been trying for a while now. I really struggle with the asoundrc documentation. Especially how to distinguish inputs and outputs.
As previously explained, I'm using two USB sound cards:

Device_1: Stereo output and Stereo input
Device: Stereo output and Mono input (This input shall be mixed into the input of Device_1

This is the code I tried (copied from different documentation):

# merge - merged device consisting of both sound cards. Only capture is
# further used, therefore only 3 channels are fine
# ( Stereo line in + mono mic)

pcm.merge {
type multi;
slaves.a.pcm hw:Device_1
slaves.a.channels 2;
slaves.b.pcm hw:Device
slaves.b.channels 1;
bindings.0.slave a;
bindings.0.channel 0;
bindings.1.slave a;
bindings.1.channel 1;
bindings.2.slave b;
bindings.2.channel 0;
}


ctl.merge {
type hw
card 0
}

# comdevcp - Combine capture devices

pcm.comdevcp {
type route

# slave is "hw:merge“ which has 3 channels
slave.pcm hw:merge
slave.channels 3

# Transfer Table
# ch0 => slave ch0 (main left)
ttable.0.0 1
# ch1 => slave ch1 (main right)
ttable.1.1 1
# ch0 => slave ch2 (mono)
ttable.0.2 1
# ch1 => slave ch2 (mono, want to hear left and right))
ttable.1.2 1
}

# mandatory part
ctl.comdevcp {
type hw
card 0
}

# comdev - common device

pcm.comdev {
type asym
playback.pcm hw:Device_1
capture.pcm comdevcp
}

# Again, the mandatory "ctl".
ctl.comdev {
type hw
card 0
}

I tried to generate first a merged device out of both sound cards (already here I struggle if I defined herby inputs or outputs or both), then I create the link of the inputs (again how can I distinguish input from output), then I mix the new capture with the playback device.

Unfortunately it doesn't do the job. Jack outputs:

creating alsa driver ... comdev|comdev|64|3|48000|0|0|nomon|swmeter|-|32bit
ALSA lib pcm_hw.c:1822:(_snd_pcm_hw_open) Invalid value for card
ALSA: Cannot open PCM device alsa_pcm for capture. Falling back to playback-only mode
configuring for 48000Hz, period = 64 frames (1.3 ms), buffer = 3 periods
ALSA: final selected sample format for playback: 24bit little-endian in 3bytes format
ALSA: use 3 periods for playback

Hope for your help !
User avatar
Fmajor7add9
Established Member
Posts: 218
Joined: Sun Dec 31, 2017 3:56 am
Location: Might be moving to Montana soon
Has thanked: 48 times
Been thanked: 27 times
Contact:

Re: Jackd: Create one ALSA Stereo out from 3 channels

Post by Fmajor7add9 »

Babyyoda72 wrote: Thu Feb 04, 2021 11:56 am I've been trying for a while now. I really struggle with the asoundrc documentation. Especially how to distinguish inputs and outputs. ...
Did you manage to get any further with this one?
Post Reply