Linux USB-Audio Gadget (RPi4 OTG)

Code:
2023-05-19 21:23:15.550141 INFO [src/bin.rs:711] CamillaDSP version 1.0.3
2023-05-19 21:23:15.550259 INFO [src/bin.rs:712] Running on linux, aarch64
2023-05-19 21:23:15.550395 DEBUG [src/bin.rs:754] Read config file Some("/home/dietpi/camilladsp_config/config.yml")
2023-05-19 21:23:15.551369 DEBUG [src/bin.rs:773] Config is valid
2023-05-19 21:23:15.551451 DEBUG [src/bin.rs:857] Wait for config
2023-05-19 21:23:15.551517 DEBUG [src/bin.rs:890] Config ready
2023-05-19 21:23:15.552004 DEBUG [src/filters.rs:450] Build new pipeline
2023-05-19 21:23:15.552003 DEBUG [src/bin.rs:213] Using channels [true, true]
2023-05-19 21:23:15.552242 DEBUG [src/processing.rs:19] build filters, waiting to start processing loop
2023-05-19 21:23:15.552233 DEBUG [src/alsadevice.rs:917] Buffer frames 8192
2023-05-19 21:23:15.554472 DEBUG [src/alsadevice.rs:413] Playback: supported channels, min: 2, max: 2, list: [2]
2023-05-19 21:23:15.554565 DEBUG [src/alsadevice.rs:414] Playback: setting channels to 2
2023-05-19 21:23:15.554859 DEBUG [src/alsadevice.rs:418] Playback: supported samplerates: Discrete([44100, 48000, 88200, 96000, 176400, 192000, 352800, 384000, 705600, 768000])
2023-05-19 21:23:15.554958 DEBUG [src/alsadevice.rs:419] Playback: setting rate to 192000
2023-05-19 21:23:15.555042 DEBUG [src/alsadevice.rs:423] Playback: supported sample formats: [S32LE]
2023-05-19 21:23:15.555105 DEBUG [src/alsadevice.rs:424] Playback: setting format to S32LE
2023-05-19 21:23:15.556494 DEBUG [src/alsadevice.rs:455] Opening audio device "hw:1,0" with parameters: HwParams { channels: Ok(2), rate: "Ok(192000) Hz", format: Ok(S32LE), access: Ok(RWInterleaved), period_size: "Ok(1024) frames", buffer_size: "Ok(8192) frames" }, SwParams(avail_min: Ok(4096) frames, start_threshold: Ok(3072) frames, stop_threshold: Ok(8192) frames)
2023-05-19 21:23:15.556602 DEBUG [src/alsadevice.rs:460] Audio device "hw:1,0" successfully opened
2023-05-19 21:23:15.556740 DEBUG [src/bin.rs:323] Playback thread ready to start
2023-05-19 21:23:15.557142 DEBUG [src/alsadevice.rs:413] Capture: supported channels, min: 2, max: 2, list: [2]
2023-05-19 21:23:15.557224 DEBUG [src/alsadevice.rs:414] Capture: setting channels to 2
2023-05-19 21:23:15.557294 DEBUG [src/alsadevice.rs:418] Capture: supported samplerates: Discrete([192000])
2023-05-19 21:23:15.557357 DEBUG [src/alsadevice.rs:419] Capture: setting rate to 192000
2023-05-19 21:23:15.557424 DEBUG [src/alsadevice.rs:423] Capture: supported sample formats: [S32LE]
2023-05-19 21:23:15.557488 DEBUG [src/alsadevice.rs:424] Capture: setting format to S32LE
2023-05-19 21:23:15.557721 DEBUG [src/alsadevice.rs:455] Opening audio device "hw:CARD=UAC2Gadget,DEV=0" with parameters: HwParams { channels: Ok(2), rate: "Ok(192000) Hz", format: Ok(S32LE), access: Ok(RWInterleaved), period_size: "Ok(512) frames", buffer_size: "Ok(8192) frames" }, SwParams(avail_min: Ok(4096) frames, start_threshold: Ok(0) frames, stop_threshold: Ok(8192) frames)
2023-05-19 21:23:15.557818 DEBUG [src/alsadevice.rs:460] Audio device "hw:CARD=UAC2Gadget,DEV=0" successfully opened
2023-05-19 21:23:15.557919 DEBUG [src/bin.rs:333] Capture thread ready to start
2023-05-19 21:23:15.557986 DEBUG [src/bin.rs:336] Both capture and playback ready, release barrier
2023-05-19 21:23:15.558058 DEBUG [src/bin.rs:338] Supervisor loop starts now!
2023-05-19 21:23:15.558074 DEBUG [src/alsadevice.rs:863] Starting playback loop
2023-05-19 21:23:15.558214 DEBUG [src/processing.rs:21] Processing loop starts now!
2023-05-19 21:23:15.558244 DEBUG [src/alsadevice.rs:958] Starting captureloop
2023-05-19 21:23:15.558783 INFO [src/alsadevice.rs:592] Capture device supports rate adjust
2023-05-19 21:23:15.558897 DEBUG [src/alsadevice.rs:249] Starting capture from state: SND_PCM_STATE_PREPARED, Ready to start
2023-05-19 21:23:15.581426 INFO [src/alsadevice.rs:161] Starting playback from Prepared state
2023-05-19 21:23:25.566498 DEBUG [src/alsadevice.rs:513] Playback buffer level: 4204.4, signal rms: [-51.333153, -52.494766]
2023-05-19 21:23:35.573349 DEBUG [src/alsadevice.rs:513] Playback buffer level: 3966.7, signal rms: [-40.49358, -42.989326]
2023-05-19 21:23:45.579726 DEBUG [src/alsadevice.rs:513] Playback buffer level: 3753.9, signal rms: [-51.369232, -53.032764]
2023-05-19 21:23:55.586588 DEBUG [src/alsadevice.rs:513] Playback buffer level: 3511.1, signal rms: [-52.794823, -53.809452]
2023-05-19 21:24:05.593443 DEBUG [src/alsadevice.rs:513] Playback buffer level: 3301.3, signal rms: [-47.094788, -52.038414]
2023-05-19 21:24:15.599809 DEBUG [src/alsadevice.rs:513] Playback buffer level: 3055.2, signal rms: [-48.430084, -49.70053]
2023-05-19 21:24:25.606734 DEBUG [src/alsadevice.rs:513] Playback buffer level: 2847.7, signal rms: [-36.91897, -39.026844]
2023-05-19 21:24:35.613533 DEBUG [src/alsadevice.rs:513] Playback buffer level: 2600.3, signal rms: [-39.821377, -41.82884]
2023-05-19 21:24:45.619943 DEBUG [src/alsadevice.rs:513] Playback buffer level: 2384.2, signal rms: [-51.26706, -51.2539]
2023-05-19 21:24:55.626817 DEBUG [src/alsadevice.rs:513] Playback buffer level: 2136.7, signal rms: [-51.70687, -53.785316]
2023-05-19 21:25:05.633668 DEBUG [src/alsadevice.rs:513] Playback buffer level: 1925.5, signal rms: [-49.502506, -52.068157]
2023-05-19 21:25:15.640034 DEBUG [src/alsadevice.rs:513] Playback buffer level: 1697.4, signal rms: [-52.050865, -52.86196]
2023-05-19 21:25:25.646924 DEBUG [src/alsadevice.rs:513] Playback buffer level: 1491.6, signal rms: [-51.48633, -52.513775]
2023-05-19 21:25:35.653722 DEBUG [src/alsadevice.rs:513] Playback buffer level: 1268.3, signal rms: [-40.028076, -41.30337]
2023-05-19 21:25:45.660087 DEBUG [src/alsadevice.rs:513] Playback buffer level: 1063.7, signal rms: [-42.98494, -44.685707]
2023-05-19 21:25:55.666989 DEBUG [src/alsadevice.rs:513] Playback buffer level: 830.6, signal rms: [-48.401073, -49.477554]
2023-05-19 21:26:05.673825 DEBUG [src/alsadevice.rs:513] Playback buffer level: 619.4, signal rms: [-39.687866, -42.967728]
2023-05-19 21:26:15.680173 DEBUG [src/alsadevice.rs:513] Playback buffer level: 379.3, signal rms: [-51.752815, -52.5769]
2023-05-19 21:26:25.687081 DEBUG [src/alsadevice.rs:513] Playback buffer level: 179.2, signal rms: [-51.08748, -52.56329]
2023-05-19 21:26:35.693919 DEBUG [src/alsadevice.rs:513] Playback buffer level: 174.2, signal rms: [-38.36133, -39.68678]
2023-05-19 21:26:45.700237 DEBUG [src/alsadevice.rs:513] Playback buffer level: 176.0, signal rms: [-32.99575, -41.414734]
2023-05-19 21:26:55.707120 DEBUG [src/alsadevice.rs:513] Playback buffer level: 174.0, signal rms: [-39.444702, -46.73468]
2023-05-19 21:27:05.713974 DEBUG [src/alsadevice.rs:513] Playback buffer level: 173.7, signal rms: [-41.956017, -30.376646]
2023-05-19 21:27:15.720330 DEBUG [src/alsadevice.rs:513] Playback buffer level: 174.0, signal rms: [-48.777508, -50.29355]
2023-05-19 21:27:25.727205 DEBUG [src/alsadevice.rs:513] Playback buffer level: 172.9, signal rms: [-50.158386, -53.508293]
2023-05-19 21:27:35.734053 DEBUG [src/alsadevice.rs:513] Playback buffer level: 171.5, signal rms: [-46.359997, -48.34088]
2023-05-19 21:27:45.740412 DEBUG [src/alsadevice.rs:513] Playback buffer level: 174.4, signal rms: [-53.36914, -53.87834]
2023-05-19 21:27:55.747290 DEBUG [src/alsadevice.rs:513] Playback buffer level: 172.9, signal rms: [-50.869118, -50.64703]
2023-05-19 21:28:05.754141 DEBUG [src/alsadevice.rs:513] Playback buffer level: 170.2, signal rms: [-27.983953, -32.71493]
2023-05-19 21:28:15.760504 DEBUG [src/alsadevice.rs:513] Playback buffer level: 171.7, signal rms: [-47.103123, -46.698013]
2023-05-19 21:28:25.767386 DEBUG [src/alsadevice.rs:513] Playback buffer level: 170.8, signal rms: [-24.821148, -33.365585]
2023-05-19 21:28:35.774228 DEBUG [src/alsadevice.rs:513] Playback buffer level: 170.2, signal rms: [-30.863045, -35.44345]
2023-05-19 21:28:45.780583 DEBUG [src/alsadevice.rs:513] Playback buffer level: 136.6, signal rms: [-30.77583, -31.669104]
2023-05-19 21:28:55.787470 DEBUG [src/alsadevice.rs:513] Playback buffer level: 152.4, signal rms: [-28.79026, -29.511028]
2023-05-19 21:29:05.794311 DEBUG [src/alsadevice.rs:513] Playback buffer level: 152.9, signal rms: [-34.457092, -37.544884]
2023-05-19 21:29:15.800676 DEBUG [src/alsadevice.rs:513] Playback buffer level: 178.5, signal rms: [-26.35021, -31.543663]
2023-05-19 21:29:25.807542 DEBUG [src/alsadevice.rs:513] Playback buffer level: 150.7, signal rms: [-44.566837, -44.493027]
2023-05-19 21:29:35.814415 DEBUG [src/alsadevice.rs:513] Playback buffer level: 214.5, signal rms: [-20.751732, -20.84506]
2023-05-19 21:29:45.820766 DEBUG [src/alsadevice.rs:513] Playback buffer level: 208.7, signal rms: [-29.981018, -30.230946]
2023-05-19 21:29:55.827634 DEBUG [src/alsadevice.rs:513] Playback buffer level: 153.1, signal rms: [-18.122952, -22.40102]
2023-05-19 21:30:05.834488 DEBUG [src/alsadevice.rs:513] Playback buffer level: 191.0, signal rms: [-32.880344, -36.31322]
2023-05-19 21:30:15.840850 DEBUG [src/alsadevice.rs:513] Playback buffer level: 185.4, signal rms: [-22.808378, -31.2481]

