mpd with the alsa equalizer plugin

Debian Linux Linux audio mpd Music Player Daemon

UPDATED March 2023 (see below)

Getting MPD to work with the ALSA Equaliser plugin

I found a few sites with ‘howtos’ for this, although none of them worked for me.

First thing to do is ensure your MPD installation is working properly, and playing music through your chosen device.

If you have any problems getting MPD to work, then go to the excellent La Cocina site where you’ll find a lot of useful help. (site now dead)

Some of the info is now replicated on Github here

Once you are sure everything is working correctly;

Install the equaliser plugin:

apt-get install libasound2-plugin-equal

Edit your mpd configuration file (on my Debian box it was in /etc/mpd.conf)

Add the following lines:

audio_output {
        type            "alsa"
        name            "ALSA EQ"
        device          "plug:plugequal"
#       format          "44100:16:2"    # optional
#       mixer_device    "default"    # optional
#       mixer_control   "PCM"        # optional
#       mixer_index     "0"        # optional
}

While you’re editing mpd.conf, check that mpd is running with the mpd user account:

user "mpd"

Save the mpd.conf file and move on to the next step.

Now edit / create the .asoundrc in the home directory of the MPD user (you should be running the daemon as non privileged user – mine runs as mpd).

On Debian, my mpd home directory is in /var/lib/mpd/ – yours may vary.

vi /var/lib/mpd/.asoundrc

Add the following lines:

pcm.!default {
  type plug
  slave.pcm plugequal;
}
ctl.!default {
  type hw card 0
}
ctl.equal {
  type equal;
}
pcm.plugequal {
  type equal;
  slave.pcm "plughw:2,0"; # NOTE this line MUST be your hardware device.
}
pcm.equal {
  type plug;
  slave.pcm plugequal;
}

Once you have completed the above steps, you can restart the MPD daemon or simply reboot your machine.

Before you can use the Equaliser, you need to run it as the MPD user, otherwise it won’t work.

I created a script to do this:

Create a script called runeq.sh and add the following lines:

*UPDATE* March 2023 – see new improved script for setting presets at the bottom of the page

#!/bin/bash
su -s /bin/sh -c "alsamixer -D equal" mpd

Save the file and make it executable.

chmod +x runeq.sh

To run this script simply type:

./runeq.sh

Note: All the “vi” editor commands above can be substituted with “nano” (or the editor of your choice).

Tested and working on Debian 8.8

*UPDATE* May 2021

I followed my own guide to install this on Void Linux and ran into a few issues.

Firstly I was getting

Failed to load plugin "caps.so": caps.so: cannot open shared object file: No such file or directory

caps.so is in /usr/lib/ladspa/ so…

This was solved by inserting the following into the /etc/sv/mpd/run startup script

LADSPA_PATH=/usr/lib/ladspa/
export LADSPA_PATH

The relevant section in mpd.conf on Void Linux looked like this:

audio_output {
        type            "alsa"
        name            "ALSA EQ"
        device          "plug:plugequal"
        mixer_type      "software"
#       format          "44100:16:2"    # optional
#       mixer_device    "default"    # optional
#       mixer_control   "PCM"        # optional
#       mixer_index     "0"        # optional
}

The .asoundrc file remained the same as the example above.

*UPDATE* March 2023 – see new script for setting presets below

The EQ can be changed via shell scripts.

Your mpd.conf can have multiple outputs to feed different DACs etc. This can be enable or disabled with the mpc command.

If you only have the single ‘audio_output’ device set in mpd.conf this is note required, as it will be the default output.

In the script below, I use the runuser command to set the EQ to specific settings, and it is assumed that MPD runs as user mpd (if you run yours as a different user then you will need to change this).

The format of the amixer command is: -D defines which card you wish to set (as defined in .asoundrc) -q (quiet mode) set (EQ number is 0 to 9, 31Hz to 16kHz) (31Hz…16kHz) (level is 0 min. 100 max.)

The script below disables all other outputs except ‘ALSA EQ’ (as defined in mpd.conf) and sets the EQ levels as explained above.

#!/bin/bash
#
mpc enable only 'ALSA EQ'
#
runuser -u mpd -- /usr/bin/amixer -D equal -q set '00. 31 Hz' 68
runuser -u mpd -- /usr/bin/amixer -D equal -q set '01. 63 Hz' 64
runuser -u mpd -- /usr/bin/amixer -D equal -q set '02. 125 Hz' 65
runuser -u mpd -- /usr/bin/amixer -D equal -q set '03. 250 Hz' 58
runuser -u mpd -- /usr/bin/amixer -D equal -q set '04. 500 Hz' 65
runuser -u mpd -- /usr/bin/amixer -D equal -q set '05. 1 kHz' 65
runuser -u mpd -- /usr/bin/amixer -D equal -q set '06. 2 kHz' 63
runuser -u mpd -- /usr/bin/amixer -D equal -q set '07. 4 kHz' 53
runuser -u mpd -- /usr/bin/amixer -D equal -q set '08. 8 kHz' 56
runuser -u mpd -- /usr/bin/amixer -D equal -q set '09. 16 kHz' 66
#
# eof
#

If you have more than one DAC connected, you can define the other DAC(s) in mpd.conf and have one playing a flat response and the other an equalised response. In the above script, you will need to change the line:

mpc enable only 'ALSA EQ'

to

mpc enable 'ALSA EQ'

and add the line:

mpc enable 'your other DAC name'

below.

This should enable an equalised output to one DAC and a flat output to the other (you do need two DACs to do this).

Enjoy your equaliser. 🙂