• WANTED: Happy members who like to discuss audio and other topics related to our interest. Desire to learn and share knowledge of science required. There are many reviews of audio hardware and expert members to help answer your questions. Click here to have your audio equipment measured for free!

RPi + CamillaDSP Tutorial

MCH

Major Contributor
Joined
Apr 10, 2021
Messages
2,720
Likes
2,357
I've spend a little more time i'd be willing to admit trying to get Camilladsp setup on my RPi and believe to be stuck.
Followed the installation guide, but i think there's either a problem with my config file or the way my Octa Capture is handled by ubuntu?
This is as far as i'm getting trying to boot camilla:

I'm getting the error
2024-04-27 14:08:19.958993 ERROR [src/bin.rs:307] Capture error: ALSA function 'snd_pcm_hw_params_set_channels' failed with error 'EINVAL: Invalid argument'

I've attached the log and config file, i really hope there is somebody able to get me going; i'dd really love to get this working!
Thanks in advance

Log
Code:
024-04-27 14:08:19.728271 INFO [src/bin.rs:683] CamillaDSP version 2.0.3
2024-04-27 14:08:19.728381 INFO [src/bin.rs:684] Running on linux, aarch64
2024-04-27 14:08:19.728464 DEBUG [src/bin.rs:728] Loaded state: None
2024-04-27 14:08:19.728485 DEBUG [src/bin.rs:732] Using command line argument for initial volume
2024-04-27 14:08:19.728499 DEBUG [src/bin.rs:755] Using default initial mute
2024-04-27 14:08:19.728512 DEBUG [src/bin.rs:765] Initial mute: [false, false, false, false, false]
2024-04-27 14:08:19.728528 DEBUG [src/bin.rs:766] Initial volume: [-40.0, -40.0, -40.0, -40.0, -40.0]
2024-04-27 14:08:19.728551 DEBUG [src/bin.rs:768] Read config file Some("/home/kerwin/camilladsp/configs/octacapture.yml")
2024-04-27 14:08:19.730326 DEBUG [src/bin.rs:808] Config is valid
2024-04-27 14:08:19.730967 DEBUG [src/socketserver.rs:432] Start websocket server on 127.0.0.1:1234
2024-04-27 14:08:19.731320 DEBUG [src/bin.rs:994] Wait for config
2024-04-27 14:08:19.731357 DEBUG [src/bin.rs:1010] Waiting to receive a command
2024-04-27 14:08:19.731374 DEBUG [src/bin.rs:1013] Config change command received
2024-04-27 14:08:19.731390 DEBUG [src/bin.rs:999] New config is available and there are no queued commands, continuing
2024-04-27 14:08:19.731403 DEBUG [src/bin.rs:1036] Config ready, start processing
2024-04-27 14:08:19.732087 DEBUG [src/bin.rs:157] Using channels [false, false, true, true]
2024-04-27 14:08:19.732013 DEBUG [src/filters.rs:488] Build new pipeline
2024-04-27 14:08:19.732505 DEBUG [src/processing.rs:19] build filters, waiting to start processing loop
2024-04-27 14:08:19.954234 DEBUG [src/alsadevice.rs:334] Available Capture devices: [("hw:Loopback,0,0", "Loopback, Loopback PCM, subdevice #0"), ("hw:Loopback,0,1", "Loopback, Loopback PCM, subdevice #1"), ("hw:Loopback,0,2", "Loopback, Loopback PCM, subdevice #2"), ("hw:Loopback,0,3", "Loopback, Loopback PCM, subdevice #3"), ("hw:Loopback,0,4", "Loopback, Loopback PCM, subdevice #4"), ("hw:Loopback,0,5", "Loopback, Loopback PCM, subdevice #5"), ("hw:Loopback,0,6", "Loopback, Loopback PCM, subdevice #6"), ("hw:Loopback,0,7", "Loopback, Loopback PCM, subdevice #7"), ("hw:Loopback,1,0", "Loopback, Loopback PCM, subdevice #0"), ("hw:Loopback,1,1", "Loopback, Loopback PCM, subdevice #1"), ("hw:Loopback,1,2", "Loopback, Loopback PCM, subdevice #2"), ("hw:Loopback,1,3", "Loopback, Loopback PCM, subdevice #3"), ("hw:Loopback,1,4", "Loopback, Loopback PCM, subdevice #4"), ("hw:Loopback,1,5", "Loopback, Loopback PCM, subdevice #5"), ("hw:Loopback,1,6", "Loopback, Loopback PCM, subdevice #6"), ("hw:Loopback,1,7", "Loopback, Loopback PCM, subdevice #7"), ("hw:OCTACAPTURE,0,0", "OCTA-CAPTURE, USB Audio, subdevice #0"), ("null", "Discard all samples (playback) or generate zero samples (capture)"), ("hw:CARD=Loopback,DEV=0", "Loopback, Loopback PCM\nDirect hardware device without any conversions"), ("hw:CARD=Loopback,DEV=1", "Loopback, Loopback PCM\nDirect hardware device without any conversions"), ("plughw:CARD=Loopback,DEV=0", "Loopback, Loopback PCM\nHardware device with all software conversions"), ("plughw:CARD=Loopback,DEV=1", "Loopback, Loopback PCM\nHardware device with all software conversions"), ("default:CARD=Loopback", "Loopback, Loopback PCM\nDefault Audio Device"), ("sysdefault:CARD=Loopback", "Loopback, Loopback PCM\nDefault Audio Device"), ("front:CARD=Loopback,DEV=0", "Loopback, Loopback PCM\nFront output / input"), ("dsnoop:CARD=Loopback,DEV=0", "Loopback, Loopback PCM\nDirect sample snooping device"), ("dsnoop:CARD=Loopback,DEV=1", "Loopback, Loopback PCM\nDirect sample snooping device"), ("hw:CARD=OCTACAPTURE,DEV=0", "OCTA-CAPTURE, USB Audio\nDirect hardware device without any conversions"), ("plughw:CARD=OCTACAPTURE,DEV=0", "OCTA-CAPTURE, USB Audio\nHardware device with all software conversions"), ("default:CARD=OCTACAPTURE", "OCTA-CAPTURE, USB Audio\nDefault Audio Device"), ("sysdefault:CARD=OCTACAPTURE", "OCTA-CAPTURE, USB Audio\nDefault Audio Device"), ("front:CARD=OCTACAPTURE,DEV=0", "OCTA-CAPTURE, USB Audio\nFront output / input"), ("dsnoop:CARD=OCTACAPTURE,DEV=0", "OCTA-CAPTURE, USB Audio\nDirect sample snooping device")]
2024-04-27 14:08:19.958625 DEBUG [src/alsadevice.rs:352] Capture: supported channels, min: 12, max: 12, list: [12]
2024-04-27 14:08:19.958696 DEBUG [src/alsadevice.rs:353] Capture: setting channels to 4
2024-04-27 14:08:19.958993 ERROR [src/bin.rs:307] Capture error: ALSA function 'snd_pcm_hw_params_set_channels' failed with error 'EINVAL: Invalid argument'
2024-04-27 14:08:19.959036 DEBUG [src/bin.rs:309] Error while starting, release barrier
2024-04-27 14:08:19.977977 DEBUG [src/alsadevice.rs:334] Available Playback devices: [("hw:Loopback,0,0", "Loopback, Loopback PCM, subdevice #0"), ("hw:Loopback,0,1", "Loopback, Loopback PCM, subdevice #1"), ("hw:Loopback,0,2", "Loopback, Loopback PCM, subdevice #2"), ("hw:Loopback,0,3", "Loopback, Loopback PCM, subdevice #3"), ("hw:Loopback,0,4", "Loopback, Loopback PCM, subdevice #4"), ("hw:Loopback,0,5", "Loopback, Loopback PCM, subdevice #5"), ("hw:Loopback,0,6", "Loopback, Loopback PCM, subdevice #6"), ("hw:Loopback,0,7", "Loopback, Loopback PCM, subdevice #7"), ("hw:Loopback,1,0", "Loopback, Loopback PCM, subdevice #0"), ("hw:Loopback,1,1", "Loopback, Loopback PCM, subdevice #1"), ("hw:Loopback,1,2", "Loopback, Loopback PCM, subdevice #2"), ("hw:Loopback,1,3", "Loopback, Loopback PCM, subdevice #3"), ("hw:Loopback,1,4", "Loopback, Loopback PCM, subdevice #4"), ("hw:Loopback,1,5", "Loopback, Loopback PCM, subdevice #5"), ("hw:Loopback,1,6", "Loopback, Loopback PCM, subdevice #6"), ("hw:Loopback,1,7", "Loopback, Loopback PCM, subdevice #7"), ("hw:b1,0,0", "bcm2835 HDMI 1, bcm2835 HDMI 1, subdevice #0"), ("hw:b1,0,1", "bcm2835 HDMI 1, bcm2835 HDMI 1, subdevice #1"), ("hw:b1,0,2", "bcm2835 HDMI 1, bcm2835 HDMI 1, subdevice #2"), ("hw:b1,0,3", "bcm2835 HDMI 1, bcm2835 HDMI 1, subdevice #3"), ("hw:Headphones,0,0", "bcm2835 Headphones, bcm2835 Headphones, subdevice #0"), ("hw:Headphones,0,1", "bcm2835 Headphones, bcm2835 Headphones, subdevice #1"), ("hw:Headphones,0,2", "bcm2835 Headphones, bcm2835 Headphones, subdevice #2"), ("hw:Headphones,0,3", "bcm2835 Headphones, bcm2835 Headphones, subdevice #3"), ("hw:OCTACAPTURE,0,0", "OCTA-CAPTURE, USB Audio, subdevice #0"), ("null", "Discard all samples (playback) or generate zero samples (capture)"), ("hw:CARD=Loopback,DEV=0", "Loopback, Loopback PCM\nDirect hardware device without any conversions"), ("hw:CARD=Loopback,DEV=1", "Loopback, Loopback PCM\nDirect hardware device without any conversions"), ("plughw:CARD=Loopback,DEV=0", "Loopback, Loopback PCM\nHardware device with all software conversions"), ("plughw:CARD=Loopback,DEV=1", "Loopback, Loopback PCM\nHardware device with all software conversions"), ("default:CARD=Loopback", "Loopback, Loopback PCM\nDefault Audio Device"), ("sysdefault:CARD=Loopback", "Loopback, Loopback PCM\nDefault Audio Device"), ("front:CARD=Loopback,DEV=0", "Loopback, Loopback PCM\nFront output / input"), ("surround21:CARD=Loopback,DEV=0", "Loopback, Loopback PCM\n2.1 Surround output to Front and Subwoofer speakers"), ("surround40:CARD=Loopback,DEV=0", "Loopback, Loopback PCM\n4.0 Surround output to Front and Rear speakers"), ("surround41:CARD=Loopback,DEV=0", "Loopback, Loopback PCM\n4.1 Surround output to Front, Rear and Subwoofer speakers"), ("surround50:CARD=Loopback,DEV=0", "Loopback, Loopback PCM\n5.0 Surround output to Front, Center and Rear speakers"), ("surround51:CARD=Loopback,DEV=0", "Loopback, Loopback PCM\n5.1 Surround output to Front, Center, Rear and Subwoofer speakers"), ("surround71:CARD=Loopback,DEV=0", "Loopback, Loopback PCM\n7.1 Surround output to Front, Center, Side, Rear and Woofer speakers"), ("dmix:CARD=Loopback,DEV=0", "Loopback, Loopback PCM\nDirect sample mixing device"), ("dmix:CARD=Loopback,DEV=1", "Loopback, Loopback PCM\nDirect sample mixing device"), ("hw:CARD=b1,DEV=0", "bcm2835 HDMI 1, bcm2835 HDMI 1\nDirect hardware device without any conversions"), ("plughw:CARD=b1,DEV=0", "bcm2835 HDMI 1, bcm2835 HDMI 1\nHardware device with all software conversions"), ("default:CARD=b1", "bcm2835 HDMI 1, bcm2835 HDMI 1\nDefault Audio Device"), ("sysdefault:CARD=b1", "bcm2835 HDMI 1, bcm2835 HDMI 1\nDefault Audio Device"), ("dmix:CARD=b1,DEV=0", "bcm2835 HDMI 1, bcm2835 HDMI 1\nDirect sample mixing device"), ("hw:CARD=Headphones,DEV=0", "bcm2835 Headphones, bcm2835 Headphones\nDirect hardware device without any conversions"), ("plughw:CARD=Headphones,DEV=0", "bcm2835 Headphones, bcm2835 Headphones\nHardware device with all software conversions"), ("default:CARD=Headphones", "bcm2835 Headphones, bcm2835 Headphones\nDefault Audio Device"), ("sysdefault:CARD=Headphones", "bcm2835 Headphones, bcm2835 Headphones\nDefault Audio Device"), ("dmix:CARD=Headphones,DEV=0", "bcm2835 Headphones, bcm2835 Headphones\nDirect sample mixing device"), ("hw:CARD=OCTACAPTURE,DEV=0", "OCTA-CAPTURE, USB Audio\nDirect hardware device without any conversions"), ("plughw:CARD=OCTACAPTURE,DEV=0", "OCTA-CAPTURE, USB Audio\nHardware device with all software conversions"), ("default:CARD=OCTACAPTURE", "OCTA-CAPTURE, USB Audio\nDefault Audio Device"), ("sysdefault:CARD=OCTACAPTURE", "OCTA-CAPTURE, USB Audio\nDefault Audio Device"), ("front:CARD=OCTACAPTURE,DEV=0", "OCTA-CAPTURE, USB Audio\nFront output / input"), ("surround21:CARD=OCTACAPTURE,DEV=0", "OCTA-CAPTURE, USB Audio\n2.1 Surround output to Front and Subwoofer speakers"), ("surround40:CARD=OCTACAPTURE,DEV=0", "OCTA-CAPTURE, USB Audio\n4.0 Surround output to Front and Rear speakers"), ("surround41:CARD=OCTACAPTURE,DEV=0", "OCTA-CAPTURE, USB Audio\n4.1 Surround output to Front, Rear and Subwoofer speakers"), ("surround50:CARD=OCTACAPTURE,DEV=0", "OCTA-CAPTURE, USB Audio\n5.0 Surround output to Front, Center and Rear speakers"), ("surround51:CARD=OCTACAPTURE,DEV=0", "OCTA-CAPTURE, USB Audio\n5.1 Surround output to Front, Center, Rear and Subwoofer speakers"), ("surround71:CARD=OCTACAPTURE,DEV=0", "OCTA-CAPTURE, USB Audio\n7.1 Surround output to Front, Center, Side, Rear and Woofer speakers"), ("iec958:CARD=OCTACAPTURE,DEV=0", "OCTA-CAPTURE, USB Audio\nIEC958 (S/PDIF) Digital Audio Output"), ("dmix:CARD=OCTACAPTURE,DEV=0", "OCTA-CAPTURE, USB Audio\nDirect sample mixing device")]
2024-04-27 14:08:19.981141 DEBUG [src/alsadevice.rs:352] Playback: supported channels, min: 10, max: 10, list: [10]
2024-04-27 14:08:19.981210 DEBUG [src/alsadevice.rs:353] Playback: setting channels to 4
2024-04-27 14:08:19.981385 DEBUG [src/bin.rs:312] Wait for playback thread to exit..
2024-04-27 14:08:19.981586 DEBUG [src/processing.rs:21] Processing loop starts now!
2024-04-27 14:08:19.981743 DEBUG [src/bin.rs:1038] Processing ended with status Ok(Restart)
2024-04-27 14:08:19.981778 DEBUG [src/bin.rs:1052] Restarting with new config
2024-04-27 14:08:19.981791 DEBUG [src/bin.rs:994] Wait for config