Code:
devices:
  samplerate: 192000
  chunksize: 4096
  silence_threshold: -90
  silence_timeout: 5.0
  adjust_period: 10
  capture:
    type: Alsa
    channels: 2
    device: "hw:CARD=UAC2Gadget,DEV=0"
    format: S32LE
  playback:
    type: Alsa
    channels: 2
    device: "hw:1,0"
    format: S32LE

here, the debug log doesnt show anything obvious but i still hear it from time to time
 
The debug log is very clear. You can see that the buffer level starts off at about 4000 and then decreases steadily. You need to add "enable_rate_adjust: true" in the config. Without that it won't try to match rates.
ah thanks!
with it enabled it looks better now

Code:
2023-05-19 22:02:40.964274 DEBUG [src/audiodevice.rs:628] Current buffer level: 4217.0, corrected capture rate: 99.9969%
2023-05-19 22:02:40.964394 DEBUG [src/alsadevice.rs:513] Playback buffer level: 4217.0, signal rms: [-59.276443, -64.556625]
2023-05-19 22:02:40.964413 DEBUG [src/bin.rs:423] SetSpeed message received
2023-05-19 22:02:50.971129 DEBUG [src/audiodevice.rs:628] Current buffer level: 3954.6, corrected capture rate: 100.0037%
2023-05-19 22:02:50.971248 DEBUG [src/alsadevice.rs:513] Playback buffer level: 3954.6, signal rms: [-42.419838, -42.670296]
2023-05-19 22:02:50.971271 DEBUG [src/bin.rs:423] SetSpeed message received
2023-05-19 22:03:00.977500 DEBUG [src/audiodevice.rs:628] Current buffer level: 3719.5, corrected capture rate: 100.0098%
2023-05-19 22:03:00.977618 DEBUG [src/alsadevice.rs:513] Playback buffer level: 3719.5, signal rms: [-63.015785, -62.103306]
2023-05-19 22:03:00.977647 DEBUG [src/bin.rs:423] SetSpeed message received
2023-05-19 22:03:10.983372 DEBUG [src/audiodevice.rs:628] Current buffer level: 3611.2, corrected capture rate: 100.0126%
2023-05-19 22:03:10.983492 DEBUG [src/alsadevice.rs:513] Playback buffer level: 3611.2, signal rms: [-57.786484, -57.415947]
2023-05-19 22:03:10.983521 DEBUG [src/bin.rs:423] SetSpeed message received
2023-05-19 22:03:20.988714 DEBUG [src/audiodevice.rs:628] Current buffer level: 3604.5, corrected capture rate: 100.0128%
2023-05-19 22:03:20.988829 DEBUG [src/alsadevice.rs:513] Playback buffer level: 3604.5, signal rms: [-71.575096, -73.24554]
2023-05-19 22:03:20.988868 DEBUG [src/bin.rs:423] SetSpeed message received
2023-05-19 22:03:30.994061 DEBUG [src/audiodevice.rs:628] Current buffer level: 3613.6, corrected capture rate: 100.0126%
2023-05-19 22:03:30.994176 DEBUG [src/alsadevice.rs:513] Playback buffer level: 3613.6, signal rms: [-66.969315, -68.07337]
2023-05-19 22:03:30.994210 DEBUG [src/bin.rs:423] SetSpeed message received
2023-05-19 22:03:40.999446 DEBUG [src/audiodevice.rs:628] Current buffer level: 3643.9, corrected capture rate: 100.0118%
2023-05-19 22:03:40.999563 DEBUG [src/alsadevice.rs:513] Playback buffer level: 3643.9, signal rms: [-51.28618, -52.441364]
2023-05-19 22:03:40.999593 DEBUG [src/bin.rs:423] SetSpeed message received
2023-05-19 22:03:51.004780 DEBUG [src/audiodevice.rs:628] Current buffer level: 3633.2, corrected capture rate: 100.0121%
2023-05-19 22:03:51.004896 DEBUG [src/alsadevice.rs:513] Playback buffer level: 3633.2, signal rms: [-60.587585, -61.28565]
2023-05-19 22:03:51.005353 DEBUG [src/bin.rs:423] SetSpeed message received
2023-05-19 22:04:01.010673 DEBUG [src/audiodevice.rs:628] Current buffer level: 3651.0, corrected capture rate: 100.0116%
2023-05-19 22:04:01.010789 DEBUG [src/alsadevice.rs:513] Playback buffer level: 3651.0, signal rms: [-48.93492, -53.745533]
2023-05-19 22:04:01.011109 DEBUG [src/bin.rs:423] SetSpeed message received
2023-05-19 22:04:11.016007 DEBUG [src/audiodevice.rs:628] Current buffer level: 3640.9, corrected capture rate: 100.0119%
2023-05-19 22:04:11.016126 DEBUG [src/alsadevice.rs:513] Playback buffer level: 3640.9, signal rms: [-60.07704, -60.30668]
2023-05-19 22:04:11.016455 DEBUG [src/bin.rs:423] SetSpeed message received
2023-05-19 22:04:21.021363 DEBUG [src/audiodevice.rs:628] Current buffer level: 3638.3, corrected capture rate: 100.0119%
2023-05-19 22:04:21.021481 DEBUG [src/alsadevice.rs:513] Playback buffer level: 3638.3, signal rms: [-46.498474, -46.261517]
2023-05-19 22:04:21.021507 DEBUG [src/bin.rs:423] SetSpeed message received
2023-05-19 22:04:31.027238 DEBUG [src/audiodevice.rs:628] Current buffer level: 3656.4, corrected capture rate: 100.0115%
2023-05-19 22:04:31.027353 DEBUG [src/alsadevice.rs:513] Playback buffer level: 3656.4, signal rms: [-59.271065, -60.890648]
2023-05-19 22:04:31.027390 DEBUG [src/bin.rs:423] SetSpeed message received
2023-05-19 22:04:41.032589 DEBUG [src/audiodevice.rs:628] Current buffer level: 3628.4, corrected capture rate: 100.0122%
2023-05-19 22:04:41.032706 DEBUG [src/alsadevice.rs:513] Playback buffer level: 3628.4, signal rms: [-61.41953, -63.2445]
2023-05-19 22:04:41.033029 DEBUG [src/bin.rs:423] SetSpeed message received
2023-05-19 22:04:51.037935 DEBUG [src/audiodevice.rs:628] Current buffer level: 3662.4, corrected capture rate: 100.0113%
2023-05-19 22:04:51.038052 DEBUG [src/alsadevice.rs:513] Playback buffer level: 3662.4, signal rms: [-61.73758, -62.88021]
2023-05-19 22:04:51.038085 DEBUG [src/bin.rs:423] SetSpeed message received
2023-05-19 22:05:01.043803 DEBUG [src/audiodevice.rs:628] Current buffer level: 3636.9, corrected capture rate: 100.0120%
2023-05-19 22:05:01.043922 DEBUG [src/alsadevice.rs:513] Playback buffer level: 3636.9, signal rms: [-46.30715, -49.187637]
2023-05-19 22:05:01.044367 DEBUG [src/bin.rs:423] SetSpeed message received
2023-05-19 22:05:11.049152 DEBUG [src/audiodevice.rs:628] Current buffer level: 3648.4, corrected capture rate: 100.0117%
2023-05-19 22:05:11.049271 DEBUG [src/alsadevice.rs:513] Playback buffer level: 3648.4, signal rms: [-38.000816, -38.578182]
2023-05-19 22:05:11.049719 DEBUG [src/bin.rs:423] SetSpeed message received
2023-05-19 22:05:21.054521 DEBUG [src/audiodevice.rs:628] Current buffer level: 3659.8, corrected capture rate: 100.0114%
2023-05-19 22:05:21.054685 DEBUG [src/alsadevice.rs:513] Playback buffer level: 3659.8, signal rms: [-62.469154, -65.951096]
2023-05-19 22:05:21.054991 DEBUG [src/bin.rs:423] SetSpeed message received
2023-05-19 22:05:31.060379 DEBUG [src/audiodevice.rs:628] Current buffer level: 3631.5, corrected capture rate: 100.0121%
2023-05-19 22:05:31.060498 DEBUG [src/alsadevice.rs:513] Playback buffer level: 3631.5, signal rms: [-39.85694, -41.39443]
2023-05-19 22:05:31.060821 DEBUG [src/bin.rs:423] SetSpeed message received
2023-05-19 22:05:41.065731 DEBUG [src/audiodevice.rs:628] Current buffer level: 3640.6, corrected capture rate: 100.0119%
2023-05-19 22:05:41.065852 DEBUG [src/alsadevice.rs:513] Playback buffer level: 3640.6, signal rms: [-31.264977, -39.099205]
2023-05-19 22:05:41.066231 DEBUG [src/bin.rs:423] SetSpeed message received
2023-05-19 22:05:51.071114 DEBUG [src/audiodevice.rs:628] Current buffer level: 3645.8, corrected capture rate: 100.0117%
2023-05-19 22:05:51.071236 DEBUG [src/alsadevice.rs:513] Playback buffer level: 3645.8, signal rms: [-43.353218, -48.059204]
2023-05-19 22:05:51.071261 DEBUG [src/bin.rs:423] SetSpeed message received
2023-05-19 22:06:01.076955 DEBUG [src/audiodevice.rs:628] Current buffer level: 3638.5, corrected capture rate: 100.0119%
2023-05-19 22:06:01.077073 DEBUG [src/alsadevice.rs:513] Playback buffer level: 3638.5, signal rms: [-50.982613, -52.263954]
2023-05-19 22:06:01.077103 DEBUG [src/bin.rs:423] SetSpeed message received
2023-05-19 22:06:11.082312 DEBUG [src/audiodevice.rs:628] Current buffer level: 3655.7, corrected capture rate: 100.0115%
2023-05-19 22:06:11.082430 DEBUG [src/alsadevice.rs:513] Playback buffer level: 3655.7, signal rms: [-39.786045, -27.145905]
2023-05-19 22:06:11.082460 DEBUG [src/bin.rs:423] SetSpeed message received
2023-05-19 22:06:21.087667 DEBUG [src/audiodevice.rs:628] Current buffer level: 3632.1, corrected capture rate: 100.0121%
2023-05-19 22:06:21.087785 DEBUG [src/alsadevice.rs:513] Playback buffer level: 3632.1, signal rms: [-36.880154, -37.33123]
2023-05-19 22:06:21.088242 DEBUG [src/bin.rs:423] SetSpeed message received
2023-05-19 22:06:31.093527 DEBUG [src/audiodevice.rs:628] Current buffer level: 3651.9, corrected capture rate: 100.0116%
2023-05-19 22:06:31.093646 DEBUG [src/alsadevice.rs:513] Playback buffer level: 3651.9, signal rms: [-51.526775, -50.513588]
2023-05-19 22:06:31.093677 DEBUG [src/bin.rs:423] SetSpeed message received
2023-05-19 22:06:41.098901 DEBUG [src/audiodevice.rs:628] Current buffer level: 3638.2, corrected capture rate: 100.0119%
2023-05-19 22:06:41.099021 DEBUG [src/alsadevice.rs:513] Playback buffer level: 3638.2, signal rms: [-53.290363, -52.522717]
2023-05-19 22:06:41.099471 DEBUG [src/bin.rs:423] SetSpeed message received
2023-05-19 22:06:51.104245 DEBUG [src/audiodevice.rs:628] Current buffer level: 3642.7, corrected capture rate: 100.0118%
2023-05-19 22:06:51.104365 DEBUG [src/alsadevice.rs:513] Playback buffer level: 3642.7, signal rms: [-32.05969, -35.807205]
2023-05-19 22:06:51.104807 DEBUG [src/bin.rs:423] SetSpeed message received
2023-05-19 22:07:01.110113 DEBUG [src/audiodevice.rs:628] Current buffer level: 3655.6, corrected capture rate: 100.0115%
2023-05-19 22:07:01.110232 DEBUG [src/alsadevice.rs:513] Playback buffer level: 3655.6, signal rms: [-21.495096, -24.200525]
2023-05-19 22:07:01.110698 DEBUG [src/bin.rs:423] SetSpeed message received
2023-05-19 22:07:11.115480 DEBUG [src/audiodevice.rs:628] Current buffer level: 3633.7, corrected capture rate: 100.0121%
2023-05-19 22:07:11.115600 DEBUG [src/alsadevice.rs:513] Playback buffer level: 3633.7, signal rms: [-48.090324, -48.553543]
2023-05-19 22:07:11.115921 DEBUG [src/bin.rs:423] SetSpeed message received
2023-05-19 22:07:21.120824 DEBUG [src/audiodevice.rs:628] Current buffer level: 3652.4, corrected capture rate: 100.0116%
2023-05-19 22:07:21.120943 DEBUG [src/alsadevice.rs:513] Playback buffer level: 3652.4, signal rms: [-41.61529, -48.740402]
2023-05-19 22:07:21.121387 DEBUG [src/bin.rs:423] SetSpeed message received
2023-05-19 22:07:31.126757 DEBUG [src/audiodevice.rs:628] Current buffer level: 3639.4, corrected capture rate: 100.0119%
2023-05-19 22:07:31.126880 DEBUG [src/alsadevice.rs:513] Playback buffer level: 3639.4, signal rms: [-48.44294, -47.902256]
2023-05-19 22:07:31.126907 DEBUG [src/bin.rs:423] SetSpeed message received
2023-05-19 22:07:41.132035 DEBUG [src/audiodevice.rs:628] Current buffer level: 3641.5, corrected capture rate: 100.0118%
2023-05-19 22:07:41.132153 DEBUG [src/alsadevice.rs:513] Playback buffer level: 3641.5, signal rms: [-50.09443, -52.249176]
2023-05-19 22:07:41.132189 DEBUG [src/bin.rs:423] SetSpeed message received
2023-05-19 22:07:51.137393 DEBUG [src/audiodevice.rs:628] Current buffer level: 3663.2, corrected capture rate: 100.0113%
2023-05-19 22:07:51.137513 DEBUG [src/alsadevice.rs:513] Playback buffer level: 3663.2, signal rms: [-30.826157, -39.780106]
2023-05-19 22:07:51.137543 DEBUG [src/bin.rs:423] SetSpeed message received
2023-05-19 22:08:01.143289 DEBUG [src/audiodevice.rs:628] Current buffer level: 3634.0, corrected capture rate: 100.0120%
2023-05-19 22:08:01.143430 DEBUG [src/bin.rs:423] SetSpeed message received
2023-05-19 22:08:01.143515 DEBUG [src/alsadevice.rs:513] Playback buffer level: 3634.0, signal rms: [-33.59828, -41.36278]
2023-05-19 22:08:11.148611 DEBUG [src/audiodevice.rs:628] Current buffer level: 3648.9, corrected capture rate: 100.0117%
2023-05-19 22:08:11.148748 DEBUG [src/bin.rs:423] SetSpeed message received
2023-05-19 22:08:11.148834 DEBUG [src/alsadevice.rs:513] Playback buffer level: 3648.9, signal rms: [-54.08422, -53.110027]
2023-05-19 22:08:21.153965 DEBUG [src/audiodevice.rs:628] Current buffer level: 3637.2, corrected capture rate: 100.0120%
2023-05-19 22:08:21.154103 DEBUG [src/bin.rs:423] SetSpeed message received
2023-05-19 22:08:21.154192 DEBUG [src/alsadevice.rs:513] Playback buffer level: 3637.2, signal rms: [-35.523346, -35.13809]
2023-05-19 22:08:31.159824 DEBUG [src/audiodevice.rs:628] Current buffer level: 3635.7, corrected capture rate: 100.0120%
2023-05-19 22:08:31.159961 DEBUG [src/bin.rs:423] SetSpeed message received
2023-05-19 22:08:31.160045 DEBUG [src/alsadevice.rs:513] Playback buffer level: 3635.7, signal rms: [-54.78695, -53.45541]
2023-05-19 22:08:41.165194 DEBUG [src/audiodevice.rs:628] Current buffer level: 3658.3, corrected capture rate: 100.0114%
2023-05-19 22:08:41.165328 DEBUG [src/bin.rs:423] SetSpeed message received
2023-05-19 22:08:41.165409 DEBUG [src/alsadevice.rs:513] Playback buffer level: 3658.3, signal rms: [-54.311424, -53.654404]
2023-05-19 22:08:51.170545 DEBUG [src/audiodevice.rs:628] Current buffer level: 3630.8, corrected capture rate: 100.0121%
2023-05-19 22:08:51.170722 DEBUG [src/bin.rs:423] SetSpeed message received
2023-05-19 22:08:51.170807 DEBUG [src/alsadevice.rs:513] Playback buffer level: 3630.8, signal rms: [-38.427334, -44.281075]
2023-05-19 22:09:01.175901 DEBUG [src/audiodevice.rs:628] Current buffer level: 3659.0, corrected capture rate: 100.0114%
2023-05-19 22:09:01.176034 DEBUG [src/bin.rs:423] SetSpeed message received
2023-05-19 22:09:01.176119 DEBUG [src/alsadevice.rs:513] Playback buffer level: 3659.0, signal rms: [-55.95991, -54.725918]
2023-05-19 22:09:11.181760 DEBUG [src/audiodevice.rs:628] Current buffer level: 3634.1, corrected capture rate: 100.0120%
2023-05-19 22:09:11.181892 DEBUG [src/bin.rs:423] SetSpeed message received
2023-05-19 22:09:11.181979 DEBUG [src/alsadevice.rs:513] Playback buffer level: 3634.1, signal rms: [-44.567566, -47.54403]
2023-05-19 22:09:21.187121 DEBUG [src/audiodevice.rs:628] Current buffer level: 3644.4, corrected capture rate: 100.0118%
2023-05-19 22:09:21.187255 DEBUG [src/bin.rs:423] SetSpeed message received
2023-05-19 22:09:21.187335 DEBUG [src/alsadevice.rs:513] Playback buffer level: 3644.4, signal rms: [-45.966225, -45.656773]
2023-05-19 22:09:31.192479 DEBUG [src/audiodevice.rs:628] Current buffer level: 3650.5, corrected capture rate: 100.0116%
2023-05-19 22:09:31.192617 DEBUG [src/bin.rs:423] SetSpeed message received
2023-05-19 22:09:31.192698 DEBUG [src/alsadevice.rs:513] Playback buffer level: 3650.5, signal rms: [-39.35886, -44.354763]
2023-05-19 22:09:41.198332 DEBUG [src/audiodevice.rs:628] Current buffer level: 3638.4, corrected capture rate: 100.0119%
2023-05-19 22:09:41.198469 DEBUG [src/bin.rs:423] SetSpeed message received
2023-05-19 22:09:41.198551 DEBUG [src/alsadevice.rs:513] Playback buffer level: 3638.4, signal rms: [-37.91758, -37.752384]
2023-05-19 22:09:51.203700 DEBUG [src/audiodevice.rs:628] Current buffer level: 3652.6, corrected capture rate: 100.0116%
2023-05-19 22:09:51.203836 DEBUG [src/bin.rs:423] SetSpeed message received
2023-05-19 22:09:51.203915 DEBUG [src/alsadevice.rs:513] Playback buffer level: 3652.6, signal rms: [-40.332573, -43.2052]
2023-05-19 22:10:01.209049 DEBUG [src/audiodevice.rs:628] Current buffer level: 3640.6, corrected capture rate: 100.0119%
2023-05-19 22:10:01.209189 DEBUG [src/bin.rs:423] SetSpeed message received
2023-05-19 22:10:01.209278 DEBUG [src/alsadevice.rs:513] Playback buffer level: 3640.6, signal rms: [-55.343555, -56.895294]
2023-05-19 22:10:11.214937 DEBUG [src/audiodevice.rs:628] Current buffer level: 3641.6, corrected capture rate: 100.0118%
2023-05-19 22:10:11.215077 DEBUG [src/bin.rs:423] SetSpeed message received
2023-05-19 22:10:11.215159 DEBUG [src/alsadevice.rs:513] Playback buffer level: 3641.6, signal rms: [-56.645184, -56.753593]
2023-05-19 22:10:21.220276 DEBUG [src/audiodevice.rs:628] Current buffer level: 3662.9, corrected capture rate: 100.0113%
2023-05-19 22:10:21.220413 DEBUG [src/bin.rs:423] SetSpeed message received
2023-05-19 22:10:21.220495 DEBUG [src/alsadevice.rs:513] Playback buffer level: 3662.9, signal rms: [-42.47488, -43.627472]
2023-05-19 22:10:31.226186 DEBUG [src/audiodevice.rs:628] Current buffer level: 3630.2, corrected capture rate: 100.0121%
2023-05-19 22:10:31.226330 DEBUG [src/bin.rs:423] SetSpeed message received

