Sample rate switcher for CamillaDSP

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:
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).
 
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.
 
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.
 
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
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.
 
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.
 
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
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."

//
 
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