Config File:
Code:
description: null
devices:
  adjust_period: 10
  capture:
    channels: 4
    device: hw:OCTACAPTURE
    format: S32LE
    type: Alsa
  capture_samplerate: 41000
  chunksize: 1024
  enable_rate_adjust: false
  playback:
    channels: 4
    device: hw:OCTACAPTURE
    format: S32LE
    type: Alsa
  queuelimit: 4
  rate_measure_interval: 1
  samplerate: 41000
  silence_threshold: -100
  silence_timeout: 5
  stop_on_rate_change: false
  target_level: 1024
  volume_ramp_time: null
filters: null
mixers:
  4x4:
    channels:
      in: 4
      out: 4
    description: null
    mapping:
    - dest: 0
      mute: false
      sources:
      - channel: 2
        gain: 0
        inverted: false
        mute: false
        scale: null
    - dest: 1
      mute: false
      sources:
      - channel: 3
        gain: 0
        inverted: false
        mute: false
        scale: null
    - dest: 2
      mute: false
      sources:
      - channel: 2
        gain: 0
        inverted: false
        mute: false
        scale: null
    - dest: 3
      mute: false
      sources:
      - channel: 3
        gain: 0
        inverted: false
        mute: false
        scale: null
pipeline:
- bypassed: null
  description: null
  name: 4x4
  type: Mixer
