• 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

nabiullin

Member
Joined
Jul 16, 2023
Messages
6
Likes
0
with this config Camilla after ctart working 20-30 minutes

description: null
devices:
adjust_period: null
capture:
channels: 8
device: hw:Loopback,0,0
format: S32LE
type: Alsa
capture_samplerate: null
chunksize: 2048
enable_rate_adjust: null
playback:
channels: 8
device: plughw:R71,0,0
format: S32LE
type: Alsa
queuelimit: null
rate_measure_interval: null
resampler: null
samplerate: 96000
silence_threshold: -60
silence_timeout: 3
stop_on_rate_change: null
target_level: null
volume_ramp_time: null
filters:
Unnamed Filter 1:
description: null
parameters:
freq: 1000
order: 12
type: ButterworthHighpass
type: BiquadCombo
Unnamed Filter 2:
description: null
parameters:
freq: 1000
order: 12
type: ButterworthLowpass
type: BiquadCombo
mixers:
8x8:
channels:
in: 8
out: 8
description: null
mapping:
- dest: 0
mute: null
sources:
- channel: 0
gain: 0
inverted: false
mute: null
scale: null
- dest: 1
mute: null
sources:
- channel: 1
gain: 0
inverted: false
mute: null
scale: null
- dest: 2
mute: false
sources:
- channel: 0
gain: 0
inverted: false
mute: false
scale: dB
- dest: 3
mute: false
sources:
- channel: 1
gain: 0
inverted: false
mute: false
scale: dB
- dest: 4
mute: false
sources:
- channel: 0
gain: 0
inverted: false
mute: false
scale: dB
- dest: 5
mute: false
sources:
- channel: 1
gain: 0
inverted: false
mute: false
scale: dB
- dest: 6
mute: false
sources:
- channel: 0
gain: 0
inverted: false
mute: false
scale: dB
- dest: 7
mute: false
sources:
- channel: 1
gain: 0
inverted: false
mute: false
scale: dB
pipeline:
- bypassed: null
description: null
name: 8x8
type: Mixer
- bypassed: null
channel: 0
description: null
names:
- Unnamed Filter 1
type: Filter
- bypassed: null
channel: 1
description: null
names:
- Unnamed Filter 1
type: Filter
processors: null
title: null

and then fail with this error

2024-01-29 18:12:38.099809 DEBUG [src/alsadevice.rs:573] PB: buffer level: 8218.1, signal rms: Some(HistoryRecord { time: Instant { tv_sec: 1894, tv_nsec: 528775560 }, values: [4.6523282e-6, 3.4454824e-6, 0.00044679746, 0.00028649936, 0.00044679746, 0.00028649936, 0.00044679746, 0.00028649936] })
2024-01-29 18:12:44.923569 WARN [src/alsadevice.rs:312] Capture failed, error: ALSA function 'snd_pcm_readi' failed with error 'EPIPE: Broken pipe'
2024-01-29 18:12:44.924095 ERROR [src/bin.rs:307] Capture error: ALSA function 'snd_pcm_readi' failed with error 'EPIPE: Broken pipe'
2024-01-29 18:12:44.924250 DEBUG [src/bin.rs:312] Wait for playback thread to exit..
2024-01-29 18:12:45.132177 DEBUG [src/bin.rs:1038] Processing ended with status Ok(Restart)
2024-01-29 18:12:45.132361 DEBUG [src/bin.rs:1052] Restarting with new config
2024-01-29 18:12:45.132399 DEBUG [src/bin.rs:994] Wait for config
2024-01-29 18:12:45.132444 DEBUG [src/bin.rs:1004] Wait mode is disabled, there are no queued commands, and no new config. Exiting.
 

Nisse10000

Member
Joined
Nov 14, 2022
Messages
30
Likes
15
When I get Message channel error: receiving on a closed channel it is usually that I haven’t stopped the source.

Error after 20~30 min may be a bug?
 

nabiullin

Member
Joined
Jul 16, 2023
Messages
6
Likes
0
Some details: the program crashes with the above error in the log exactly at the frequency of 96 khz in the above configuration.
When I set 44.1 khz, it works stably and does not crash.
The other conditions are all the same (the player via alsa works in a loop with one playlist).
 

phofman

Addicted to Fun and Learning
Joined
Apr 13, 2021
Messages
503
Likes
328
Actually it's not crashing, it is not correctly configured. If two clock domains are involved, the clocking needs to be taken care of. Either by feedback rate control, or asynchronous resampling.

