• 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!

Pi4 + CamillaDSP + Audio Interface (Motu M4) = Phenomal DSP streamer

armigo

Member
Forum Donor
Joined
Sep 18, 2020
Messages
28
Likes
28
Hello Everyone,
I am posting on this as people have been messaging me about how to use CamillaDSP with a Pi4 or any linux based system to turn the Motu M4 or any other audio interface into a very powerfull DSP. I use this for a 2.2 system with Genelec 8030s and two 8" DIY subwoofers.

This won't be a fully comprehensive guide but I just want to share my experience and maybe open a place where ideas on this can be exchanged. Also, I am no longer running this on a pi but everything should also apply to a Pi.

This is the setup I use to run Roon. I now use one device as server and streamer but it makes no difference for this whether you can a Roon server or only a Roon bridge.
  1. You need to install ubuntu server. For the pi you can use the Raspberry Pi Imager. I use ubuntu server as it comes with a newer kernel and in my experiance I could only get the Motu M4 to work well with kernel 5.11 onward. I think somebody contributed a patch for the Motu M4
  2. Get camilladsp form here and compile it as described
  3. create a loopback device to reroute CamillaDSP to
    • Code:
      sudo modprobe snd-aloop
  4. create a camilaDSP config file. Instructions can be found on the github page. A basic file for 2.2 system with a crossover at 85hz looks like this (of course you'd have to change the used device names):
    • Code:
      devices:
        samplerate: 192000
        chunksize: 4096
        enable_resampling: false
        capture:
          type: Alsa
          channels: 2
          device: "hw:CARD=Loopback,DEV=1"
          format: S24LE
        playback:
          type: Alsa
          channels: 4
          device: "hw:CARD=M4"
          format: S32LE
      mixers:
        to4chan:
          channels:
            in: 2
            out: 4
          mapping:
            - dest: 0
              sources:
                - channel: 0
                  gain: 0
                  inverted: false
            - dest: 1
              sources:
                - channel: 1
                  gain: 0
                  inverted: false
            - dest: 2
              sources:
                - channel: 0
                  gain: 0
                  inverted: false
            - dest: 3     
              sources:
                - channel: 1
                  gain: 0
                  inverted: false
      filters:
        highpass2k:
          type: Biquad
          parameters:
            type: Highpass
            freq: 85
            q: 0.707
        lowpass2k:
          type: Biquad
          parameters:
            type: Lowpass
            freq: 85
            q: 0.707
      pipeline:
        - type: Mixer
          name: to4chan
        - type: Filter
          channel: 0
          names:
            - highpass2k
        - type: Filter
          channel: 1
          names:
            - highpass2k
        - type: Filter     
          channel: 2
          names:
            - lowpass2k
        - type: Filter 
          channel: 3
          names:
            - lowpass2k
  5. Set up CamillaDSP as a system service by creating the following file
    • Code:
      sudo nano /lib/systemd/system/camilladsp.service
    • And Add the following while chaning the location for camilladsp and the config file
    • Code:
      After=syslog.target
      StartLimitIntervalSec=10
      StartLimitBurst=10
      
      [Service]
      Type=simple
      ExecStart=/home/armin/camilladsp/target/release/camilladsp /home/armin/camillad>
      Restart=always
      RestartSec=1
      StandardOutput=syslog
      StandardError=syslog
      SyslogIdentifier=camilladsp
      User=root
      Group=root
      CPUSchedulingPolicy=fifo
      CPUSchedulingPriority=10
      
      [Install]
      WantedBy=graphical.target
  6. Now if you use Roon like me you just need to install roon bridge or server and you're all set there should be too Loopback devices detected by Roon. You'll just have to try which one is the correct one for playback.
  7. For spotify you could use librespot and for Tidal connect this worked for me when I tested it

I love this system it basically is as powerfull as a MiniDSP SHD for a fraction of the price. Sure, it needs much more tinkering but that's halve the fun. Has anybody else tried somethign similar I'd be courious to hear experiences. Also, I still have one issue I cannot figure out camilladsp randomly roughly once an hour which is why I set it up as a service so it is restarted immediately than it only causes a very brief blip.
 

jensgk

Active Member
Forum Donor
Joined
Mar 21, 2020
Messages
256
Likes
564
Location
Denmark
CamillaDSP is so very usefull. I use the CamillaDSP, that is party of Moode audio player, to EQ my headphones and add crossfeed.
 
OP
armigo

armigo

Member
Forum Donor
Joined
Sep 18, 2020
Messages
28
Likes
28
Nice.

Just wanted to note that moOde has Camilldsp integrated into it now. Easy alternative ?

The problem is in my experiance it doesn't play nice with multi-channel device like the Motu M4 but if you just have a 2.0 system it probably is. I personally prefer working with the config file over the web interface.

Edit: Also this way I could have CamillaDSP run on the same device as my roon server. My goal was to have less boxes around
 

mdsimon2

Major Contributor
Forum Donor
Joined
Oct 20, 2020
Messages
2,478
Likes
3,315
Location
Detroit, MI
This is probably a dumb noob question but I see you set the sample rate to 192000 Hz but then have enable_resampling as "false", by setting the sample rate to 192000 Hz does Camilla resample everything to that rate or does it change sample rates depending on source material? I am new to software DSP but I assume you want the DSP running at constant sample rate or else you will need to define different filters for each sample rate?

Michael
 
OP
armigo

armigo

Member
Forum Donor
Joined
Sep 18, 2020
Messages
28
Likes
28
This is probably a dumb noob question but I see you set the sample rate to 192000 Hz but then have enable_resampling as "false", by setting the sample rate to 192000 Hz does Camilla resample everything to that rate or does it change sample rates depending on source material? I am new to software DSP but I assume you want the DSP running at constant sample rate or else you will need to define different filters for each sample rate?

Michael
If I understand correctly what is set under sample rate is the "working sample rate" so the sample rate at which processing is happening. I just have Roon upsample the signal to 192kHz so there is no conversion happening in camillaDSP. I set resampling to false as I want as little conversion as possible but in my case it probably makes no difference. To be honest I don't know how CamillaDSP handles different incoming sample rates so I thought its better to have Roon do the upsampling as I at least know how it does it.
 

Daverz

Major Contributor
Joined
Mar 17, 2019
Messages
1,294
Likes
1,451
Hello Everyone,
I am posting on this as people have been messaging me about how to use CamillaDSP with a Pi4 or any linux based system to turn the Motu M4 or any other audio interface into a very powerfull DSP.

Thanks for this write up.

General question for anyone: does the M4 expose a master volume control to alsa? It looks like the main volume only controls outputs 1 & 2.

I would like add a display for volume level to the Pi4 and an IR receiver for remote control of the volume.

Currently I'm using a nanoDIGI as crossover between my mains and sub. I'm using piCorePlayer on the Pi4. This gives me 3 ways to adjust volume:

- set the volume in iPeng, Material Skin or other control app. I hate having to fumble with my phone to do this (unlock, go to app, wait for it to connect to the Pi). Also the "squeezebox" volume level algorithm is funky (doesn't use even dB steps).
- use the IR receiver on the nanoDIGI and a generic remote. This works well, except that there is no way to know the last volume setting. I could add the miniDSP wi-fi interface, but then I'm back to using an app on my phone.
- use both remotes for my DACs two fisted (possible since they both use digital volume with 1/2 dB steps).
 
OP
armigo

armigo

Member
Forum Donor
Joined
Sep 18, 2020
Messages
28
Likes
28
Thanks for this write up.

General question for anyone: does the M4 expose a master volume control to alsa? It looks like the main volume only controls outputs 1 & 2.

I would like add a display for volume level to the Pi4 and an IR receiver for remote control of the volume.

Currently I'm using a nanoDIGI as crossover between my mains and sub. I'm using piCorePlayer on the Pi4. This gives me 3 ways to adjust volume:

- set the volume in iPeng, Material Skin or other control app. I hate having to fumble with my phone to do this (unlock, go to app, wait for it to connect to the Pi). Also the "squeezebox" volume level algorithm is funky (doesn't use even dB steps).
- use the IR receiver on the nanoDIGI and a generic remote. This works well, except that there is no way to know the last volume setting. I could add the miniDSP wi-fi interface, but then I'm back to using an app on my phone.
- use both remotes for my DACs two fisted (possible since they both use digital volume with 1/2 dB steps).

Its funny I was also using a nanodigi before. Unfortunately, it's like you said the volume control on the M4 only controls 1&2 and does not register with alsa which makes it useless for a 2.2 system. I currently use Roon's DSP audio which is from a technical perspective as good as it gets but I'm also thinking about how to implement a physical volume control. For roon there's a guy that makes a plug in to use a Microsoft surface dial as a volume control which is pretty cool.
 

Daverz

Major Contributor
Joined
Mar 17, 2019
Messages
1,294
Likes
1,451
Its funny I was also using a nanodigi before. Unfortunately, it's like you said the volume control on the M4 only controls 1&2 and does not register with alsa which makes it useless for a 2.2 system.

Aw, too bad. But it's still a really compelling idea to replace the 4 devices I'm currently using -- and all their power cables and wiring -- with a single $240 bus-powered device.

So that leaves software volume control as the only choice for master volume. An intriguing option is using the camillaDSP volume control.

"The Volume filter is intended to be used as a volume control. The inital volume and muting state can be set with the gain and mute command line parameters. The volume can then be changed via the websocket."

EDIT: And then there's this:

https://github.com/HEnquist/pycamilladsp

Resistance may be futile.
 

Daverz

Major Contributor
Joined
Mar 17, 2019
Messages
1,294
Likes
1,451
Just got my M4 today, and already have everything set up by following the instructions here:

https://github.com/HEnquist/camilladsp-config

I am having a problem with intermittent dropouts, though.

Here's my camilla config for a 2.1 system:

YAML:
---
devices:
  samplerate: 96000
  buffersize: 4096
  silence_threshold: -60
  silence_timeout: 3.0
  capture:
    type: Alsa
    channels: 2
    device: "hw:Loopback,DEV=1"
    format: S32LE
  playback:
    type: Alsa
    channels: 4
    device: "hw:CARD=M4"
    format: S32LE

filters:
  mainshighpass:
    type: BiquadCombo
    parameters:
      type: LinkwitzRileyHighpass
      freq: 80
      order: 4
  sublowpass:
    type: BiquadCombo
    parameters:
      type: LinkwitzRileyLowpass
      freq: 80
      order: 4
  mainsdelay:
    type: Delay
    parameters:
      delay: 8.59
      unit: ms
      subsample: false
 
mixers:
  to3:
    channels:
      in: 2
      out: 4
    mapping:
      - dest: 0
        sources:
          - channel: 0
            gain: 0
            inverted: false
      - dest: 1
        sources:
          - channel: 1
            gain: 0
            inverted: false
      - dest: 2
        sources:
          - channel: 0
            gain: 0
            inverted: false
          - channel: 1
            gain: 0
            inverted: false

pipeline:
  - type: Mixer
    name: to3
  - type: Filter
    channel: 0
    names:
      - mainshighpass
      - mainsdelay
  - type: Filter
    channel: 1
    names:
      - mainshighpass
      - mainsdelay
  - type: Filter
    channel: 2
    names:
      - sublowpass

And my squeezelite config, based on Archimago's setup:

http://archimago.blogspot.com/2017/12/howto-musings-playing-with-digital_23.html

Bash:
# Defaults for squeezelite initscript
# sourced by /etc/init.d/squeezelite
# installed at /etc/default/squeezelite by the maintainer scripts

# The name for the squeezelite player:
#SL_NAME="$(hostname -s)"
SL_NAME="pi4"

# ALSA output device:
#SL_SOUNDCARD="default:CARD=Set"
SL_SOUNDCARD="hw:Loopback,DEV=0"

# Squeezebox server (Logitech Media Server):
# Uncomment the next line if you want to point squeezelite at the IP address of
# your squeezebox server. This is usually unnecessary as the server is
# automatically discovered.
#SB_SERVER_IP="192.168.x.y"

# Additional options to pass to squeezelite:
# Please do not include -z to make squeezelite daemonise itself.
SB_EXTRA_ARGS="-a 120:4::1 -r 96000 -R vX::4:28:99:100:50"

That should resample everything to 96kHz. Seems to work OK, except for the dropouts.
 

mdsimon2

Major Contributor
Forum Donor
Joined
Oct 20, 2020
Messages
2,478
Likes
3,315
Location
Detroit, MI
You might try adding enable_rate_adjust: true. In reading through the DIYaudio thread (post 1091) Henrik suggested this would help prevent buffer under runs. I've been running through squeezelite with CamillaDSP (although not a MOTU M4) and haven't had any drop outs.

Michael
 

Daverz

Major Contributor
Joined
Mar 17, 2019
Messages
1,294
Likes
1,451
You might try adding enable_rate_adjust: true. In reading through the DIYaudio thread (post 1091) Henrik suggested this would help prevent buffer under runs. I've been running through squeezelite with CamillaDSP (although not a MOTU M4) and haven't had any drop outs.

Michael

Thanks, if it happens again, I'll try that one.

I think the dropouts were caused by the optional

silence_threshold: -60
silence_timeout: 3.0

lines and the fact that I'm using squeezelite software volume (before camilladsp). I removed those lines and so far so good. I suppose I could play around with the threshold.
 

phofman

Senior Member
Joined
Apr 13, 2021
Messages
489
Likes
319
M4 is clocked by its internal HW crystal. The software loopback device is clocked by Linux high-resolution timer, controlled by internal CPU clock. Two clocks will always deviate a bit, resulting in buffer under/overruns. But the alsa loopback device offers a control element for fine-tuning its software-based clock. With enable_rate_adjust = true CamillaDSP monitors the actual playback rate (HW-based) relative to the software clock and tweaks the loopback control element regularly to adjust the capture rate appropriately. If the capture clock is not tunable (e.g. another physical soundcard with HW clock), the parameter enable_resampling (+ appropriate resampler_type) adaptively resamples in software between the exact capture samplerate and exact playback samplerate.
 

mdsimon2

Major Contributor
Forum Donor
Joined
Oct 20, 2020
Messages
2,478
Likes
3,315
Location
Detroit, MI
@phofman thank you for the explanation of enable_rate_adjust, I am still having a bit of trouble wrapping my head around what it is exactly doing but I think that is probably mostly my own misunderstanding of how Camilla works.

For example let's say my Camilla sample rate is 96 kHz and I play a 44.1 kHz song, doesn't there always need to be some sort of resampling to get it to the Camilla sample rate of 96 kHz?

Michael
 

phofman

Senior Member
Joined
Apr 13, 2021
Messages
489
Likes
319
What are your capture and playback devices in this setup?
 

mdsimon2

Major Contributor
Forum Donor
Joined
Oct 20, 2020
Messages
2,478
Likes
3,315
Location
Detroit, MI
Capture device is an ALSA loopback and playback is a USB DAC (currently using a DIYINHK 8 channel XMOS, but have also used a MOTU M4). My specific example:

devices:
samplerate: 96000
chunksize: 2048
enable_rate_adjust: true
capture:
type: Alsa
channels: 2
device: "hw:Loopback,0,1"
format: S32LE
playback:
type: Alsa
channels: 8
device: "hw: D20"
format: S32LE

Michael
 

mdsimon2

Major Contributor
Forum Donor
Joined
Oct 20, 2020
Messages
2,478
Likes
3,315
Location
Detroit, MI
No problems with clicks, I am just trying to understand how Camilla / ALSA work becomes something does not add up to me. This is my first time playing with software DSP.

In a more conventional hardware DSP like a miniDSP I understand the concept of using a ASRC to convert to the DSP sample rate, performing filtering in the digital domain at that sample rate and then outputting the processed signal at that sample rate. So if I send 44.1 kHz I know it will be ASRC'd to 96 kHz, similarly if I send 192 kHz I know it will be ASRC'd to 96 kHz. In all cases all processing will be done at 96 kHz and the output will be at 96 kHz.

With CamillaDSP / ALSA I do not understand how I can have an input file at 44.1 kHz, set a 96 kHz processing rate in the CamillaDSP and have no resampling. Seems to me that that there must be a sample rate conversion somewhere but all the documentation states you can use enable_rate_adjust without enable_resampling (and this works in my experience!) but I have not idea how this is possible. Just want to understand what I am missing here.

Michael
 

DavidL

Member
Joined
Nov 28, 2019
Messages
9
Likes
19
I have a similar 2.2 setup running camilldsp on an old Mac Mini into an Audient EVO8. The EVO8 has separate volume controls for 1&2 and 3&4, so you can use it as a loudness control for boosting or attenuating your subs. Passed on the Motu M4 because I wanted hardware volume control. Essentially, I have a poor man’s MiniDSP SHD, but without Dirac. This is fine for me because Dirac autocalibration didn’t work well in my room, which is small and has lots of windows. And I can use FIR filters with many, many taps (Multi Sub Optimizer + Rephase = :)).

Unfortunately the EV08 doesn’t play well with Linux, so I could never get it to work with a Raspberry Pi.

I hope that Amir tests an EVO8 (or EVO4) someday, although I am pretty sure that it will test worse than the M4.
 

phofman

Senior Member
Joined
Apr 13, 2021
Messages
489
Likes
319
BTW the M4 volume control is digital (in the ES9016S DAC), the same result as controlling the volume in the PC before the USB interface.
 
Top Bottom