i will test it some time now if all runs flawlessly, thanks
 
it works really well now, the last few hours i havent noticed any interrupts, probably the best solution so far
also jack was kind of unusable without manual intervention because it couldnt start jack if the gadget device isnt used yet

it would be quite interesting to try out 768khz resampling with camilladsp, this would actually a great benefit since pipewire doesnt seem to support over 192khz well
what configuration i need for resampling before i forget/overlook something again?

Code:
devices:
  samplerate: 768000
  chunksize: 1024
  enable_resampling: true
  resampler_type: AccurateSync
  capture_samplerate: 192000
is this all i need to resample from 192khz to 768khz ?
 
this seems to work, but for some reason not with AccurateAsync
with AccurateAsync (and 768khz) i get this:
Code:
2023-05-20 09:27:20.614748 WARN [src/alsadevice.rs:596] Async resampler not needed since capture device supports rate adjust. Switch to Sync type to save CPU time.
2023-05-20 09:27:20.614829 DEBUG [src/alsadevice.rs:249] Starting capture from state: SND_PCM_STATE_PREPARED, Ready to start
2023-05-20 09:27:20.624186 INFO [src/alsadevice.rs:161] Starting playback from Prepared state
2023-05-20 09:27:20.639503 WARN [src/alsadevice.rs:237] Prepare capture device
2023-05-20 09:27:20.647739 WARN [src/alsadevice.rs:262] Wait timed out, capture device takes too long to capture frames
2023-05-20 09:27:20.647815 DEBUG [src/alsadevice.rs:735] Capture device is inactive, processing is stalled
2023-05-20 09:27:20.647959 DEBUG [src/alsadevice.rs:249] Starting capture from state: SND_PCM_STATE_PREPARED, Ready to start
2023-05-20 09:27:21.633084 WARN [src/alsadevice.rs:237] Prepare capture device
2023-05-20 09:27:21.641305 WARN [src/alsadevice.rs:262] Wait timed out, capture device takes too long to capture frames
2023-05-20 09:27:21.641380 DEBUG [src/alsadevice.rs:735] Capture device is inactive, processing is stalled
2023-05-20 09:27:21.641565 DEBUG [src/alsadevice.rs:249] Starting capture from state: SND_PCM_STATE_PREPARED, Ready to start
2023-05-20 09:27:22.634713 WARN [src/alsadevice.rs:237] Prepare capture device
2023-05-20 09:27:22.642948 WARN [src/alsadevice.rs:262] Wait timed out, capture device takes too long to capture frames
2023-05-20 09:27:22.643031 DEBUG [src/alsadevice.rs:735] Capture device is inactive, processing is stalled
2023-05-20 09:27:22.643219 DEBUG [src/alsadevice.rs:249] Starting capture from state: SND_PCM_STATE_PREPARED, Ready to start
2023-05-20 09:27:23.636267 WARN [src/alsadevice.rs:237] Prepare capture device
2023-05-20 09:27:23.644489 WARN [src/alsadevice.rs:262] Wait timed out, capture device takes too long to capture frames
2023-05-20 09:27:23.644563 DEBUG [src/alsadevice.rs:735] Capture device is inactive, processing is stalled
2023-05-20 09:27:23.644745 DEBUG [src/alsadevice.rs:249] Starting capture from state: SND_PCM_STATE_PREPARED, Ready to start
2023-05-20 09:27:24.639488 WARN [src/alsadevice.rs:237] Prepare capture device
2023-05-20 09:27:24.647714 WARN [src/alsadevice.rs:262] Wait timed out, capture device takes too long to capture frames
2023-05-20 09:27:24.647796 DEBUG [src/alsadevice.rs:735] Capture device is inactive, processing is stalled
2023-05-20 09:27:24.647977 DEBUG [src/alsadevice.rs:249] Starting capture from state: SND_PCM_STATE_PREPARED, Ready to start
2023-05-20 09:27:25.642796 WARN [src/alsadevice.rs:237] Prepare capture device
2023-05-20 09:27:25.651020 WARN [src/alsadevice.rs:262] Wait timed out, capture device takes too long to capture frames
2023-05-20 09:27:25.651097 DEBUG [src/alsadevice.rs:735] Capture device is inactive, processing is stalled
2023-05-20 09:27:25.651283 DEBUG [src/alsadevice.rs:249] Starting capture from state: SND_PCM_STATE_PREPARED, Ready to start
but other modes seem to work with 768khz
AccurateAsync also works with 384khz