A different samplerate just produces different time to buffer issue.
 

nabiullin

Member
Joined
Jul 16, 2023
Messages
6
Likes
0
Actually it's not crashing, it is not correctly configured. If two clock domains are involved, the clocking needs to be taken care of. Either by feedback rate control, or asynchronous resampling.

A different samplerate just produces different time to buffer issue.

I understand that you need to dive into the documentation of the yml profile settings in more detail, make match sampling rate parameters of the capture and output devices
 

nabiullin

Member
Joined
Jul 16, 2023
Messages
6
Likes
0
Life is so much easier if you lose your upsampling phobia and just upsample everything to the maximum bit rate you need. If you do not upsample, your DAC will (usually).

yes, this is exactly what I want to achieve with configuration settings, so that any audio file being played goes out to the DAC at a fixed preset frequency, for example 96 or 192 khz.
 

phofman

Addicted to Fun and Learning
Joined
Apr 13, 2021
Messages
503
Likes
328
I understand that you need to dive into the documentation of the yml profile settings in more detail, make match sampling rate parameters of the capture and output devices
It's always good to read a user guide :)

You need to enable the rate adjust, so that CDSP controls the variable loopback rate to fit the fixed playback rate.

If you want to resample, just enable the rate adjust and configure sync rate resampler (sync because the rate adjust allows for fixed resampling ratio).
 

Davide

Senior Member
Joined
Jul 6, 2020
Messages
468
Likes
176
Location
Milan, Italy
CamillaDSP expects a constant capture sample rate and cannot accommodate rate changes without a restart. If you have a variable sample rate physical digital source like TOSLINK, AES or SPDIF or have multiple physical digital sources with different rates a good option is to add a device that has an ASRC to convert to a consistent rate. Some devices with this capability are summarized below.
I would like to suggest ASRC boards with AK4137 available on AliExpress, which allow you to standardize different sample rates from the source.
Asynchronous conversion is not optimal in this case and in fact is not exactly its purpose (for whose want to read 7 pages, here there is a Cirrus designer who explains in a fascinating way what it consists of).
However, I tried one board with the i2s to spdif interface added, and it works great.
It works smoothly up to 192khz and the quality of the ASRC is superb (I measured distortion and jitter and they are way below audible threshold).
Paired with my Wiim mini and Motu Ultralite mk5... perfect complement.
$70 total.

I attach an extract of the datasheet with the expected THD values for PCM to PCM conversion (from/to DSD is also supported).
Obviously the ASRC process is very sensitive to jitter and therefore clock and power quality are influential.
The board I linked has completely similar performance, although not equipped with SOTA components.

1000008671.png
 
Last edited:
OP
M

mdsimon2

Major Contributor
Forum Donor
Joined
Oct 20, 2020
Messages
2,515
Likes
3,371
Location
Detroit, MI
I would like to suggest ASRC boards with AK4137 available on AliExpress, which allow you to standardize different sample rates from the source.
Asynchronous conversion is not optimal in this case and in fact is not exactly its purpose (for whose want to read 7 pages, here there is a Cirrus designer who explains in a fascinating way what it consists of).
However, I tried one board with the i2s to spdif interface added, and it works great.
It works smoothly up to 192khz and the quality of the ASRC is superb (I measured distortion and jitter and they are way below audible threshold).
Paired with my Wiim mini and Motu Ultralite mk5... perfect complement.
$70 total.

I attach an extract of the datasheet with the expected THD values for PCM to PCM conversion (from/to DSD is also supported).
Obviously the ASRC process is very sensitive to jitter and therefore clock and power quality are influential.
The board I linked has completely similar performance, although not equipped with SOTA components.

View attachment 346655

Nice! I really think constant sample rate CamillaDSP setups are a great option.

I like having no rate adjust or resampling with the capture and playback devices on the same clock. This sort of setup seems the most predictable as you can get away with smaller chunk sizes and the buffer level stays constant. I've never had a buffer underrun or audible dropout with such a configuration my Ultralite Mk5 or Okto.

Michael
 

itsikhefez

Member
Joined
Mar 20, 2019
Messages
39
Likes
40
Location
Greater Seattle Area
This tutorial describes how to use an IR receiver and remote to change configurations. The CamillaDSP compact view is also a good way to easily change configurations from say your phone.

Just my 2 cents, but I wouldn't use CamillaDSP volume control without some sort of non computer volume indication. The display described in this tutorial is a nice way to get that volume indication and also has the advantage of being able to display your active configuration.

