• WANTED: Happy members who like to discuss audio and other topics related to our interest. Desire to learn and share knowledge of science required. There are many reviews of audio hardware and expert members to help answer your questions. Click here to have your audio equipment measured for free!

RPi4 + CamillaDSP Tutorial

OP
M

mdsimon2

Major Contributor
Forum Donor
Joined
Oct 20, 2020
Messages
2,515
Likes
3,378
Location
Detroit, MI
Guys, i am testing amazon music unlimited and currently i use it this way:
Amazon fire tv stick > hdmi > tv > toslink 16/48> camilladsp > usb 24/96 > topping d30pro
I can see that every album i play in amazon has a different bit depth and sample rate but my tv resamples everything to 16bit/48khz so so far so good with camilladsp :)

I have two questions:

1. If i try to use a hdmi audio extractor and from there via spdif to camilladsp, if understand what was discussed here a few times, camilladsp won't like the sample rate changes and basically i would have to have a config for each possible sample rate and change it manually without a way to automate the change, is this correct?

2. Is there a reason to want to keep the original bit depth/sample rate and try to either do what i described in 1. or to do the upsampling/downsampling in a different device than my tv? Or wanting to do that would be a signal of accute audiofoolitis with no real benefit? If there is indeed a reason, what would be an inexpensive way to do it?

Thanks!

1. First, are you sure that the fire tv stick won't resample the output? Second, as I understand it there are issues with SPDIF interfaces correctly detecting the rate changes. If you can get your interface to detect the rate changes than you should be able to build automated rate switching based on that. If you can see the rate changes (for example in the CamillaDSP GUI) let me know and I'll see if I can write a python script to reload a new configuration based on the new rate.

2. I do think avoiding the TV resampling is a good idea. My TV does a really terrible job at resampling (see image below) and actually limits everything to worse than CD quality. Although you should be able to measure the TV resampling with your SPDIF interface and see how it does. Amazon actually has a decent CD quality test tone (Audiophiles vol 1, 1 kHz, -1 LUFS/LKFS, DO NOT USE -0 LUFS/LKFS AS IT IS LOSSY).

1654391800254.png


If you can't get rate switching to work the easy way to solve this is to use an external ASRC like a miniDSP OpenDRC-DI or a nanoDIGI. They do a very good job at resampling and also give you some source switching although are rather expensive if you are just using them as a resamplers.

Michael
 

MCH

Major Contributor
Joined
Apr 10, 2021
Messages
2,663
Likes
2,275
Thank you Michael, that is exactly the sort of information i was looking for. To your comments:
1. First, are you sure that the fire tv stick won't resample the output?
Well, whatever happens between the fire stick and my tv, i have no idea, that's why i did not comment on that. I see here in ASR a couple of threads discussing this, and my takeaway from there is that Amazon fire stick upsamples everything to the maximum capability of the device that is connected to with a ceiling of 24/192, no matter what the original sample was and what the info on the screen tells you (link below). In my case the device capability is 24/192 so i assume that everything is upsampled to that and this is what is going out of the stick HDMI. Now, what is woing to happen when i plug an audio extractor, i have no idea either, but until i try it, i will assume that it will upsample everything to 24/192 (?)


Second, as I understand it there are issues with SPDIF interfaces correctly detecting the rate changes. If you can get your interface to detect the rate changes than you should be able to build automated rate switching based on that. If you can see the rate changes (for example in the CamillaDSP GUI) let me know and I'll see if I can write a python script to reload a new configuration based on the new rate.
Ok, good to know. I am still far from reaching that point (i dont even have an audio extractor yet), but if i ever go there and need help, will let you know. Thanks!
2. I do think avoiding the TV resampling is a good idea. My TV does a really terrible job at resampling (see image below) and actually limits everything to worse than CD quality. Although you should be able to measure the TV resampling with your SPDIF interface and see how it does. Amazon actually has a decent CD quality test tone (Audiophiles vol 1, 1 kHz, -1 LUFS/LKFS, DO NOT USE -0 LUFS/LKFS AS IT IS LOSSY).
Cool, thanks. I found the file and did the measurement (not sure if i did it well though....) and got a TDH+N of -95.5 db, i guess not bad and pretty close to -96 db, so i might settle with this until i think on a longer term solution.

If you can't get rate switching to work the easy way to solve this is to use an external ASRC like a miniDSP OpenDRC-DI or a nanoDIGI. They do a very good job at resampling and also give you some source switching although are rather expensive if you are just using them as a resamplers.