also the documentation is a bit confusing about resampling
the documentation says this:
Code:
When using the rate adjust feature to match capture and playback devices, one of the "Async" variants must be used. These asynchronous presets do not rely on a fixed resampling ratio. When rate adjust is enabled the resampling ratio is dynamically adjusted in order to compensate for drifts and mismatches between the input and output sample clocks.
Using the "Synchronous" variant with rate adjust enabled will print warnings, and any rate adjust request will be ignored.

but the actually warning im getting is this:
Code:
2023-05-20 09:33:31.195734 WARN [src/alsadevice.rs:596] Async resampler not needed since capture device supports rate adjust. Switch to Sync type to save CPU time.

So do i need Async or Sync resampler type with rate_adjust?
 
It's possible the capture thread does not keep up with the resampling to 768kHz, causing input (capture) buffer overruns (the reading loop must resample the read chunk before reading a new chunk).

If you use rate adjustment, the capture device rate is tweaked to be aligned with the playback device rate. Therefore you need only fixed-ratio resampling (called sync in CDSP), no need to tweak the resampling ratio (= async resampler).
 
It's possible the capture thread does not keep up with the resampling to 768kHz, causing input (capture) buffer overruns (the reading loop must resample the read chunk before reading a new chunk).
the systemd service runs with fifo priority 70 but i also tested "stock" same here, i also tried to increase chunksize but 768/705khz just dont wanna work with AccurateAsync

