You are not logged in.

#1 2024-11-01 09:43:22

melodiante
Member
Registered: 2024-11-01
Posts: 6

Help with .asoundrc to create a virtual dev summing all inputs

Hello.
I am building an audio looper (https://github.com/RandomVertebrate/raspi-looper) with a raspberry pi.
I am using a Zoom H5 like USB audio interface and I need raspi-looper to capture the sum of the 4 mono audio inputs in order to use the different instruments and mics connected to the physical inputs of the interface all of them summed and redirected to a single ALSA virtual capture device.
I suppose that I need an aloop (loopback) device created on the ~/.asoundrc file but I need help to configure it.

$ aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: vc4hdmi0 [vc4-hdmi-0], device 0: MAI PCM i2s-hifi-0 [MAI PCM i2s-hifi-0]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: vc4hdmi1 [vc4-hdmi-1], device 0: MAI PCM i2s-hifi-0 [MAI PCM i2s-hifi-0]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 2: Headphones [bcm2835 Headphones], device 0: bcm2835 Headphones [bcm2835 Headphones]
  Subdevices: 8/8
  Subdevice #0: subdevice #0
  Subdevice #1: subdevice #1
  Subdevice #2: subdevice #2
  Subdevice #3: subdevice #3
  Subdevice #4: subdevice #4
  Subdevice #5: subdevice #5
  Subdevice #6: subdevice #6
  Subdevice #7: subdevice #7
card 4: H5 [H5], device 0: USB Audio [USB Audio]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
$ cat /proc/asound/cards
 0 [vc4hdmi0       ]: vc4-hdmi - vc4-hdmi-0
                      vc4-hdmi-0
 1 [vc4hdmi1       ]: vc4-hdmi - vc4-hdmi-1
                      vc4-hdmi-1
 2 [Headphones     ]: bcm2835_headpho - bcm2835 Headphones
                      bcm2835 Headphones
 4 [H5             ]: USB-Audio - H5
                      ZOOM Corporation H5 at usb-0000:01:00.0-1.1, high speed

When I load the kernel module snd-aloop (modprobe snd-aloop) i see this:

$ aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: vc4hdmi0 [vc4-hdmi-0], device 0: MAI PCM i2s-hifi-0 [MAI PCM i2s-hifi-0]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: vc4hdmi1 [vc4-hdmi-1], device 0: MAI PCM i2s-hifi-0 [MAI PCM i2s-hifi-0]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 2: Headphones [bcm2835 Headphones], device 0: bcm2835 Headphones [bcm2835 Headphones]
  Subdevices: 8/8
  Subdevice #0: subdevice #0
  Subdevice #1: subdevice #1
  Subdevice #2: subdevice #2
  Subdevice #3: subdevice #3
  Subdevice #4: subdevice #4
  Subdevice #5: subdevice #5
  Subdevice #6: subdevice #6
  Subdevice #7: subdevice #7
card 3: Loopback [Loopback], device 0: Loopback PCM [Loopback PCM]
  Subdevices: 8/8
  Subdevice #0: subdevice #0
  Subdevice #1: subdevice #1
  Subdevice #2: subdevice #2
  Subdevice #3: subdevice #3
  Subdevice #4: subdevice #4
  Subdevice #5: subdevice #5
  Subdevice #6: subdevice #6
  Subdevice #7: subdevice #7
card 3: Loopback [Loopback], device 1: Loopback PCM [Loopback PCM]
  Subdevices: 8/8
  Subdevice #0: subdevice #0
  Subdevice #1: subdevice #1
  Subdevice #2: subdevice #2
  Subdevice #3: subdevice #3
  Subdevice #4: subdevice #4
  Subdevice #5: subdevice #5
  Subdevice #6: subdevice #6
  Subdevice #7: subdevice #7
card 4: H5 [H5], device 0: USB Audio [USB Audio]
  Subdevices: 1/1
  Subdevice #0: subdevice #0

I need help to configure the .asoundrc file to mix the 4 physical inputs of the Zoom H5 soundcard in a mono virtual device or subdevice in order to use this one like the mono input of the raspi-looper.

Thank you very much :-)

Last edited by melodiante (2024-11-01 09:47:46)

Offline