processors: null
title: Analog
I don't know your device, but I read that at 41kHz it supports 12 channels capture and 10 channels playbak also your log suggests the same:

src/alsadevice.rs:352] Capture: supported channels, min: 12, max: 12, list: [12]

src/alsadevice.rs:352] Playback: supported channels, min: 10, max: 10, list: [10]

But you set 4 channels. I would try setting the number of channels accordingly in your config and give it a try
 

kerwin

New Member
Joined
Apr 27, 2024
Messages
3
Likes
0
can you try with 10, the maximum of input channels.
Thanks, i didn't know you had to use all channels.
I had to adjust the channels, format and sampling rate using information i got from aplay
Small step forward, it boots but gives me a sampling rate warning.
This changes every second or so:
2024-04-27 17:25:20.873867 WARN [src/alsadevice.rs:779] sample rate change detected, last rate was 28084.176587296097 Hz

At the same time I/O on the interface are going crazy.

Config file is now:
Code:
description: null
devices:
  adjust_period: 10
  capture:
    channels: 12
    device: hw:OCTACAPTURE
    format: S32LE
    type: Alsa
  capture_samplerate: 44100
  chunksize: 1024
  enable_rate_adjust: false
  playback:
    channels: 10
    device: hw:OCTACAPTURE
    format: S32LE
    type: Alsa
  queuelimit: 4
  rate_measure_interval: 1
  samplerate: 44100
  silence_threshold: -4000
  silence_timeout: 5
  stop_on_rate_change: false
  target_level: 1024
  volume_ramp_time: null
