Mpd with the alsa equalizer plugin
Posted by on 2017-09-13 15:55:29:
UPDATED March 2023 (see below)
Getting MPD and Squeezelite to work with the ALSA Equaliser plugin - these instructions should work on any Linux distro including the RaspBerry Pi.
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.
Some of the info from the above site 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).
NOTE: I found that Squeezelite looked for
/etc/asound.conf
so if using Squeezelite I suggest using /etc/asound.conf
instead.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 { controls "/path/to/alsaequal.bin" type equal; } pcm.plugequal { type equal; slave.pcm "plughw:2,0"; # NOTE this line MUST be your hardware device. } pcm.equal { controls "/path/to/alsaequal.bin" type plug; slave.pcm plugequal; }
The EQ settings are stored in alsaequal.bin - I recommend using the users' home directory.
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 scriptLADSPA_PATH=/usr/lib/ladspa/ export LADSPA_PATH
Update August 2024
I ran into issues with the above method using Squeezeplayer, so I created a symbolic link to
/usr/lib/ladspa/caps.so
in /usr/libln -sr /usr/lib/ladspa/caps.so /usr/lib/
MPD
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 or /etc/asound.conf 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 not 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
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).
Squeezelite
To use the equaliser with Squeezelite, you need to pass the device name using
plug:equal
as per below./usr/local/bin/squeezelite -s [server]:3483 -o plug:equal -a 80:4:: -d log=info -f /var/log/squeezelite.log -m '74:d4:35:4a:70:30' -M SqueezeLite -n SqueezePlayer
Note: the -s [server] is optional, as is the -f for logging - however I find it useful to have logging enabled until I'm satisfied it's all working correctly.
Enjoy your equaliser. :-)
Tags: Audio , Linux , Alsa , alsaequal , equaliser , equalizer , squeezeplay , squeezelite
Return to home page: Home