Sample rate switcher for CamillaDSP

Member
Joined 2004
I have developed an automatic sample rate switcher for CamillaDSP.
Unlike gaudio_ctl, this tool is dedicated to updating the CamillaDSP configuration, so there is no need for external programs.
It also automatically reloads a valid configuration after the USB playback device has been unavailabe for a while (e.g. when you switch the input of your DAC from USB to S/P-DIF and then back to USB).
Details and software are available on github.

https://github.com/marcoevang/camilladsp-setrate
 
Last edited:
Member
Joined 2015
So, I tried this out and am stymied by the fact that my USB stream doesn't indicate the stream rate as far as I can tell. The only way I could find to get something similar to work was by using the websocket interface to camilladsp and reading the current capture rate then using that information to switch parameters. I'm using a SPDIF->USB converter (UR23).
 
Member
Joined 2004
Would you please briefly describe your setup (music source, computer running camilladsp, capture device, playback device) ?
This might help understanding the problem.
 
Member
Joined 2016
I'm using a SPDIF->USB converter (UR23).
Does the measured capture rate match the incoming rate? Most spdif input devices misbehave if they are fed another rate than the one they expect, so if this one records at the actual incoming rate it's very good news.

The sample rate switcher that @mevang built (which is really cool btw!) is made for USB gadget mode input. If you are using a spdif->usb converter then it won't help.
 
Member
Joined 2015
Yeah, I was just hoping it would work for me with minor mods. The UR23 works ok but it just passes data through and does an electrical convert more or less. I wrote a simple python app to test querying CamillaDsp via websocket and using the changed capture rate to alter the configuration and it works flawlessly when the rate decreases. When the rate increases CamillaDsp exits and it restarts via the .service call which is momentarily painful.

When the rate isn't changing often the python app is just fine.
 
Member
Joined 2023
Hey,
as I am new to pi and Linux, I am struggling with the makefile.
Could you kindly explain how to proceed with it?
I used wget on all scripts listed and made the makefile with vi then tried to use make but it doesn't work for me.
 
Member
Joined 2004
Could you kindly explain how to proceed with it?
First, I would suggest you to install git to download all the required files.

Bash:
sudo apt install git

Once git is installed, you can download the entire project with the following command:
Bash:
git clone https://github.com/marcoevang/camilladsp-setrate
cd camilladsp-setrate

After that, please follow the instructions I posted on github to install the required libraries and the development environment, and to build and install the executable file.
If you succeed in building the executable file, try to launch it by hand in the shell enabling all logging options.
If everything works as expected, you can proceed with configuring the camilladsp-setrate.service service, as described on github, to get the tool launched at boot time.

Instructions for installing the packages are valid on debian-based Linux distributions. On other Linux flavors (e.g. Fedora) the package manager might differ, and the name of the libraries might also differ slightly.

Hope this helps.
 
Last edited:
  • Like
Reactions: 1 user
Member
Joined 2004
The sample rate switcher that @mevang built (which is really cool btw!) is made for USB gadget mode input. If you are using a spdif->usb converter then it won't help.
As @HenrikEnquist pointed out, camilladsp-setrate is meant for use with a USB gadget (i.e. peripheral) capture device. For example, the USB-C port of a Raspberry Pi 4 configured as peripheral would do the trick. Your SPDIF->USB converter box is itself a peripheral that requires the computer to which it is connected to act as host. That's why camilladsp-setrate cannot work in your case.
 
Member
Joined 2015
@mevang thanks. I didn't really know how a "USB gadget" compared with the SPDIF converter so gave it a shot. The code concepts were enough for me to get a python app running so it was pretty useful even if not applicable for me. Thanks.
 
Member
Joined 2005
Yes, in principle the UAC gadget and SPDIF receiver are quite similar, both present a capture alsa device to userspace and both (IF the SPDIF-USB is implemented completely and correctly) provide some alsa control element which informs about current incoming samplerate, which can be tracked externally.
 
Member
Joined 2004
Indeed in camilladsp-setrate the only setting that selects the capture device is the name of the sound card, so in theory it is possible to switch to another type of device just by changing the name. Unfortunately, I have not a capture device with SPDIF input, therefore I am not able to test that use case.
However, I am about to upload a new version of camilladsp-setrate that adds a command option to set the capture card name (in the format returned by arecord -l). This will allow experimenting with SPDIF.
 
Last edited:

TNT

Member
Joined 2003
Paid Member
sudo in this case basically opens up "internet" to your computer as you just gave it total read and write access to the whole computer...

//
 
Member
Joined 2004
sudo in this case basically opens up "internet" to your computer as you just gave it total read and write access to the whole computer...
Yes, I agree. But can you please point out which use case of the sudo command you are referring to?
 

TNT

Member
Joined 2003
Paid Member
Post #7: sudo apt install git

"APT: The commands contained within apt provide the means for installing new software packages, upgrading existing software packages, updating the package list index, and even upgrading the entire Ubuntu system."

//
 
Member
Joined 2004
Post #7: sudo apt install git
Thank you for clarifying.
In the case you refer to, the sudo command is used because the package manager apt requires administrator privileges, and could not be otherwise.
Super-user privileges are only given for installing the required packages; installed packages do not inherit such privileges.
Obviously, it is strongly recommended not to run the camilladsp-setrate tool as super user.
 
  • Like
Reactions: 3 users
Member
Joined 2020
Many folks on the internet could learn from @mevang's patient explanation. @TNT You are correct that sudo commands should be scrutinised. But I can confirm that this is a sensible use of sudo - apt needs to run as super-user to install the "git" package.
 
  • Like
Reactions: 1 user
Top