Using Camilladsp with moOde 7

Camilladsp is audio processor with both FIR and IIR filters, written by Henrik Enquist. Despite Camilladsp is not, yet, integrated in to moOde, it supplies Camilladsp version 0.4.0 to experiment with. This article shows you how.

To integrate MPD with Camilladsp @scripple created an alsa plugin based bluealsa called alsa_cdsp. This module alsa handle switching the audio format for Camilladsp. Also this module is already included in moOde 7.

Also default configuration files are supplied :

  • /usr/share/camilladsp/config.out.yaml (default camilladsp config used by alsa_cdsp for camilladsp)
  • /usr/share/camilladsp/config.yaml
  • /etc/alsa/conf.d/camilladsp.conf (for the alsa_cdsp module)

Before you continue make sure moOde functions correct and can playback audio of the correct audio device. Required is that you are familiar with the SSH terminal and editing configuration files on the moOde file system.

What do you need to your self to make it work

  1. Assign the correct output device to camilladsp.
  2. Make the alsa_cdsp as output available with moOde/MPD.
  3. Edit the camilladsp to contain you own filter pipeline.

Set output device to camilladsp

We assume that you want to apply camilladsp to the same output device as used for moOde, but these can of course also be completely different devices and even several devices.

Normally if you select an output device moOde will update the configuration alsa files. For camilladsp we have to do it our selfs.

First find the current used device:

pi@moode:~ $cat /etc/alsa/conf.d/alsaequal.conf | grep plughw
slave.pcm "plughw:2,0";

Is this case it concerns the device hw:2,0, notice not plughw.

Next is to used the same device as playback device in camilladsp.
Open the /usr/share/camilladsp/config.out.yaml (in case alsa_cdsp is in the mode config_cdsp 1, else use the config.yaml variant), in your favorite editor .

Replace the playback device by correct one, just like in this example hw:2,0.

devices:
  samplerate: 44100
  chunksize: 1024
  queuelimit: 1
  capture:
    type: File
    channels: 2
    filename: "/dev/stdin"
    format: S16LE
    extra_samples: 8192
  playback:
    type: Alsa
    channels: 2
    device: "hw:2,0"
    format: S32LE
~

Route the audio to the camilladsp

Because camilladsp isn’t integrated yet in moOde and we don’t want to edit the moOde code we have to hijack an existing MPD output.

You can see the available outputs with:

pi@moode:~ $ mpc outputs
Output 1 (ALSA default) is enabled
        allowed_formats=""
        dop="0"
Output 2 (ALSA crossfeed) is disabled
        allowed_formats=""
        dop="0"
Output 3 (ALSA parametric eq) is disabled
        allowed_formats=""
        dop="0"
Output 4 (ALSA graphic eq) is disabled
        allowed_formats=""
        dop="0"
Output 5 (ALSA polarity inversion) is disabled
        allowed_formats=""
        dop="0"
Output 6 (ALSA bluetooth) is disabled
        allowed_formats=""
        dop="0"
Output 7 (HTTP stream) is disabled
 

Lets reuse the ALSA graphic output for camilladsp.

That output is defined in the /etc/mpd.conf:

audio_output {
type "alsa"
name "ALSA graphic eq"
device "alsaequal"
mixer_type "software"
dop "no"
}

We need to change the device form “alsaequal” to “camilladsp”. Only editing the file directly isn’t a great idea, because the file is is generated by moOde.

Luckily moOde provide a way where custom mpd configurations can be merged with the moode mpd configuration.

First create a custom mpd configuration file called /etc/mpd.custom.conf. Put the following content in it:

audio_output {
name "ALSA graphic eq"
device "camilladsp"
} 

This will make sure the device name of the audio output with the name “ALSA graphic eq: is replaced.

If the moOde 7.0.0 image the alsa_cdsp module is in the wrong place (my bad) !!!
You have to correct that by running the following command:

sudo install -m 644 `pkg-config --variable=libdir alsa`/libasound_module_pcm_cdsp.so `pkg-config --variable=libdir alsa`/alsa-lib/

Next enable the mpd custom configuration support by running the following command and restart moOde:

moodeutl -A add 32768
moodeutl -r

Final step to activate the output is in the moOde configuration interface. Go to the audio configuration page select a Graphic EQ curve and press SET:

You check this with:

pi@moodep4:~ $ mpc outputs
Output 1 (ALSA default) is disabled
        allowed_formats=""
        dop="0"
Output 2 (ALSA crossfeed) is disabled
        allowed_formats=""
        dop="0"
Output 3 (ALSA parametric eq) is disabled
        allowed_formats=""
        dop="0"
Output 4 (ALSA graphic eq) is enabled
        allowed_formats=""
        dop="0"
Output 5 (ALSA polarity inversion) is disabled
        allowed_formats=""
        dop="0"
Output 6 (ALSA bluetooth) is disabled
        allowed_formats=""
        dop="0"
Output 7 (HTTP stream) is disabled

If everything went well output 4 is active.

Editing the camilladsp configuration

Maybe one day if moOde fully integrate camilladsp including the camilladsp web gui, you will have a fancy configuration editor, but for now you have to do it your self.

Open the /usr/share/camilladsp/config.out.yaml (in case alsa_cdsp is in the mode config_cdsp 1, else use the config.yaml variant), in your favorite editor . And edit it to your wishes, see the camilladsp documentation for more.

After configuration restart moOde with moodeutl -r. Alternative stop your audio stream with the command mpc stop and enable it again mpc play.

If you prefer to upload a configuration file instead , please don’t forget to set the correct output device.

4 Replies to “Using Camilladsp with moOde 7”

  1. Something off or I did it wrong. All screens look as above, but I get “failed to open ALSA graphic eq, failed to find device camilladsp.

    BTW do the filter files have the correct phase variation like a circuit would?

    1. It looks like the alsa_cdsp module is in the wrong place.
      You can correct it by running the following comand from the terminal:
      sudo install -m 644 `pkg-config --variable=libdir alsa`/libasound_module_pcm_cdsp.so `pkg-config --variable=libdir alsa`/alsa-lib/

Leave a Reply

Your email address will not be published.