filters: null
mixers:
  12x10:
    channels:
      in: 12
      out: 10
    description: null
    mapping:
    - dest: 0
      mute: false
      sources:
      - channel: 0
        gain: -40
        inverted: false
        mute: false
        scale: null
    - dest: 1
      mute: false
      sources:
      - channel: 1
        gain: -40
        inverted: false
        mute: false
        scale: null
    - dest: 2
      mute: false
      sources:
      - channel: 0
        gain: -40
        inverted: false
        mute: false
        scale: null
    - dest: 3
      mute: false
      sources:
      - channel: 1
        gain: -40
        inverted: false
        mute: false
        scale: null
    - dest: 4
      mute: false
      sources:
      - channel: 0
        gain: -40
        inverted: false
        mute: false
        scale: null
    - dest: 5
      mute: false
      sources:
      - channel: 1
        gain: -40
        inverted: false
        mute: false
        scale: null
    - dest: 6
      mute: false
      sources:
      - channel: 0
        gain: -40
        inverted: false
        mute: false
        scale: null
    - dest: 7
      mute: false
      sources:
      - channel: 1
        gain: -40
        inverted: false
        mute: false
        scale: null
    - dest: 8
      mute: false
      sources:
      - channel: 0
        gain: -40
        inverted: false
        mute: false
        scale: null
    - dest: 9
      mute: false
      sources:
        - channel: 1
          gain: -40
          inverted: false
          mute: false
          scale: null