Another potential alternative to changing configurations is using the WaveInput LMS plugin with a separate ADC. You could digitize your analog sources with the ADC and send them via LMS to squeezelite with this plugin. You would never need to change CamillaDSP configurations and your capture device would always be an ALSA loopback.

Michael

Thanks for the suggestion. I've built something similar in the past for piCorePlayer with a VFD display in a small box, but for this I'll try to match the form factor and layout of the RME device, so the units look somewhat consistent.

I received the UCX-II a few weeks ago and now have configurations working for TOSLINK (TV usage) and loopback for Squeezelite.
Followed OCA tutorials for creating convolution filters and now doing some listening and comparison to their effects.

Overall I feel this is a really strong setup that I'd highly recommend, thanks again for the detailed tutorial.

BTW, a small improvement to the workflow is using VS Code with SSH Remote extension. It makes it a bit easier moving files around, editing and comparing.
 

Alex7777

Member
Joined
Feb 8, 2024
Messages
10
Likes
1
Hello everyone,

I have been reading this nice tutorial with much interest for days (big thanks to the author mdsimon2) so now plan to build the audio digital setup mentioned below.

This is my first project like that so your assistance, review is much appreciated.

Setup A) stereo music to 2 speakers + sub

1) Volumio (with FusionDSP/CamillaDSP) on Rpi4 -> USB out
2) USB in MOTU Ultralite mk5 - 7 channels TRS out --> 7 channels RCA in to amplifiers
3) 6 channels to two 3-way speakers and 1 channel to the subwoofer

At stage 1) and 2) above stereo signal will be processed with CDSP (highpass for ch 1&2 (L, R tweeters) and similarly x-overs for ch 2&3 (L, R midbass), ch 5&6 (L, R woofers) and ch 7 for the sub, filters applied and routed to 6+1 separate channels to feed the amps.

I want to exclude hardware x-overs in my speakers and in my active sub and to apply digital x-overs with CDSP separately for tweeters, midbass, woofers and the sub.
I will directly connect amps outs to tweeters, midbass and bass in speakers. With the sub I will probably do the same unless I find a better solution.


Setup B) TV sound to the same 2 speakers + sub

Additionally I want to connect my TV set to MOTU (Toslink / Toslink) and similarly to playback TV sound using the above setup (2 speakers + sub).
It seems in such setup I will not be able to use CDSP setting (x-overs, filters applied) that I used for music playback in A) as Rpi4 with CDSP excluded from the signal flow.
As an option for TV sound I understand that I can create x-overs and filters for each 6+1 channel in MOTU Ultralite mk5 DSP interface, can I?
In this case I will just have to switch input from USD (music) to Toslink (TV set) in MOTU when I change from music to TV and back?

I have all the components for the above setups except for the multichannel DAC.
Actually my choice was between MiniDSP Flex Eight and MOTU Ultralite mk5 but I am more inclined to purchase the latter.
Before ordering MOTU Ultralite mk5 I would like to understand if it can fit nicely into such system and can do the tasks above.
Or maybe there are some hidden problems that I did not notice reading this forum and that I will have to face?

Thank you.
 
OP
M

mdsimon2

Major Contributor
Forum Donor
Joined
Oct 20, 2020
Messages
2,515
Likes
3,371
Location
Detroit, MI
Flex Eight will be a bit simpler than an Ultralite Mk5 + CamillaDSP setup, it also seems like you don’t need balanced outputs which would be one reason to go with the Ultralite. Unless you have a specific need that requires the Ultralite + CamillaDSP (long FIR filters, loudness volume control, more flexible processing, higher output voltage, etc) I would go with the Flex Eight. The Flex Eight gives you a nice screen with volume indication, IR volume control and an ASRC, you can get the same functionality out of the Ultralite but you will end up paying more for it.

The Ultralite itself does not have an enough DSP capability to implement x-overs, you will need some DSP software to get the job done.

I am not familiar with the Volumio CamillaDSP implementation but in general it seems like streamer implementations make dealing with external inputs more difficult.

What streaming services / capabilities are you looking for from Volumio?

That being said, in a vanilla CamillaDSP implementation as described in this tutorial, you can switch between streaming sources and a TOSLINK input. The biggest issue is you will need to switch the clock source of the Ultralite from internal to TOSLINK, you might be able to always use TOSLINK from the TV as the clock source but I wouldn’t count on it. Changing clock sources isn’t too difficult and can be done on via the front panel or on a computer / phone / tablet connected to the same network and running CueMix.