Michael
OK, i hope not to have to get one of these... being on the fence of getting a minidsp flex or a used SHD, i am not sure i want to invest >200 eur in another box right now. Might give a try to audio extractor > capture card, and if everything is upsampled at 24/192, well, no need to do anything special with camilladsp, and if not, might continue passing the signal through the tv until i build something completely different.

Thanks again, very informative and good learning.
 

MCH

Major Contributor
Joined
Apr 10, 2021
Messages
2,663
Likes
2,275
Well, whatever happens between the fire stick and my tv, i have no idea, that's why i did not comment on that. I see here in ASR a couple of threads discussing this, and my takeaway from there is that Amazon fire stick upsamples everything to the maximum capability of the device that is connected to with a ceiling of 24/192, no matter what the original sample was and what the info on the screen tells you (link below). In my case the device capability is 24/192 so i assume that everything is upsampled to that and this is what is going out of the stick HDMI. Now, what is woing to happen when i plug an audio extractor, i have no idea either, but until i try it, i will assume that it will upsample everything to 24/192 (?)
Today i got the Amazon basics HDMI audio extractor and yes, it outputs 192 kHz to both coax and toslink no matter what Amazon music says on the screen or what the original sample rate of the music is.

Well, I guess this is advantageous for camilladsp users as it solves the sample rate change issue and thats why I am posting.

Now I just need to get a spdif input card or hat capable of 24/192 and there aren't so many...

@mdsimon2 you commented you have used the hifiberry digi+ i/o, right? Do you think it is possible to have one source connected to coax at 24/192 and a second source to toslink at 16/48 and switch between the two using two different configurations? Do coax and toslink inputs show as different devices? Thanks for your input
 
OP
M

mdsimon2

Major Contributor
Forum Donor
Joined
Oct 20, 2020
Messages
2,515
Likes
3,378
Location
Detroit, MI
I do have a hifiberry digi+ I/O although not in use currently. I am 99% sure it only presents 2 ch input to ALSA so it doesn't differentiate between coax and optical. That HAT in particular seems to struggle if there are pauses in your digital input stream as described here -> https://www.audiosciencereview.com/...s/rpi4-camilladsp-tutorial.29656/post-1199740 so probably not the best option if switching between two streams.

To do what you want you need one of the following IMO.

1) Digital input device that can switch between coaxial and TOSLINK input. Ideally with the ability for clock source to be controlled in ALSA. For example the Focusrite 18i20 has this ability but the MOTU Ultralite Mk5 does not and the clock source needs to be changed on the front panel. I do wonder what the cheapest USB audio interface is that has SPDIF and TOSLINK inputs.

2) Digital input device that has coaxial and TOSLINK inputs but is only treated as a single stereo input in ALSA that handles stream pauses gracefully without crashing. Not sure if such a device exists.

3) Digital input device with ASRC that automatically converts all inputs to a consistent sample rate. A miniDSP 2X4HD can do this but only has a single TOSLINK input. A hifiberry DAC+ DSP can do this but is a pain to use and won't work under Ubuntu last I checked and also only has a single TOSLINK input.

Michael
 
  • Like
Reactions: MCH

MCH

Major Contributor
Joined
Apr 10, 2021
Messages
2,663
Likes
2,275
I do have a hifiberry digi+ I/O although not in use currently. I am 99% sure it only presents 2 ch input to ALSA so it doesn't differentiate between coax and optical. That HAT in particular seems to struggle if there are pauses in your digital input stream as described here -> https://www.audiosciencereview.com/...s/rpi4-camilladsp-tutorial.29656/post-1199740 so probably not the best option if switching between two streams.

To do what you want you need one of the following IMO.

1) Digital input device that can switch between coaxial and TOSLINK input. Ideally with the ability for clock source to be controlled in ALSA. For example the Focusrite 18i20 has this ability but the MOTU Ultralite Mk5 does not and the clock source needs to be changed on the front panel. I do wonder what the cheapest USB audio interface is that has SPDIF and TOSLINK inputs.

2) Digital input device that has coaxial and TOSLINK inputs but is only treated as a single stereo input in ALSA that handles stream pauses gracefully without crashing. Not sure if such a device exists.

3) Digital input device with ASRC that automatically converts all inputs to a consistent sample rate. A miniDSP 2X4HD can do this but only has a single TOSLINK input. A hifiberry DAC+ DSP can do this but is a pain to use and won't work under Ubuntu last I checked and also only has a single TOSLINK input.

Michael
Well, or two different input cards, right?
But bah, i think i am not going to get into so much trouble, will let the tv do the job for now, it works fine and sounds good enough.
Thanks for the info on the hifiberry, will save me a few euros and a headache trying to make it work.
 