#2 2024-11-01 21:25:31

melodiante
Member
Registered: 2024-11-01
Posts: 6

Re: Help with .asoundrc to create a virtual dev summing all inputs

I have defined the hardware interface and the loopback device on .asoundrc

pcm.ZoomH5{
    type hw
    card H5
    device 0
    subdevice 0
    nonblock true}

ctl.ZoomH5{
    type hw
    card H5}

pcm.loopin {
    type plug
    slave.pcm "hw:Loopback,0,0"
}

pcm.loopout {
    type plug
    slave.pcm "hw:Loopback,1,0"
}

Now I guess that I will need a mixer in order to sum the 4 input channels and send it to the loopback device, but I don't understand how to use bindings or slaves.

Offline

#3 2024-11-02 12:22:43

Lone_Wolf
Administrator
From: Netherlands, Europe
Registered: 2005-10-04
Posts: 12,926

Re: Help with .asoundrc to create a virtual dev summing all inputs

The Raspberry PI uses an ARM processor and only x86_64 is supported here.

Do you have an x86_64 system with archlinux where you can setup this ?
If not, this thread will have to be dustbinned.


Disliking systemd intensely, but not satisfied with alternatives so focusing on taming systemd.

clean chroot building not flexible enough ?
Try clean chroot manager by graysky

Offline

#4 2024-11-02 13:26:35

melodiante
Member
Registered: 2024-11-01
Posts: 6

Re: Help with .asoundrc to create a virtual dev summing all inputs

Sorry, I understand you.
You are right, Raspberry Pi is an ARM processor. But I think that the question is the same because I am asking help to configure .asoundrc, that is architecture independent.
I am almost sure (sorry if I am in a mistake) that the answer will work in my setup.

If you can give me some orientation, I can ask in another forum and delete this thread.

Thanks.

Offline

#5 2024-11-02 13:28:37

melodiante
Member
Registered: 2024-11-01
Posts: 6

Re: Help with .asoundrc to create a virtual dev summing all inputs

Lone_Wolf wrote:

Do you have an x86_64 system with archlinux where you can setup this ?

Yes. I can try the same .asoundrc config in my lenovo thinkpad that is x86_64.
Then, if it works, I will implement in my rpi.

Thanks :-)

Offline

#6 2024-11-02 13:41:22

Lone_Wolf
Administrator
From: Netherlands, Europe
Registered: 2005-10-04
Posts: 12,926

Re: Help with .asoundrc to create a virtual dev summing all inputs

Please edit a post if no one has responded yet instead of creating  a new one, especially if it has only been a few minutes.

Ok, then this thread can continue.

Let's start  with the output of aplay -lL from the x86_64 system.


Disliking systemd intensely, but not satisfied with alternatives so focusing on taming systemd.

clean chroot building not flexible enough ?
Try clean chroot manager by graysky

Offline

#7 2024-11-02 13:54:55

melodiante
Member
Registered: 2024-11-01
Posts: 6

Re: Help with .asoundrc to create a virtual dev summing all inputs

Lone_Wolf wrote:

Please edit a post if no one has responded yet instead of creating  a new one, especially if it has only been a few minutes.

Understood :-)

Lone_Wolf wrote:

Let's start  with the output of aplay -lL from the x86_64 system.

$ aplay -lL
null
    Discard all samples (playback) or generate zero samples (capture)
lavrate
    Rate Converter Plugin Using Libav/FFmpeg Library
samplerate
    Rate Converter Plugin Using Samplerate Library
speexrate
    Rate Converter Plugin Using Speex Resampler
jack
    JACK Audio Connection Kit
oss
    Open Sound System
pipewire
    PipeWire Sound Server
pulse
    PulseAudio Sound Server
speex
    Plugin using Speex DSP (resample, agc, denoise, echo, dereverb)
upmix
    Plugin for channel upmix (4,6,8)
vdownmix
    Plugin for channel downmix (stereo) with a simple spacialization
default
    Default ALSA Output (currently PipeWire Media Server)
sysdefault:CARD=sofhdadsp
    sof-hda-dsp, 
    Default Audio Device
usbstream:CARD=sofhdadsp
    sof-hda-dsp
    USB Stream Output