Michael
 

itsikhefez

Member
Joined
Mar 20, 2019
Messages
39
Likes
40
Location
Greater Seattle Area
I'm still ironing out the details of my RPI/CamillaDSP setup with the UCX-II, one thing here caught my eye
The biggest issue is you will need to switch the clock source of the Ultralite from internal to TOSLINK, you might be able to always use TOSLINK from the TV as the clock source but I wouldn’t count on it.
@mdsimon2 is this an Ultralite specific issue? I've been swapping between TOSLINK and squeezelite and had not had any issues. Perhaps the UCX-II has a clock source setting per input?

As an aside, I'm really liking this setup. My plan is to put the RPI in a box, with display and remote control similar to yours.
For software, my plan is to write a program that supports the following:
1) Input switching -- Streamer (loopback), TV (toslink), Cassette Deck (analog), Phono (analog)
2) Volume control
3) Display modes for streaming -- Album art, Artist/Title/Track length
4) Will try to use a simple TSOP38238 in GPIO instead of Flirc. This allows for using the USB-C as power supply (although its not a big issue anyway).

As a bonus, I'll add a Karaoke mode (for spouse and kids), which will be some combination of TV or streamer with the mic inputs and potentially some FX.

I started a Github repo, its pretty empty but will share it once I have something decent thats working.
 
OP
M

mdsimon2

Major Contributor
Forum Donor
Joined
Oct 20, 2020
Messages
2,515
Likes
3,371
Location
Detroit, MI
I am not sure about the UCX-II but my RME Fireface 800 has the ability to select a preferred clock source (SPDIF, ADAT, word clock) and if it can’t lock to that source it reverts to the internal clock. This is a really nice feature that the UL Mk5 definitely does not have.

Now that I have remote control of the UL Mk5 working via nginx I would like to see if I can figure out how to send commands to the UL Mk5 via python. If I could get that going I could make it so the clock source switches when I switch configurations. Although it would be more for others than myself, I definitely prefer to use a TOSLINK input from a commercial streamer and just run the RPi as a standalone CamillaDSP box.

Michael
 

Alex7777

Member
Joined
Feb 8, 2024
Messages
10
Likes
1
Flex Eight will be a bit simpler than an Ultralite Mk5 + CamillaDSP setup, it also seems like you don’t need balanced outputs which would be one reason to go with the Ultralite. Unless you have a specific need that requires the Ultralite + CamillaDSP (long FIR filters, loudness volume control, more flexible processing, higher output voltage, etc) I would go with the Flex Eight. The Flex Eight gives you a nice screen with volume indication, IR volume control and an ASRC, you can get the same functionality out of the Ultralite but you will end up paying more for it.
Thank you for your usual prompt and detailed reply.

Re MOTU's balanced output - for the time being I will use 2 of my available amps (with RCA inputs) to see in general how it works/sounds. I think eventually I will use balanced amps instead of the available ones.

Re ASRC - I did not find this feature in MOTU Ultralite mk5 manual. Does MOTU support it? I suppose it is quite convenient to allow the system to do sample rate conversion automatically.

The Ultralite itself does not have an enough DSP capability to implement x-overs, you will need some DSP software to get the job done.
For Volumio/CDSP Rpi4 setup (for music) I plan to use CamillaDSP (within FusionDSP module) to implement x-overs, filters. I understand it can be arranged using CDSP capabilities (filters etc..)? Am I correct here?

I am not familiar with the Volumio CamillaDSP implementation but in general it seems like streamer implementations make dealing with external inputs more difficult.
In case I face problems with Volumio / CamillaDSP functionality I think I will have to do change setup a bit, for example a separate full installation of Camilla DSP on a separate Rpi unit and will manage 2 Rpi units:
Unit 1: Media player + Unit 2: Full CamillaDSP.

Or maybe I will try LMS + Squeezelite + CamillaDSP. (Read abt it many positive opinions but not yet studied).
What streaming services / capabilities are you looking for from Volumio?
Mainly playing files like FLAC, DSD from network SSD storage.

That being said, in a vanilla CamillaDSP implementation as described in this tutorial, you can switch between streaming sources and a TOSLINK input. The biggest issue is you will need to switch the clock source of the Ultralite from internal to TOSLINK
1707481371189.png


Is this what you are talking about? As long as it can be switched in MOTU or a smartphone running CueMix this is fine to me.
Thanks again.
 

