MusicLounge: Alsa EQ Plugin


# ALSA EQ (alsaeq plugin)
# add a real-time adjustable equalizer plugin for ALSA sound server to your audiophile server

# install plugin

  1. $ sudo apt-get install libasound2-plugin-equal


# edit the .asoundrc (or create one if doesnt exist)

# mpd home

  1. $ sudo nano /var/lib/mpd/.asoundrc


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

# CTRL+O to save
# CTRL+X to exit

# reboot

  1. $ sudo reboot



# command for using the mixer through MPD user:

  1. $ sudo -H -u mpd alsamixer -D equal

# user this command to EQ your audio system (if needed) and then
# write down the values of the 10 bands to create the corresponding EQ script
# then edit your remote control configuration to assign a key (see below for sample scripts)


# Sample script to drive the ALSA EQ

# 66 == zero change

# script to change preset:

seteq(){
sudo -H -u mpd amixer -D equal -q set '00. 31 Hz' $1
sudo -H -u mpd amixer -D equal -q set '01. 63 Hz' $2
sudo -H -u mpd amixer -D equal -q set '02. 125 Hz' $3
sudo -H -u mpd amixer -D equal -q set '03. 250 Hz' $4
sudo -H -u mpd amixer -D equal -q set '04. 500 Hz' $5
sudo -H -u mpd amixer -D equal -q set '05. 1 kHz' $6
sudo -H -u mpd amixer -D equal -q set '06. 2 kHz' $7
sudo -H -u mpd amixer -D equal -q set '07. 4 kHz' $8
sudo -H -u mpd amixer -D equal -q set '08. 8 kHz' $9
sudo -H -u mpd amixer -D equal -q set '09. 16 kHz' ${10}
}

# usage:

  1. $ seteq 29 39 58 58 60 66 66 66 66 66

# see the IR remote control tutorials to trigger script by pressing a button of your remote control

# by default in the installation of triggerhappy or Lirc we assigned key 6 and 9 of the remote control to trigger ALSA EQ script lowbass.sh and jbleq.sh and key 0 (zero) to reset to dafault audio output (EQ is not used in the default)

# if you followed the installation the scripts/ directory is already created

# we are going to create a simple script to drive the ALSA EQ
# the script start to select the “ALSA EQ” audio output of MPD
# then it sets each band of the EQ

  1. $ sudo nano ~/scripts/lowbass.sh
#!/bin/bash
mpc enable only 'ALSA EQ'
sudo -u mpd /usr/bin/amixer -D equal -q set '00. 31 Hz' 39
sudo -u mpd /usr/bin/amixer -D equal -q set '01. 63 Hz' 39
sudo -u mpd /usr/bin/amixer -D equal -q set '02. 125 Hz' 58
sudo -u mpd /usr/bin/amixer -D equal -q set '03. 250 Hz' 58
sudo -u mpd /usr/bin/amixer -D equal -q set '04. 500 Hz' 60
sudo -u mpd /usr/bin/amixer -D equal -q set '05. 1 kHz' 66
sudo -u mpd /usr/bin/amixer -D equal -q set '06. 2 kHz' 66
sudo -u mpd /usr/bin/amixer -D equal -q set '07. 4 kHz' 66
sudo -u mpd /usr/bin/amixer -D equal -q set '08. 8 kHz' 66
sudo -u mpd /usr/bin/amixer -D equal -q set '09. 16 kHz' 66
mpc play

# set exec permission

  1. $ sudo chmod +x ~/scripts/lowbass.sh

# reshaping JBL speakers example

  1. $ sudo nano ~/scripts/jbleq.sh
#!/bin/bash
mpc enable only 'ALSA EQ'
sudo -u mpd /usr/bin/amixer -D equal -q set '00. 31 Hz' 66
sudo -u mpd /usr/bin/amixer -D equal -q set '01. 63 Hz' 66
sudo -u mpd /usr/bin/amixer -D equal -q set '02. 125 Hz' 66
sudo -u mpd /usr/bin/amixer -D equal -q set '03. 250 Hz' 60
sudo -u mpd /usr/bin/amixer -D equal -q set '04. 500 Hz' 60
sudo -u mpd /usr/bin/amixer -D equal -q set '05. 1 kHz' 62
sudo -u mpd /usr/bin/amixer -D equal -q set '06. 2 kHz' 66
sudo -u mpd /usr/bin/amixer -D equal -q set '07. 4 kHz' 70
sudo -u mpd /usr/bin/amixer -D equal -q set '08. 8 kHz' 71
sudo -u mpd /usr/bin/amixer -D equal -q set '09. 16 kHz' 66
mpc play

# set exec permission

  1. $ sudo chmod +x ~/scripts/jbleq.sh

# set owner of scripts directory to current user (pi)

  1. $ sudo chown $USER:$USER  ~/scripts/*

# Congrats! Now you can shape your sound with EQ plugin (obviously not suitable for native DSD playback)
# see the next tutorial to install remote control and select on-fly your EQ setup by pressing key 6 or 9 of the remote control,
# key 0 (zero) reset to default audio output (no EQ)