8xIN+8xOUT samplerate

Hi there! I’m getting problem trying to set 384 kHz samplerate for playback. 192 kHz is no prob, but with 384 CamillaDSP v4 troughs error “[camilladsp] <src/bin.rs:315> Playback error: ALSA function ‘snd_pcm_hw_params_set_rate’ failed with error 'Invalid argument (22)”. Kernel 6.18.23-v8-16k+

Hi,

Thanks for the report.

This error usually means that ALSA rejected the requested sample rate before CamillaDSP could start:

snd_pcm_hw_params_set_rate failed with Invalid argument (22)

So first we need to check whether the Raspberry Pi kernel driver exposes 384 kHz for the card, or only up to 192 kHz.

Could you please run the following commands and paste the output here?

aplay -l
cat /proc/asound/cards
Then please try a direct ALSA test, without CamillaDSP:

speaker-test -D plughw:2,0 -c8 -r 192000 -F S32_LE -t sine -l 1
speaker-test -D plughw:2,0 -c8 -r 384000 -F S32_LE -t sine -l 1





Please replace plughw:2,0 with the correct card/device number shown by aplay -l if your card number is different.

If 192 kHz works and 384 kHz fails with speaker-test too, then the problem is not CamillaDSP. It means the current Raspberry Pi OS kernel/ALSA driver does not accept 384 kHz for this card.

For now, we recommend using 192 kHz as the reliable setting. We will also check on our side whether the driver/overlay can expose 384 kHz correctly on recent Raspberry Pi kernels.

Thanks for responding! Both speaker-test commands worked.

yourgis@Silkius:~ $ speaker-test -D plughw:1,0 -c8 -r 192000 -F S32_LE -t sine -l 1

speaker-test 1.2.14

Playback device is plughw:1,0
Stream parameters are 192000Hz, S32_LE, 8 channels
Sine wave rate is 440.0000Hz
Rate set to 192000Hz (requested 192000Hz)
Buffer size range from 2 to 16384
Period size range from 1 to 8192
Periods = 4
was set period_size = 8192
was set buffer_size = 16384
0 - Front Left
4 - Center
1 - Front Right
7 - Side Right
3 - Rear Right
2 - Rear Left
6 - Side Left
5 - LFE
Time per period = 23.809846
yourgis@Silkius:~ $ speaker-test -D plughw:1,0 -c8 -r 384000 -F S32_LE -t sine -l 1

speaker-test 1.2.14

Playback device is plughw:1,0
Stream parameters are 384000Hz, S32_LE, 8 channels
Sine wave rate is 440.0000Hz
Rate set to 384000Hz (requested 384000Hz)
Buffer size range from 4 to 32768
Period size range from 1 to 16385
Periods = 4
was set period_size = 16384
was set buffer_size = 32768
0 - Front Left
4 - Center
1 - Front Right
7 - Side Right
3 - Rear Right
2 - Rearb Left
6 - Side Left
5 - LFE
Time per period = 23.812689

But without plug before hw (just hw2,0) 384000 does not work. 192000 does. With plughw I can even use -r 768000, but I think alsa plugin just downsamples it to the specs, that hardware accepts? Because when checking hw_params when speaker-test is running with plughw and 384000, hardware is being opened with 192000:

cat /proc/asound/card1/pcm0p/sub0/hw_params
access: MMAP_INTERLEAVED
format: S32_LE
subformat: STD
channels: 8
rate: 192000 (192000/1)
period_size: 8192
buffer_size: 16384

yourgis@Silkius:~ $ speaker-test -D hw:1,0 -c8 -r 384000 -F S32_LE -t sine -l 1

speaker-test 1.2.14

Playback device is hw:1,0
Stream parameters are 384000Hz, S32_LE, 8 channels
Sine wave rate is 440.0000Hz
Rate 384000Hz not available for playback: Invalid argument
Setting of hwparams failed: Invalid argument
yourgis@Silkius:~ $ ^C
yourgis@Silkius:~ $ ^C
yourgis@Silkius:~ $ speaker-test -D hw:1,0 -c8 -r 192000 -F S32_LE -t sine -l 1

speaker-test 1.2.14

Playback device is hw:1,0
Stream parameters are 192000Hz, S32_LE, 8 channels
Sine wave rate is 440.0000Hz
Rate set to 192000Hz (requested 192000Hz)
Buffer size range from 2 to 16384
Period size range from 1 to 8192
Periods = 4
was set period_size = 8192
was set buffer_size = 16384
0 - Front Left

4 - Center
1 - Front Right
7 - Side Right
3 - Rear Right
2 - Rear Left
6 - Side Left
5 - LFE
Time per period = 0.867876

Checking hw-params, it’s 192000.

yourgis@Silkius:~ $ aplay -D hw:1,0 --dump-hw-params /dev/zero

Playing raw data ‘/dev/zero’ : Unsigned 8 bit, Rate 8000 Hz, Mono
HW Params of device “hw:1,0”:

ACCESS: MMAP_INTERLEAVED RW_INTERLEAVED

FORMAT: S16_LE S24_LE S32_LE
SUBFORMAT: STD MSBITS_MAX
SAMPLE_BITS: [16 32]
FRAME_BITS: [32 256]
CHANNELS: [2 8]
RATE: [8000 192000]
PERIOD_TIME: (5 8192000]
PERIOD_SIZE: [1 65536]
PERIOD_BYTES: [32 262144]
PERIODS: [2 131072]
BUFFER_TIME: (10 16384000]
BUFFER_SIZE: [2 131072]
BUFFER_BYTES: [32 524288]
TICK_TIME: ALL

aplay: set_params:1387: Sample format non available
Available formats:

  • S16_LE
  • S24_LE
  • S32_LE

yourgis@Silkius:~ $ aplay -l
**** List of PLAYBACK Hardware Devices ****
card 1: sndrpihifiberry [snd_rpi_hifiberry_dac8x], device 0: HiFiBerry DAC8xADC8x HiFi snd-soc-dummy-dai-0 [HiFiBerry DAC8xADC8x HiFi snd-soc-dummy-dai-0]
Subdevices: 1/1
Subdevice #0: subdevice #0