If you use rate adjustment, the capture device rate is tweaked to be aligned with the playback device rate. Therefore you need only fixed-ratio resampling (called sync in CDSP), no need to tweak the resampling ratio (= async resampler).
and you are sure here? the documentation and error message seems very unclear saying the opposite

i tested both, Synchronous uses less cpu (20% on one core) and buffer stays filled nicely, so i guess it works

but my testing showed that i prefer the resampling of pipewire, it seems the cleanest resampling i found so far while i hear postives/negatives with most resampling algorithms the one from pipewire seems to just have positives (tho mind that i use the highest resampling quality in pipewire)
another thing that brought sq up a notch is using dither inside camilladsp

my config looks like this right now:
Code:
  devices:
  chunksize: 4096
  #capture_samplerate: 192000
  samplerate: 192000
  #enable_resampling: true
  #resampler_type: Synchronous
  #resampler_type: FreeAsync, FastAsync, BalancedAsync, AccurateAsync, Synchronous 
  silence_threshold: -60
  silence_timeout: 3.0
  enable_rate_adjust: true
  adjust_period: 5
  capture:
    type: Alsa
    channels: 2
    device: "hw:CARD=UAC2Gadget,DEV=0"
    format: S32LE
  playback:
    type: Alsa
    channels: 2
    device: "hw:CARD=DAC,DEV=0"
    format: S32LE