OP
M

mdsimon2

Major Contributor
Forum Donor
Joined
Oct 20, 2020
Messages
2,515
Likes
3,378
Location
Detroit, MI
Well, or two different input cards, right?
But bah, i think i am not going to get into so much trouble, will let the tv do the job for now, it works fine and sounds good enough.
Thanks for the info on the hifiberry, will save me a few euros and a headache trying to make it work.

Two inputs seems like a really good option, just switch between configs.

Have you seen the devices linked below?


First one does 96/24 ($25) and second one does 192/32 ($40) although both are optical and in my experience optical doesn't really work above 96 kHz due to receiver / transmitter design constraints.

Is there anyway you can set your fire stick to resample to 96 kHz instead of 192 kHz?

Michael
 
  • Like
Reactions: MCH

MCH

Major Contributor
Joined
Apr 10, 2021
Messages
2,663
Likes
2,275
Two inputs seems like a really good option, just switch between configs.

Have you seen the devices linked below?


First one does 96/24 ($25) and second one does 192/32 ($40) although both are optical and in my experience optical doesn't really work above 96 kHz due to receiver / transmitter design constraints.

Is there anyway you can set your fire stick to resample to 96 kHz instead of 192 kHz?

Michael
Oh thank you so much! I have been searching for something like that all these days without any success. I was even convinced such a thing does not exist.

I only had little time to play with the audio extractor but it seems that once you get into amazon music app with the fire stick it automatically starts tp output at 192 khz no matter what. It doesn't seem to be a way to change the sample rate.

But the good news is that if i plug the toslink out from the extractor to my dac (d30pro) directly it accepts the signal and plays without any problem at 192 khz. So your second suggestion should work.
might gice it a try if i find the way to get it to Europe at a reasonable price, I still have one usb slot free in my pi :D
 

Wirrunna

Member
Joined
May 27, 2021
Messages
93
Likes
45
Location
South Coast, NSW, Australia
Michael,

'scuse my ignorance, but how do I update the camilladsp-plot ? The GUI was explained earlier - delete, download and unzip.
 
OP
M

mdsimon2

Major Contributor
Forum Donor
Joined
Oct 20, 2020
Messages
2,515
Likes
3,378
Location
Detroit, MI
Michael,

'scuse my ignorance, but how do I update the camilladsp-plot ? The GUI was explained earlier - delete, download and unzip.

Very similar, delete the old folder via "sudo rm -r ~/camilladsp/pycamilladsp-plot" and repeat the pycamilladsp-plot install instructions in step 13.

Michael
 
OP
M

mdsimon2

Major Contributor
Forum Donor
Joined
Oct 20, 2020
Messages
2,515
Likes
3,378
Location
Detroit, MI
You can simplify step 12 and 13 by letting pip fetch directly from GitHub.
Something like:
Code:
pip install git+https://github.com/HEnquist/pycamilladsp-plot.git
No need to clone :)

Thanks Henrik! Command below works perfectly.

Code:
sudo pip3 install git+https://github.com/HEnquist/pycamilladsp-plot.git

I assume that if there is a new version available and I run this command it just overwrites the old version?

In general probably time to give the tutorial some editing and see where I can simplify. I really like your suggested command because it removes directory changes which have been a source of trouble for some folks. Next update will remove as many of those as practicable.

Michael
 

MCH

Major Contributor
Joined
Apr 10, 2021
Messages
2,663
Likes
2,275
In general probably time to give the tutorial some editing and see where I can simplify. I really like your suggested command because it removes directory changes which have been a source of trouble for some folks. Next update will remove as many of those as practicable.

Michael
Hey Michael, i don't know if there is an easy way to do it but it would be good to have some sort of archive with the older versions of your tutorial. Can be handy if you need to look back at some pàrticular setting or change something but you don't fancy having to start from zero... i personally regret not to have copy/pasted the first version already :)
 
OP
M

mdsimon2

Major Contributor
Forum Donor
Joined
Oct 20, 2020
Messages
2,515
Likes
3,378
Location
Detroit, MI
Hey Michael, i don't know if there is an easy way to do it but it would be good to have some sort of archive with the older versions of your tutorial. Can be handy if you need to look back at some pàrticular setting or change something but you don't fancy having to start from zero... i personally regret not to have copy/pasted the first version already :)

Ahh...good call. I was thinking about that as the step numbers changed. I'll print to PDF and attach to first post from now on.

Michael
 

HenrikEnquist