pipeline:
- bypassed: null
  description: null
  name: 12x10
  type: Mixer
processors: null
title: null
 

tinnitus

Active Member
Joined
Jan 26, 2021
Messages
152
Likes
208
Location
Germany
Hi Kerwin, the camilladsp mixer must not use all Channels that are available. You can use a 2x4 Mixer. Yust use as much channels vou need to operate ;-)
 

kerwin

New Member
Joined
Apr 27, 2024
Messages
3
Likes
0
Hi Kerwin, the camilladsp mixer must not use all Channels that are available. You can use a 2x4 Mixer. Yust use as much channels vou need to operate ;-)
But when i use less channels i get an error 'wrong number of input channels. Expected 12, found 2'
 

phofman

Addicted to Fun and Learning
Joined
Apr 13, 2021
Messages
534
Likes
350
Thanks, i didn't know you had to use all channels.
You do not have to use all channels, but the number must be between the min and max supported by the driver/device, as reported in the log. That's only 10 for the capture direction, in this particular case.
This changes every second or so:
2024-04-27 17:25:20.873867 WARN [src/alsadevice.rs:779] sample rate change detected, last rate was 28084.176587296097 Hz

Do you perhaps have the device switched to be clocked from incoming SPDIF, with no SPDIF signal present?
 
  • Like