filters:
  dither:
    type: Dither
    parameters:
      type: Simple
      bits: 16

pipeline:
  - type: Filter
    channel: 0
    names:
      - dither
  - type: Filter
    channel: 1
    names:
      - dither

with camilladsp this setup is really usable, i found hardly any differences between connecting the dac directly to the pc or going over the rpi4, i even hear a slight improvement going over the rpi4, really curious what a ddc hat can do here now
im not very sensitive to lip sync (and im willing to even sacrifies it a bit) but i havent noticed anything, it seems very responsive, also with pause/play

i might play around with mpd/mopidy but i honestly dont wanna miss getting good quality pc output, so if i ever build a rpi streamer again it definitely has this feature :)
 
the systemd service runs with fifo priority 70 but i also tested "stock" same here, i also tried to increase chunksize but 768/705khz just dont wanna work with AccurateAsync
If the core computing power is not up to all the calculations involved, no priority will help.

and you are sure here? the documentation and error message seems very unclear saying the opposite
The warn message says exactly that: Async resampler not needed since capture device supports rate adjust.

Why do you dither to 16bits in your 32-bit (+ float64) chain?
 
Why do you dither to 16bits in your 32-bit (+ float64) chain?
maybe i have the wrong thinking here but i use 16 bit so 16 bit files get dithered too (since i also use EQ), i presume a 32bit dither wouldnt have any effect on 16 bit files
i also "imagine" it sounds better tho im not 100% sure