Member
Joined
Jul 1, 2021
Messages
82
Likes
110
I assume that if there is a new version available and I run this command it just overwrites the old version?
Yes exactly. You can also specify exactly which version to install:
sudo pip3 install git+https://github.com/HEnquist/pycamilladsp-plot.git@reference
Here reference is any git reference, like a branch or tag name, or a commit hash. For example to install the v1.0.1 release you type:
sudo pip3 install git+https://github.com/HEnquist/[email protected]
 

chuckt62

Active Member
Editor
Joined
Apr 6, 2022
Messages
142
Likes
123
Location
Tejas
I just received a RPi4-4GB and went through the tutorial to get CamillaDSP setup for the M4. That part seems to be working fine, thanks @mdsimon2. I've previously made some crossover filters for Camilla in Volumio (FusionDSP) on an old Pi2b. I'll get those implemented after I get some sound through this new setup. I guess the next step is to get LMS going for Squeezelite. This is where things get a little fuzzy. Should I install LMS on the Pi4 w/SQlite & Camilla, or the Pi2b? I also have a miniPC running Windows10 that I've been streaming Spotify from w/Voicemeeter Banana & EqualizerAPO. I'd rather not use the miniPC for LMS but I will if it will improve performance.
I can only assume Squeezelite is running correctly as I don't know of any way to check this. It doesn't show up as a device anywhere. I was hoping I could just play to it from the Spotify app but no joy.
Is there a good tutorial for LMS on ASR, I haven't run across anything? If there is, it might be a good idea to provide a note or link to it on page 1 for noobs like myself.
 
OP
M

mdsimon2

Major Contributor
Forum Donor
Joined
Oct 20, 2020
Messages
2,515
Likes
3,378
Location
Detroit, MI
Glad to hear you got it up and running!

On Ubuntu 21.10 I would have said download and install the arm deb from here -> https://downloads.slimdevices.com/LogitechMediaServer_v8.2.0/.

Code:
sudo apt install libio-socket-ssl-perl
wget https://downloads.slimdevices.com/LogitechMediaServer_v8.2.0/logitechmediaserver_8.2.0_arm.deb
sudo dpkg -i logitechmediaserver_8.2.0_arm.deb

Unfortunately Ubuntu 22.04 runs Perl 5.34 which is not currently supported by LMS. I was able to build my own LMS that supports Perl 5.34 more or less following these instructions -> https://angerman.net/articles/lms/ but I would not recommend that to a beginner.

Running a separate RPi with LMS is probably the simplest option. I believe Raspberry Pi OS includes LMS as a package so it is very easy to install using apt. Otherwise I've used Ubuntu 20.04 and that also works well but you need to install LMS via the instructions above. @MarcosCh has a tutorial here for setting up LMS using PiCorePlayer -> https://www.audiosciencereview.com/...-step-by-step-instructions-for-dummies.33528/.

I am not a LMS guru by any means so I am sure there are other better options. If it is just Spotify you are after then the instructions below will install librespot, although to be honest a working LMS setup gives the same thing but is more straight forward.

1) Install Rust

Code:
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

Enter 1 at the prompt to select Select 1) Proceed with installation (default) and press enter.

Reboot RPi.

Code:
sudo reboot

Log back in to RPi

Code:
ssh username@hostname

2) Install dependencies

Code:
sudo apt install build-essential libasound2-dev pkg-config

3) Download and install librespot

This assumes you are installing this in /home/username/. You can verify your location using pwd.

Code:
git clone https://github.com/librespot-org/librespot
cd librespot
cargo build --release --no-default-features --features alsa-backend

Compiling librespot will take 10-15 minutes on a RPi4.

4) Try librespot

Rich (BB code):
/home/username/librespot/target/release/librespot --format S32 --device hw:Loopback,1

You should now see a device called Librespot in your Spotify app.

5) Setup service to automatically start Librespot.

Code:
sudo nano /lib/systemd/system/librespot.service

You will need to update your username.

Rich (BB code):
[Unit]
Description=Spotify Connect
After=multi-user.target

[Service]
User=username
Type=idle
ExecStart=/home/username/librespot/target/release/librespot --format S32 --device hw:Loopback,1

[Install]
WantedBy=multi-user.target

Reboot the RPi.

Code:
sudo reboot

Good luck!

Michael
 

dfgoiuj

Member
Joined
Mar 22, 2022
Messages
43
Likes
5
Hi @mdsimon2, I used your excellent guide along with 'Budget Standalone "Toslink > DSP > Toslink" with Camilladsp. Set up instructions for newbies.' posted by @MarcosCh