Reactions: MCH

silverD

Member
Joined
May 12, 2020
Messages
43
Likes
47
For those of you who picked up a Hifiberry DAC8x, I couldn't get it to work on Ubuntu server LTS 24.04. There seems to be an issue with overlays and had success with Raspberry Pi OS Lite 64.
 
Last edited:

terryforsythe

Addicted to Fun and Learning
Forum Donor
Joined
May 4, 2022
Messages
588
Likes
632
CamillaDSP + Raspberry Pi is an incredible combination. I am using it to apply the Harman curve (modified for my preference) on my KEF LS60s. The LS60s are very good speakers, but using CamillaDSP for room correction (using convolution files) takes them to the next level in my room - significant improvement.

As a side note, I am impressed with how efficient the software runs. On my Raspberry Pi 5, the DSP load stays under 5%, and my memory (RAM) usage stays below 180 MB. (Getting a Raspberry Pi 5 with 8 GB of RAM is way, way overkill for 2-channel operation).
 

Wirrunna

Member
Joined
May 27, 2021
Messages
99
Likes
48
Location
South Coast, NSW, Australia
CamillaDSP + Raspberry Pi is an incredible combination. I am using it to apply the Harman curve (modified for my preference) on my KEF LS60s. The LS60s are very good speakers, but using CamillaDSP for room correction (using convolution files) takes them to the next level in my room - significant improvement.
What filters have you used to get the Harman Curve ?
As far as I can remember, I set the Shortcut Bass and Treble to them,
Bass filter.jpg
Treble filter.jpg


In my latest toy, a CamillaDSP on a RPi5 mounted behind an Elecrow 7" touchscreen to test out a HiFiBerry DAC8X I have been trying out the Bass and Treble in the shortcuts tab of the CamillaDSP GUI -
Picoreplayer and Pi Screen tone ctl.jpg
The slider allows a slightly delayed (1 or 2 seconds due to stream buffers) response. Pic shows a PiCorePlayer on the left and the Elecrow screen on the right. The black box under the PiCorePlayer is my attempt at mounting Michael's recommended OLED screen and FLIRC, it's RPi5 is just visible with the red led between the screens.
 

jbjbjbjbjb

Member
Joined
Feb 12, 2022
Messages
25
Likes
12
Hi Michael,
In the other forum you mentioned that you had the DAC8x working with CDSP. Was this with Ubuntu and a Rpi5? Any tips to getting it going? I've just got one here.
Thanks!
 

Rafaille

Member
Joined
Dec 5, 2021
Messages
99
Likes
53
Hi Michael,
In the other forum you mentioned that you had the DAC8x working with CDSP. Was this with Ubuntu and a Rpi5? Any tips to getting it going? I've just got one here.
Thanks!
Does it have to be Ubuntu? @silverD in a post above mentioned he had to switch to Raspberry Pi OS for this DAC to work with CDSP.
 

Rafaille

Member
Joined
Dec 5, 2021
Messages
99
Likes
53
And Raspberry Pi OS is based on Debian so if you are familiar with Ubuntu you should not be too lost.
 

Daverz

Major Contributor
Joined
Mar 17, 2019
Messages
1,326
Likes
1,502
  • Like
Reactions: MCH

fatoldgit

Senior Member
Joined
Feb 29, 2020
Messages
327
Likes
385
I note camilladsp has a websocket interface that includes volume control.