i just havent lowered the bitrate yet but you are right, its kinda wasted with dither that low
 
Dithering is used when reducing the bit width, basically to statistically encode the signal in the lower (dropped) bits into the lowest remaining bit. IIUC your chain is 16bit source -> 32 bit gadget -> float64 CDSP processing -> 32bit output. There is no reduction of the bit width along the chain (foat64 -> 32bit is not important). Dithering just adds an extra noise to your 16th bit in this case.

If your output were in 16bits (e.g. a 16bit DAC), dithering to the 16th bit at the end of the float64 CDSP processing chain would help (very little) with encoding the dropped information.
 
Dithering is used when reducing the bit width, basically to statistically encode the signal in the lower (dropped) bits into the lowest remaining bit. IIUC your chain is 16bit source -> 32 bit gadget -> float64 CDSP processing -> 32bit output. There is no reduction of the bit width along the chain (foat64 -> 32bit is not important). Dithering just adds an extra noise to your 16th bit in this case.

If your output were in 16bits (e.g. a 16bit DAC), dithering to the 16th bit at the end of the float64 CDSP processing chain would help (very little) with encoding the dropped information.
oh i understood dither so far more of just added noise to round of "errors" but i dont know the specifics, and kinda thought in theory its better to also catch the already applied dither of 16bit files

atleast audibly speaking dither definitely has a effect, tho im not sure if 16vs32bit makes a big difference, i thought 16 bit sounds slightly better but also 32bit sounds better than no dither

i have set it back to 32bit for my 32 bit chain, i plan to use high res files again in a bit and with 24bit files there definitely is a difference between 16bit and 24bit dither applied on 24bit files even if 16bit should be inaudible in theory

i might set the chain later to 24bit overall, 32 bit really has no real point unless you use software volume in the wrong way (way to low levels and too high amp sensitivity)
 
is this all i need to resample from 192khz to 768khz ?
Yes!