I'm using an RPi 3 with a cheapo ICUSBAUDIO7 for TOSLINK in/out. I believe I have everything running at 48000 and receive a 48000 signal from my TV. I don't resample because of this, and output to a Topping DAC after applying a DRC filter in WAV format.

What I'm finding is that I get occasional popping noises while audio is playing. Sometimes I can go a minute or so without hearing it, other times it's fairly common. I reduced gain by 9dB so that I'm not clipping, and although the RPi 3 is slower than the 4, 'top' reports that my CPU is still only 10% utilised. I've played around with chunksize and currently have it set to 1024. I'm using a 2.4A PSU which will be replaced by an official RPi supply tomorrow, although I only see a single report of undervoltage in the log.

I've used the same DAC on a Windows virtual machine and haven't experienced this, so I believe the device is okay.

Any ideas?
 
Last edited:

EdW

Senior Member
Joined
Jul 5, 2020
Messages
346
Likes
444
Location
Cambridge, UK
Hi @mdsimon2, I used your excellent guide along with 'Budget Standalone "Toslink > DSP > Toslink" with Camilladsp. Set up instructions for newbies.' posted by @MarcosCh

I'm using an RPi 3 with a cheapo ICUSBAUDIO7 for TOSLINK in/out. I believe I have everything running at 48000 and receive a 48000 signal from my TV. I don't resample because of this, and output to a Topping DAC after applying a DRC filter in WAV format.

What I'm finding is that I get occasional popping noises while audio is playing. Sometimes I can go a minute or so without hearing it, other times it's fairly common. I reduced gain by 9dB so that I'm not clipping, and although the RPi 3 is slower than the 4, 'top' reports that my CPU is still only 10% utilised. I've played around with chunksize and currently have it set to 1024. I'm using a 2.4A PSU which will be replaced by an official RPi supply tomorrow, although I only see a single report of undervoltage in the log.

I've used the same DAC on a Windows virtual machine and haven't experienced this, so I believe the device is okay.

Any ideas?
there are known issues with the RPI3 streaming to the USB ports (which the RPI4 doesn’t suffer from). It will probably depend on your software, but there have been one or two mentions of this on various ASR forums.
EDIT: Anyone more knowledgeable like to chime in here?
 
OP
M

mdsimon2

Major Contributor
Forum Donor
Joined
Oct 20, 2020
Messages
2,515
Likes
3,378
Location
Detroit, MI
Hi @mdsimon2, I used your excellent guide along with 'Budget Standalone "Toslink > DSP > Toslink" with Camilladsp. Set up instructions for newbies.' posted by @MarcosCh

I'm using an RPi 3 with a cheapo ICUSBAUDIO7 for TOSLINK in/out. I believe I have everything running at 48000 and receive a 48000 signal from my TV. I don't resample because of this, and output to a Topping DAC after applying a DRC filter in WAV format.

What I'm finding is that I get occasional popping noises while audio is playing. Sometimes I can go a minute or so without hearing it, other times it's fairly common. I reduced gain by 9dB so that I'm not clipping, and although the RPi 3 is slower than the 4, 'top' reports that my CPU is still only 10% utilised. I've played around with chunksize and currently have it set to 1024. I'm using a 2.4A PSU which will be replaced by an official RPi supply tomorrow, although I only see a single report of undervoltage in the log.

I've used the same DAC on a Windows virtual machine and haven't experienced this, so I believe the device is okay.

Any ideas?

Hmm...a lot of potential issues but I do not see a smoking gun, here are a few thoughts.

First look at the CamillaDSP log to see if there is any evidence of buffer underruns or any other weird issues. If there are buffer underruns it likely means that you need to increase chunk size and potentially enable resampling / rate adjust. I would also look in alsamixer to see if there are any clocking options for the ICUSBAUDIO7, you want to clock from the TOSLINK input not the internal clock.

I assume you are using the TOSLINK output of the ICUSBAUDIO7 directly in to the Topping DAC? If so most newer Topping DACs have issues with some TOSLINK sources and that may be the culprit. You could try using the Topping DAC as a playback device in CamillaDSP (basically use the USB input of the Topping DAC), however you would definitely need to enable resampling and rate adjust to bridge the clock domains.

As @EdW some folks have reported issues using USB audio out of RPi3s but this sounds more like a clocking issue IMHO.

EDIT: One final thing I forgot, the digital output of some TVs is really bad. I get the occasional drop out with every DAC I’ve tried with my TV and the quantitatively the output won’t even retain 16 bit fidelity.

Michael
 
Last edited:
  • Like
Reactions: MCH
Top Bottom