REW Beta Release Testing REW to RPi 5 in "Gadget Mode" running CamillaDSP

Wirrunna

New Member
Thread Starter
Joined
Jul 5, 2020
Posts
11
More  
Preamp, Processor or Receiver
NAD C725BEE
Front Speakers
Klipschorns
A RPi4/5 can be configured as a USB input / output device, this is known as a USB gadget.

Raspberry Pi configured to Gadget Mode appears as an output device to REW running in Win 11. This mode simplifies loudspeaker testing if the Raspberry Pi is running CamillaDSP as the signal remains in the digital mode - no analog cables and conversions.

In testing REW connected to a RPi5 -

Preferences/Soundcard: with the output device "EXCL: Speakers (3- Source/Sink)" sample rate at 48kHz, the Check Levels routine can be started and the calibration signal is received by the RPi and played. The Check Levels can then be stopped, level adjusted and played and stopped. CamillaDSP (CDSP) state goes from "Stalled" while waiting for a signal, to "Running" when the calibration signal is present, CDSP log shows:
2025-01-31 13:22:57.591430 INFO [src/alsadevice.rs:792] Capture device supports rate adjust
2025-01-31 13:22:57.611507 INFO [src/alsadevice.rs:970] Capture device is stalled, processing is stalled
2025-01-31 13:23:10.011419 INFO [src/alsadevice.rs:117] PB: Starting playback from Prepared state
2025-01-31 13:23:17.678074 INFO [src/alsadevice.rs:970] Capture device is stalled, processing is stalled
2025-01-31 13:23:23.408887 WARN [src/alsadevice.rs:113] PB: Prepare playback after buffer underrun
2025-01-31 13:23:28.192675 INFO [src/alsadevice.rs:970] Capture device is stalled, processing is stalled
2025-01-31 13:23:33.811463 WARN [src/alsadevice.rs:113] PB: Prepare playback after buffer underrun
2025-01-31 13:23:38.227287 INFO [src/alsadevice.rs:970] Capture device is stalled, processing is stalled

This is working as expected.

Moving on to Make a Measurement, output device "EXCL: Speakers (3- Source/Sink)" sample rate at 48kHz. The Check Level will play, CDSP going from Stalled to Running and sound is heard, then at the end of the 3 second burst CDSP goes INACTIVE with log:
2025-01-31 14:23:45.714920 INFO [src/alsadevice.rs:970] Capture device is stalled, processing is stalled
2025-01-31 14:23:57.893785 WARN [src/alsadevice.rs:113] PB: Prepare playback after buffer underrun
2025-01-31 14:24:01.644637 ERROR [src/bin.rs:354] Capture stopped due to external format change
2025-01-31 14:24:01.644632 INFO [src/alsadevice.rs:983] Capture stopped

I suspect that REW is sending something different at the end of the 3 second Measurement / Check Level burst as compared to Preferences/Soundcard Check Level.

The same happens when the sample rate is set to 96k. CDSP won't start if the REW output device is not in EXCL mode.

However, after restarting CDSP, measurements can be made provided you don't run the Check Level, so I have adopted a procedure where I run the Preferences/Soundcard Check Level to wake the system up, then go to Measure / Make a Measurement , ignore Check Level, just press Start.

It would be good if the Measurement / Check Level did not put CamillaDSP into "inactive" state.
REW V5.40 Beta 67
 

Attachments

Last edited:
Is the behaviour any different if the soundcard preferences "Use pink periodic noise for level checks throughout REW" option is not selected?
 
Same behaviour for either "Use pink periodic noise for level checks throughout REW" selection.
 
Bit of a mystery then, since REW just starts and stops the generator for the level check, wherever it is done.
 
I asked on the CamillaDSP forum and was instructed to run the procedure with debug enabled and it showed a rate change at 2025-02-02 14:51:06.168271:
Code:
2025-02-02 14:51:06.165304 DEBUG [src/alsadevice_utils.rs:406] Event from numid 4
2025-02-02 14:51:06.165335 DEBUG [src/alsadevice_utils.rs:529] Gadget rate: Some(96000)
2025-02-02 14:51:06.165340 DEBUG [src/alsadevice_utils.rs:537] Capture device resumed with unchanged sample rate
2025-02-02 14:51:06.166271 DEBUG [src/alsadevice_utils.rs:406] Event from numid 4
2025-02-02 14:51:06.166280 DEBUG [src/alsadevice_utils.rs:529] Gadget rate: Some(0)
2025-02-02 14:51:06.168266 DEBUG [src/alsadevice_utils.rs:406] Event from numid 4
2025-02-02 14:51:06.168271 DEBUG [src/alsadevice_utils.rs:529] Gadget rate: Some(44100)
2025-02-02 14:51:06.168273 DEBUG [src/alsadevice_utils.rs:421] Stopping, capture device sample format changed
2025-02-02 14:51:06.168278 INFO  [src/alsadevice.rs:983] Capture stopped
2025-02-02 14:51:06.168288 ERROR [src/bin.rs:354] Capture stopped due to external format change
2025-02-02 14:51:06.168300 DEBUG [src/processing.rs:173] Processing thread returned to normal priority.
2025-02-02 14:51:06.168315 DEBUG [src/bin.rs:359] Wait for playback thread to exit..
2025-02-02 14:51:06.168314 DEBUG [src/alsadevice.rs:687] Playback thread returned to normal priority.
2025-02-02 14:51:06.169473 DEBUG [src/bin.rs:1166] Processing ended with status Ok(Restart)
2025-02-02 14:51:06.169483 DEBUG [src/bin.rs:1180] Restarting with new config
2025-02-02 14:51:06.169485 DEBUG [src/bin.rs:1122] Wait for config
2025-02-02 14:51:06.169488 DEBUG [src/bin.rs:1138] Waiting to receive a command