sysdefault:CARD=H5
    H5, USB Audio
    Default Audio Device
front:CARD=H5,DEV=0
    H5, USB Audio
    Front output / input
surround21:CARD=H5,DEV=0
    H5, USB Audio
    2.1 Surround output to Front and Subwoofer speakers
surround40:CARD=H5,DEV=0
    H5, USB Audio
    4.0 Surround output to Front and Rear speakers
surround41:CARD=H5,DEV=0
    H5, USB Audio
    4.1 Surround output to Front, Rear and Subwoofer speakers
surround50:CARD=H5,DEV=0
    H5, USB Audio
    5.0 Surround output to Front, Center and Rear speakers
surround51:CARD=H5,DEV=0
    H5, USB Audio
    5.1 Surround output to Front, Center, Rear and Subwoofer speakers
surround71:CARD=H5,DEV=0
    H5, USB Audio
    7.1 Surround output to Front, Center, Side, Rear and Woofer speakers
iec958:CARD=H5,DEV=0
    H5, USB Audio
    IEC958 (S/PDIF) Digital Audio Output
usbstream:CARD=H5
    H5
    USB Stream Output
**** List of PLAYBACK Hardware Devices ****
card 0: sofhdadsp [sof-hda-dsp], device 0: HDA Analog (*) []
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: sofhdadsp [sof-hda-dsp], device 3: HDMI1 (*) []
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: sofhdadsp [sof-hda-dsp], device 4: HDMI2 (*) []
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: sofhdadsp [sof-hda-dsp], device 5: HDMI3 (*) []
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: sofhdadsp [sof-hda-dsp], device 31: HDA Analog Deep Buffer (*) []
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: H5 [H5], device 0: USB Audio [USB Audio]
  Subdevices: 1/1
  Subdevice #0: subdevice #0

I have tried with this .asoundrc file:

pcm.ZoomH5{
    type hw
    card H5
    device 0
    subdevice 0
    nonblock true}

ctl.ZoomH5{
    type hw
    card H5}

pcm.mixinputs {
        type dsnoop
        ipc_key 234884
        slave {
                pcm ZoomH5
                channels 4
                rate 48000
        }
        bindings.0 0
        bindings.1 0
        bindings.2 0
        bindings.3 0
}

pcm.record_mono {
        type plug
        slave.pcm "mixinputs"
}

... and when I record a wav from the record_mono device:

arecord -f dat -c 1 -D record_mono ./shared/foobar.wav

... I get a stereo file with the same channel 0 from ZommH5 in both left and right (sounding mono).

Is clear that I am not doing it right.


Another question: Is needed to reboot the entire machine in order to take effects the changes at .asoundrc?

Last edited by melodiante (2024-11-02 14:41:18)

Offline

#8 2024-11-02 19:33:23

melodiante
Member
Registered: 2024-11-01
Posts: 6

Re: Help with .asoundrc to create a virtual dev summing all inputs

Hello Again.
Sorry for the new post but I have advanced in the solution.
Loading the kernel moodule snd-aloop at boot and with this .asoundrc:

pcm.ZoomH5{
    type hw
    card H5
    device 0
    subdevice 0
    nonblock true}

ctl.ZoomH5{
    type hw
    card H5}

pcm.loopin {
    type plug
    slave.pcm "hw:Loopback,0,0"
}

pcm.loopout {
    type plug
    slave.pcm "hw:Loopback,1,0"
}

pcm.mixinputs {
	type dsnoop
	ipc_key 234884
	slave {
		pcm ZoomH5
		channels 4
		rate 48000
	}
	bindings {
		0 0
		1 1
		2 2
		3 3
	}
}

pcm.record_mono {
	type plug
	slave.pcm "mixinputs"
    route_policy "duplicate"
}

I am able to record a wav file with

arecord -f dat -c 1 -D record_mono ./shared/foobar.wav

that contains a mono mix of inputs 1, 2, 3 and 4

Now I need to copy this dsnoop out onto loopback device in order to be able to select this device from any audio software.
Please help, I don't know how to do that.

One question I have is how many audio channels has the "mixinputs" pcm?

Last edited by melodiante (2024-11-02 19:34:26)

Offline

Board footer

Powered by FluxBB