So lets imagine I take my two channel input stream (1,2), clone these (3,4) and apply different "stuff" to each pair.

Lets also imagine I can control the volume input volume on (1,2) via my playback app.. lets call that the "master" volume as it technically affects (1,2) and (3,4).

Is it possible to then apply camilladsp based volume to ONLY the (3,4) channels?

Net result is the "master" volume controls the volume for all channels and inside that camilladp volume control then handles the relative volume between (1,2) and (3,4) by only adjusting (3.4).

If so, this would save me having to use an external device to do the (3,4) volume control.

If so, how is this configured/implemented?

Thanks,

Peter
 
  • Like
Reactions: MCH

Jukka

Active Member
Joined
Apr 24, 2019
Messages
262
Likes
173
Thanks for the guide. In a few hours I managed to get this up and running with RPi4 and Apple USB-C dongle, and using USB Audio Gadget as source. It's operating as USB-in/USB-out now, just as I want it. I consider myself an anti-linux person, so that was a feat. This is still not ready for intended use, I have some questions.

I did encounter some problems with config files and it took me a while to get them working and I had to refer to Google. My capture and playback devices support only Alsa, stdin/out and File. Resampler didn't display all the same choices as your guide. This is my device config that works (for now, dsp filters are to be added):
YAML:
description: null
devices:
  adjust_period: null
  capture:
    channels: 2
    device: hw:UAC2Gadget
    format: S32LE
    type: Alsa
  capture_samplerate: 48000
  chunksize: 1024
  enable_rate_adjust: true
  playback:
    channels: 2
    device: hw:A
    format: S24LE3
    type: Alsa
  queuelimit: null
  rate_measure_interval: null
  resampler:
    profile: Balanced
    type: AsyncSinc
  samplerate: 48000
  silence_threshold: -60
  silence_timeout: 5
  stop_on_rate_change: null
  target_level: null
  volume_ramp_time: null
filters: {}
mixers: null
pipeline: null
processors: null
title: Apple USB-C dongle playback

The log gives me warning:
2024-05-13 01:13:54.641003 WARN [src/alsadevice.rs:650] Needless 1:1 sample rate conversion active. Not needed since capture device supports rate adjust
But I'm afraid to change it, because I don't understand these settings.

For what I've been testing, it looks like after each boot, the config file is not applied and I need to manually apply it in the GUI, Apply to DSP button. What's wrong?

How to give name to USB Audio device? My Windows sees it as "Source/Sink".

I'm going to power this device from the computer USB port, so I need to minimize the power draw.
For that purpose my /boot/config.txt looks like this now:
Code:
hdmi_blanking=1

arm_freq=750

dtoverlay=dwc2

gpu_mem=16
Some snipping for brevity. Can anyone give me tips so save power even more? I'd hate to overload or burn my USB controller ;) I will at least lower the arm freq even lower, but I'm not sure if the device will become unstable if lowering too or if there are voltages that I should manually adjust.
 
OP
M

mdsimon2

Major Contributor
Forum Donor
Joined
Oct 20, 2020
Messages
2,579
Likes
3,463
Location
Detroit, MI
Resampler didn't display all the same choices as your guide.

Can you expand on what you specifically mean by this?

The log gives me warning:
2024-05-13 01:13:54.641003 WARN [src/alsadevice.rs:650] Needless 1:1 sample rate conversion active. Not needed since capture device supports rate adjust
But I'm afraid to change it, because I don't understand these settings.

The USB gadget supports rate adjust without resampling, if you are using the same capture / playback rate you can disable resampling. If you want to resample to a different rate, you can use synchronous resampling.

For what I've been testing, it looks like after each boot, the config file is not applied and I need to manually apply it in the GUI, Apply to DSP button. What's wrong?

Difficult to say exactly without more detail. I assume you have set your desired configuration as active by selecting the "star" in the Files tab?

1715562832608.png

How to give name to USB Audio device? My Windows sees it as "Source/Sink".

I believe you can specify it in usb_g_audio.conf by using function_name -> https://docs.kernel.org/usb/gadget-testing.html

Michael
 
Last edited:

Jukka

Active Member
Joined
Apr 24, 2019
Messages
262
Likes
173
Can you expand on what you specifically mean by this?



