Just don't use that asound.conf file! ALSA won't do any resampling if you don't ask for it by defining a plug device.
EDIT: Sorry about all this verbiage. TL;DR:
squeezelite reopens the alsa device in the plug mode if the audio file's rate is lower than the samplerate. If the audio file's rate is higher, LMS downsamples with sox.
EDIT: In summary, either use the squeezelite -R flag or the previously mentioned alsa_cdsp if you want to have camillaDSP do the resampling. Otherwise squeezelite will use alsa's resampling.
https://github.com/scripple/alsa_cdsp
Info on squeezelite resampling:
https://soundcheck-audio.blogspot.com/2011/04/resampling-if-you-cant-avoid-it.html
I use Archimago's settings
http://archimago.blogspot.com/2017/12/howto-musings-playing-with-digital_23.html
...
Thanks. I removed /etc/asound.conf and rebooted. I hope this isn't getting too tiresome, but I'm still confused about where resampling is taking place. There are 4 places it could take place:
* My squeezebox server (LMS). This uses a sox process for resampling, if needed. My LMS config just passes flac files thru, and no sox process is running during playback (of, say, RBCD files).
* Squeezelite. My reading of the man page is that you have to use the -u or -R flag for resampling to take place, but maybe it does it anyway?
My squeezelite command is:
Bash:
/usr/bin/squeezelite -n pi4 -o hw:Loopback,0 -a 120 4 32 1
* Alsa. Should not be resampling in my case.
* CamillaDSP
So I tried turning off any resampling in camillaDSP
YAML:
devices:
samplerate: 96000
buffersize: 8192
enable_rate_adjust: false
enable_resampling: false
capture:
type: Alsa
channels: 2
device: "hw:Loopback,1"
format: S32LE
playback:
type: Alsa
channels: 4
device: "hw:CARD=M4"
format: S32LE
I notice in the status output it says
Code:
● camilladsp.service - CamillaDSP Daemon
Loaded: loaded (/etc/systemd/system/camilladsp.service; enabled; vendor preset: enabled)
Active: active (running) since Fri 2021-07-02 22:07:01 UTC; 9min ago
Main PID: 2692 (camilladsp)
Tasks: 6 (limit: 969)
Memory: 1.2M
CGroup: /system.slice/camilladsp.service
└─2692 /usr/local/bin/camilladsp /home/ubuntu/my-camilladsp-config/alsaconfig.yml -p 1>
Jul 02 22:07:01 ubuntu systemd[1]: Started CamillaDSP Daemon.
Jul 02 22:07:01 ubuntu camilladsp[2692]: 22:07:01.551 [INFO] Capture device supports rate adjust
Jul 02 22:07:01 ubuntu camilladsp[2692]: 22:07:01.648 [INFO] Starting playback from Prepared state
I'm not sure what "Capture device supports rate adjust" refers to here.
My /proc/asound looks like
Bash:
$ cat /proc/asound/Loopback/pcm1c/sub0/hw_params
access: RW_INTERLEAVED
format: S32_LE
subformat: STD
channels: 2
rate: 96000 (96000/1)
period_size: 4096
buffer_size: 32768
and
Bash:
$ cat /proc/asound/Loopback/pcm0p/sub0/hw_params
access: MMAP_INTERLEAVED
format: S32_LE
subformat: STD
channels: 2
rate: 96000 (96000/1)
period_size: 2880
buffer_size: 11520
EDIT: I tried using aplay to see what it would do with the wrong sample rate:
Bash:
aplay -D hw:CARD=Loopback,DEV=0 01_orpheus_haydn.wav
Playing WAVE '01_orpheus_haydn.wav' : Signed 32 bit Little Endian, Rate 44100 Hz, Stereo
Warning: rate is not accurate (requested = 44100Hz, got = 96000Hz)
please, try the plug plugin
So alsa isn't doing it.
EDIT: Well, alsa
is doing the resampling, but only because squeezelite reopens the resampling alsa device when there's a samplerate mismatch. From the squeezelite debug output:
Code:
[00:05:28.205807] _output_frames:152 track start sample rate: 44100 replay_gain: 0
[00:05:28.215785] sendSTAT:195 STAT: STMs
[00:05:28.216042] sendSTAT:195 STAT: STMt
[00:05:28.216166] output_thread:687 open output device: hw:Loopback,0
[00:05:28.216394] alsa_open:351 opening device at: 44100
[00:05:28.217116] alsa_open:381 reopening device hw:Loopback,0 in plug mode as plughw:Loopback,0 for resampling
[00:05:28.217951] alsa_open:422 opened device plughw:Loopback,0 using format: S32_LE sample rate: 44100 mmap: 1
So it first tries opening the hw device at 44100 then reopens it in plug mode.
So it seems better in this case to turn squeezelite upsampling back on with the -R option since this uses the sox resampling library.
By the way, in the case of audio with a higher sampling rate than the max reported to LMS by squeezelite, LMS automatically downsamples using sox based on what squeezelite reports to it:
Bash:
sh -c "/usr/share/squeezeboxserver/Bin/x86_64-linux/flac" -dcs --force-raw-format --sign=signed --endian=little -- - | "/usr/share/squeezeboxserver/Bin/x86_64-linux/sox" -q -t raw --encoding signed-integer -b 24 -r 192000 -c 2 -L - -t flac -r 96000 -C 0 -
But LMS is not upsampling RBCD files (no sox running in that case).