Wirrunna

Member
Joined
May 27, 2021
Messages
93
Likes
45
Location
South Coast, NSW, Australia
Since getting two RPi5 boards I have been running my "production" system that uses a Motu Ultralite Mk5 and my "test" system using a Motu M4. When only one instance of CamillaDSP (CDSP) is running the Squeezebox server recognises the player as do the PiCorePlayers (PCP). However, if both CDSP systems are running then only one player is recognised and both the server and PCP will get confused and sometimes will show music being played on the production system as being played on the test system. Occasionally after an Ubuntu update the individual players would be recognised but a reboot would revert to only one CDSP system being recognised.
A recent Pi update to eeprom to 2024-01-22 and a sudo apt update & sudo apt full-upgrade fixed the problem and now both squeezelite players are recognised.

Michael made some changes to the setup scripts in December that simplify the setup process, so I decided to redo the SD card. The first attempt using the Raspberry Pi Imager seemed very slow, 20 minutes to get 12%, so I cancelled and used SD Card Formatter to quick format the SD card and tried again. Instant success, the Imager went through very quickly, maybe 10 minutes for a 32GB card. Apart from the "sudo apt update" and upgrade, the rest of the setup was quick with the new scripts only requiring an occasional "username" change.


Recently I wanted to run one of my CamillaDSP on RPi 5 systems on a different wireless network at my son's house. Rather than rebuild the SD card I just changed the network SSID and associated password.
In post #5 of the Tutorial, Michael describes the adding of a USB WiFi dongle and includes instructions on how to update the network for a new dongle. It is only a slight deviation from those instructions to update the SSID and password :

1. Install wireless tools and display existing wireless network config.

Code:
sudo apt install wireless-tools
sudo iwconfig

2. Copy current network info so we can change it.

Code:
sudo cp /etc/netplan/50-cloud-init.yaml /etc/cloud/cloud.cfg.d/50-curtin-networking.cfg

3. Edit the network config replacing the network name (SSID) and password.

Code:
sudo nano /etc/cloud/cloud.cfg.d/50-curtin-networking.cfg

Example from my system.

Code:
network:
    version: 2
    wifis:
        renderer: networkd
        wlan0:
            access-points:
                 SSID name:
                    password: password
            dhcp4: true
            optional: true
It is essential that the colons ':' retain the correct spacing.

4. Update and reboot.

Code:
sudo cloud-init clean
sudo cloud-init init
sudo reboot

5. Confirm the change.
Code:
sudo iwconfig
 

Alex7777

Member
Joined
Feb 8, 2024
Messages
10
Likes
1
n terms of configuration for a new device here are a few tips.

1) Make sure the correct number of input / output channels are listed in devices and this matches channel count in mixer.
2) Make sure you are using the appropriate bit depth for your DAC (S16LE, S32LE, S24LE3, etc)
3) Play around with resampling, I usually start with resampling enabled but it may not be required.
4) It is important to understand how the channels for your device are labeled, in CamillaDSP nomenclature the 1st channel is 0.
5) I like to make a configuration first under a different name and then once I am satisfied I save that configuration to camilladsp.yml.
6) For audio interfaces with routing functionality you likely will need to setup some sort of routing outside of CamillaDSP.
7) You can make / save configurations in the GUI but if you are having issues with CamillaDSP not starting I would try disabling the camillladsp service and start camilladsp from the command line with -v on the end so that you can see why it is not working.

Michael
Hello, I have just received my Ultralite mk5, can't wait to get down to business:)

In this repect I have got a few things to make sure I have got this right:
My setup will be: VOlumio (files playing) with FusionDSP (including CDSP) on Rpi4 -> by USB to Motu Ultralite mk5 -> amps (unbalanced RCA inputs to start with) -> 3W Speakers/1 Sub

So my media player is on Rpi (Linux) but I need to install MOTU driver on my Windows PC where I can tune my Cuemix5 (only for this purpose. I am not going to play music from my PC).
As p. 6) above puts it (and as I remember seeing this in more detail on the forum elswehere, cannot find it now) I will simply assign MOTU's input/output channels in CueMix 5 and then I can close CueMix5 and forget about it.
All further DSP activity will be concentrated in CDSP. Then I connect my Rpi4 to MOTU (via USB), no drivers required in this case, and my MOTU will retain and use the routing (in/out) that I created via CUeMix5 above.

Is it correct or did I miss something?
Thank you
 
Top Bottom