this seems to work, but for some reason not with AccurateAsync
with AccurateAsync (and 768khz) i get this:
AccureteAsync is quite heavy, your cpu likely isn't able to do that at 768kHz. You don't need it in here though, Synchronous gives the same or slightly better quality at much lower load.

@phofman already answered about the dithering, not much to add there.
I would just mention that dithering only makes sense if you have a 16-bit DAC. Dithering to 24 bits or more is not meaningful. The DAC itself (even if it's one of the very best) produces more noise than the dithering adds so any dither just drowns. That's already the case at 24 bits where the dither signal is in the -140 dB range. Dithering to 32 bits is even more pointless since the dither ends ut at about -190 dB.
 
AccureteAsync is quite heavy, your cpu likely isn't able to do that at 768kHz. You don't need it in here though, Synchronous gives the same or slightly better quality at much lower load.
ah alright, thanks, i will go with Synchronous then

@phofman already answered about the dithering, not much to add there.
I would just mention that dithering only makes sense if you have a 16-bit DAC. Dithering to 24 bits or more is not meaningful. The DAC itself (even if it's one of the very best) produces more noise than the dithering adds so any dither just drowns. That's already the case at 24 bits where the dither signal is in the -140 dB range. Dithering to 32 bits is even more pointless since the dither ends ut at about -190 dB.
hmm it could be imagination but no dither sounds a bit "edgy" in comparison to dither applied where it just seems a tad smoother, since the dither itself is inaudible i will probably leave it as it is, either it does remove some distortion/error or it doesnt but also doesnt really harm
 
try to implement it later on a minimal arch rpi4
I did so. And finally gave up after wasting much, much, much, much, much (believe me) much, much, much too much time and patience.

I tried to do so because my regular Linux Intel Laptop runs on Arch, I am used to it, and I prefer Arch instead of Debian for my Laptop use for several reasons. But for an Rpi instead, my pragmatic conclusion is to better go along with a totally unsexy out-of-the-box RaspberrypiOS and it's neat OS installer, and forget about attempting to tweak fancy Arch onto a Rpi instead. And as more so, because for the moment, there seem no bonus for an Audio OTG Gadget to have a more up-to-date system than RaspberryPiOS will deliver by standard.

Saying that, I am referring to aarch64 and a Rpi3A+ or Rpi3B+. The 32-bit-version seems a bit less stubborn, and I was able to set up some nice functional little applications on a Rpi along with 32-bit arch armv7. But, as said, 64bit was a mess, at least to me.
 
I did so. And finally gave up after wasting much, much, much, much, much (believe me) much, much, much too much time and patience.

I tried to do so because my regular Linux Intel Laptop runs on Arch, I am used to it, and I prefer Arch instead of Debian for my Laptop use for several reasons. But for an Rpi instead, my pragmatic conclusion is to better go along with a totally unsexy out-of-the-box RaspberrypiOS and it's neat OS installer, and forget about attempting to tweak fancy Arch onto a Rpi instead. And as more so, because for the moment, there seem no bonus for an Audio OTG Gadget to have a more up-to-date system than RaspberryPiOS will deliver by standard.

Saying that, I am referring to aarch64 and a Rpi3A+ or Rpi3B+. The 32-bit-version seems a bit less stubborn, and I was able to set up some nice functional little applications on a Rpi along with 32-bit arch armv7. But, as said, 64bit was a mess, at least to me.
yea i first tried arch but overall arch seems way more quirky and not alot discussions about rpi with arch, so i also ditched it
what really surprised me was dietpi after that, first time using dietpi but it was a really hasslefree expierence, its basicly a stripped down raspberrypi os plus some scripts, so you get a kinda tweaked minimal os with all the positives of staying in the official raspberrypi os territory
so im probably staying with dietpi, it also already uses kernel 6.1 so not that much worries about being uptodate, shouldnt in the next months appear a new version update anyway?

the 60mb ram usage and around 10 tasks i get with dietpi are hard to top
 
does someone know how pipewire handels two different clocked devices?
my guess would be it is utitlizing resampling but im not sure if it even does that

pipewire because if i wanna use mpd on the rpi itself i rather use easyeffects then camilladsp for my use case since i think it sounds better for simple EQ
the next best option i see would be using roon after this (which i might try anyway since qobuz`s search and suggestions are rather crappy..)
 
There is an updated version of the HowTo. Main motivation for the rework was the transition from the (deprecated) g_audio kernel module approach to the up-to-date configfs interface method. Some more text and functional tests have been added, also some more polish to some bells and whistles. Sorry that the HowTo now got a bit bloated because of that.
@Daihedz thanks a lot for your great guide.

With respect to Daihedz's "howto", I would like to suggest an alternative way to launch camilladsp while ensuring that the audio device gadget is already available.
See below my version of the script /usr/lib/systemd/system/camilladsp-start.service. I added three lines to the [Service] section and launched camilladsp directly from ExecStart. No need for the camilladsp_start.sh script.

[Unit]
Description=CamillaDSP Boot Starter
After=multi-user.target

[Service]
ExecCondition=grep UAC2Gadget /proc/asound/cards
Restart=always
RestartSec=1
CPUSchedulingPolicy=fifo
CPUSchedulingPriority=10
ExecStart=camilladsp ... (put your parameters here)
Group=root
User=root

[Install]
WantedBy=multi-user.target
 
Last edited:
IMHO appearance of kernel devices is handled via udev. That's how e.g. these tutorials trigger their usb gadget systemd units https://www.collabora.com/news-and-...-and-how-to-integrate-it-with-systemd-part-1/ or https://docplayer.net/231689959-Modern-usb-gadget-with-custom-usb-functions.html - handling udev event by setting the systemd SYSTEMD_WANTS variable and setting the WantedBy of the unit to its value.

Polling for a file existence is also possible, but less reliable and CPU consuming.
 
[Unit]
Description=CamillaDSP Boot Starter
After=gadget_init.service
[Service]
Type=idle
CPUSchedulingPolicy=fifo
CPUSchedulingPriority=70
ExecStart=taskset -c 3 camilladsp /home/dietpi/camilladsp_config/config.yml
Group=root
User=root
[Install]
WantedBy=multi-user.target

this is what i use, it works :)


@phofman what does this method do? like activate the usb gadget if the usb cable is plugged in?