The USB gadget supports rate adjust without resampling, if you are using the same capture / playback rate you can disable resampling. If you want to resample to a different rate, you can using synchronous resampling.



Difficult to say exactly without more detail. I assume you have set your desired configuration as active by selecting the "star" in the Files tab?

View attachment 369182


I believe you can specify it in usb_g_audio.conf by using function_name -> https://docs.kernel.org/usb/gadget-testing.html

Michael
Thanks for the reply, here are some clarifications. I installed Ubuntu 24.04, it is/was newest LTS at the moment.

Resampler, the resampler_type has only the following available options: None, AsyncSinc, AsyncPoly, Synchronous, but not what was listed in... I'm sorry I must be mixing it up with another guide that I found while Googling. Anyhow, I'm going to disable it because it doesn't seem to be needed.

Configs being not applied, yes I have starred my preferred config:
1715617364942.png

But it is not applied and when I try listen to music, nothing comes out of my headphones. When I click the Apply to DSP, sound comes out immediately. This happens each time I reboot the RPI.
1715617805879.png

After clicking apply:
1715617854979.png


Log before:
Code:
2024-05-13 19:26:44.723734 INFO  [src/bin.rs:683] CamillaDSP version 2.0.3
2024-05-13 19:26:44.724498 INFO  [src/bin.rs:684] Running on linux, aarch64
2024-05-13 19:26:45.156502 ERROR [src/bin.rs:307] Capture error: ALSA function 'snd_pcm_hw_params_set_rate' failed with error 'EINVAL: Invalid argument'
2024-05-13 19:26:45.157092 ERROR [src/processing.rs:50] Message channel error: receiving on a closed channel
And after:
Code:
2024-05-13 19:26:44.723734 INFO  [src/bin.rs:683] CamillaDSP version 2.0.3
2024-05-13 19:26:44.724498 INFO  [src/bin.rs:684] Running on linux, aarch64
2024-05-13 19:26:45.156502 ERROR [src/bin.rs:307] Capture error: ALSA function 'snd_pcm_hw_params_set_rate' failed with error 'EINVAL: Invalid argument'
2024-05-13 19:26:45.157092 ERROR [src/processing.rs:50] Message channel error: receiving on a closed channel
2024-05-13 19:30:27.842497 INFO  [src/alsadevice.rs:648] Capture device supports rate adjust
2024-05-13 19:30:27.842786 WARN  [src/alsadevice.rs:650] Needless 1:1 sample rate conversion active. Not needed since capture device supports rate adjust
2024-05-13 19:30:27.878483 INFO  [src/alsadevice.rs:142] PB: Starting playback from Prepared state

After applying, it seems to stay in working order even when state goes pause.

Other questions

To clarify even further, is the plan with device configs to capture sound from a source and relay it directly to a playback device OR should the capture device output first to an "internal bus", from which playback devices would consume the stream?

USB Gadget mode. Maybe you could add the USB gadget mode guide? It was fairly simple procedure (thank you @phofman ). I would assume a good portion of potential users would need this anyway and it could be a bare minimum type of configuration. This configuration has been tested with with Raspberry Pi 4B.

Create or modify /boot/config.txt and add the following line:
Code:
dtoverlay=dwc2
Add these two lines to /etc/modules :
Code:
dwc2
g_audio
Create or modify /etc/modprobe.d/usb_g_audio.conf and add the following line:
Code:
options g_audio c_srate=44100,48000,88200,96000,176400,192000 c_ssize=4 p_chmask=0
The guide that I read had sample rates >700kHz, but I wouldn't use them. See this and this for reference (I could not get "function_name" to do anything..).
Then use it as a source (capture device) in configuration yml file, something like this:
Code:
  capture:
    channels: 2
    device: hw:UAC2Gadget
    format: S32LE
    type: Alsa
Now my Windows 11 sees the device and offers above sample rates with 32 bit depth. I think that was it, althou I need more configuration to give it a proper name for Windows. I could forget something though, I did this in middle of the night. Read here, and here for more.

Power managing. I'll post back later with power saving configs in case anyone else is wondering if Raspberry Pi 4B can be powered solely with PC USB port. I'm currently successfully powering it from a USB 3.0 port.
 
Top Bottom