So I changed the capture rate in CamillaDSP to 44100 and the sample rate in REW to 44100 and REW Make a Measurement , check Level will run for 3 seconds and CamillaDSP duly process the signal and at the end of 3 seconds drops back into stalled waiting for the next signal. So, it works at 44100, but doesn't at 48000 and 96000.

Here is the appropriate bit of csjsound-lib.log

Code:
03:51:02.9349114 DEBUG [src\wasapi_impl.rs:883] Found device Speakers (3- Source/Sink)
03:51:02.9351076 DEBUG [src\wasapi_impl.rs:309] Opening Render device Speakers (3- Source/Sink): rate: 96000, validbits: 32, frame_bytes: 8, channels: 2, buffer_bytes: 262144
03:51:02.9356809 DEBUG [src\wasapi_impl.rs:312] Render: default period 100000, min period 30000
03:51:02.9356858 DEBUG [src\wasapi_impl.rs:334] Render: align_segment_bytes: 128, align_segment_ns00: 13333.333333333334, align_segments 23 in approx_dev_period 300000
03:51:02.9356864 DEBUG [src\wasapi_impl.rs:341] Render: Using device period 306667
03:51:02.9365508 DEBUG [src\wasapi_impl.rs:883] Found device Speakers (3- Source/Sink)
03:51:02.9381322 DEBUG [src\wasapi_impl.rs:239] Render device Speakers (3- Source/Sink) supports format WaveFormat { nAvgBytesPerSec: 768000, cbSize: 22, nBlockAlign: 8, wBitsPerSample: 32, nSamplesPerSec: 96000, wFormatTag: 65534, wValidBitsPerSample: 32, SubFormat: 00000001-0000-0010-8000-00AA00389B71, nChannel: 2, dwChannelMask: 3 }
03:51:02.9381418 DEBUG [src\wasapi_impl.rs:868] Opening device Speakers (3- Source/Sink): supports format WaveFormat { nAvgBytesPerSec: 768000, cbSize: 22, nBlockAlign: 8, wBitsPerSample: 32, nSamplesPerSec: 96000, wFormatTag: 65534, wValidBitsPerSample: 32, SubFormat: 00000001-0000-0010-8000-00AA00389B71, nChannel: 2, dwChannelMask: 3 }
03:51:02.9381459 DEBUG [src\wasapi_impl.rs:837] Opening Render device Speakers (3- Source/Sink): will use format WaveFormat { nAvgBytesPerSec: 768000, cbSize: 22, nBlockAlign: 8, wBitsPerSample: 32, nSamplesPerSec: 96000, wFormatTag: 65534, wValidBitsPerSample: 32, SubFormat: 00000001-0000-0010-8000-00AA00389B71, nChannel: 2, dwChannelMask: 3 }
03:51:02.9524635 DEBUG [src\wasapi_impl.rs:858] initialized Render device 0 with device period 306667 and format WaveFormat { nAvgBytesPerSec: 768000, cbSize: 22, nBlockAlign: 8, wBitsPerSample: 32, nSamplesPerSec: 96000, wFormatTag: 65534, wValidBitsPerSample: 32, SubFormat: 00000001-0000-0010-8000-00AA00389B71, nChannel: 2, dwChannelMask: 3 }
03:51:02.9524799 DEBUG [src\wasapi_impl.rs:860] Opened Wasapi device Speakers (3- Source/Sink) in Render
03:51:02.9524989 DEBUG [src\wasapi_impl.rs:515] Device ready and waiting
03:51:02.9526952 WARN [src\wasapi_impl.rs:981] PB INNER: received chunk in stopped device, starting automatically!
03:51:02.9862603 DEBUG [src\wasapi_impl.rs:948] PB INNER: Starting inner loop, stream is already running
03:51:06.5248262 DEBUG [src\wasapi_impl.rs:792] flushing device Speakers (3- Source/Sink)
03:51:06.5248407 DEBUG [src\wasapi_impl.rs:762] requested closing device Speakers (3- Source/Sink)
03:51:06.5248549 DEBUG [src\wasapi_impl.rs:1001] PB INNER: Exiting inner loop

I will check both logs for REW Preferences / Check Level (which works at 48000 and 96000)
 
IMO this issue is not related to REW, but to the way a DSP application is being run on the gadget side of the USB link. Windows mixer and REW use whatever rate the gadget audio device is configured to support. But the DSP application on the gadget side must be able to respond to the gadget rate change induced by the host side. In this particular case the DSP application is not started in a flexible way to respond appropriately, and fails, as is to be expected. Discussed in https://www.diyaudio.com/community/...overs-room-correction-etc.349818/post-7918055 .

IMO there is nothing REW should do differently in this case.
 
Back
Top