Enabling Equalizer on Raspberry Pi using ALSA equal Plugin


This post shows how to setup a system wide equalizer on Raspberry Pi using ALSA equal plugin. Below are my setup.

  • Raspberry Pi3 B+ with Raspbian Stretch (2018 April version)
  • 3.5 mm plug Speaker

 

Contents
– Assumptions
– Steps
1. Equalizer Plugin Installation
2. ALSA Configuration
3. Play audio
4. Verify Equalizer
– Notes
– Reference

 

Steps
1. Equalizer Plugin Installation

sudo apt-get install libasound2-plugin-equal -y

 

2. ALSA Configuration
2-1. Create .asoundrc.

nano ~/.asoundrc

2-2. Add the lines below, save and close the file.

pcm.!default {
 type plug
 slave.pcm plugequal;
}
 
ctl.equal {
 type equal
}
 
pcm.plugequal {
 type equal
 slave.pcm "plughw:ALSA,0"
}
 
pcm.equal {
 type plug
 slave.pcm plugequal
}

2-3. Reload .asoundrc.

alsactl kill rescan

 

3. Play audio
Play a sample sound file in a loop for testing.

while [ 1 ];do aplay /usr/share/sounds/alsa/Front_Center.wav;done

Note: Press Ctrl+C to exit.

 

4. Verify Equalizer
Adjust the equalizer by using alsamixer command.

alsamixer -D equal

The sound from Raspberry Pi’s speaker should change as you change the equalizer values.

 

Notes
Since Raspbian Stretch, Bluetooth audio is handled by ALSA using bluez-alsa [2]. So if A2DP sink is enabled, this equalizer can be also applied on Bluetooth audio.

 

References
[1] Raspbian: the great Equalizer
[2] Raspbian Stretch has arrived – Raspberry Pi Official Blog

 

 

Sponsor Link

9 Comments

  1. I installed as described, but when I change equlizer values, the sound does not change at all.
    This is on a Raspberry Pi Zero with a low pass filter attched to convert PWM to audio as described at
    shallowsky.com/blog/hardware/pi-zero-audio.html

    1. Same here. It has no effect on the audio. I tested with multiple tones to confirm.

      1. Nice try, same result for me. But I have a (partial) solution: Please check /etc/pulse/default.pa; you should find an entry like
        load-module module-alsa-sink device=default
        (or at least …=plugequal)
        otherwise the pulseaudio output will not make it to the default ALSA sink (resp. plugqual) and thus, not to the equalizer.
        I did so but unfortunately, then I had NO sound at all! For some reason my ALSA equalizer does not give any output. Simply bypassing plugequal restores the sound so the overall path should be fine. Any ideas?

  2. PUT THIS IN CONSLE FOR THIS TO WORK
    while [ 1 ];do airplay /home/pi/Music/xxxxxx.wav;done
    NOTE REPLACE THE xxxxxx.wav WITH THE NAME OF THE WAV FILE THEN HIT ENTER

    1. Please note that the wav file needs to be put in your music file in /home/pi/Music
      For this to work properly

  3. doesn’t work.

    pi@raspberrypi:~ $ while [ 1 ];do aplay /usr/share/sounds/alsa/Front_Center.wav;done
    ALSA lib pcm_hw.c:1822:(_snd_pcm_hw_open) Invalid value for card
    aplay: main:828: Fehler beim Öffnen des Gerätes: Kein passendes Gerät gefunden
    ALSA lib pcm_hw.c:1822:(_snd_pcm_hw_open) Invalid value for card
    aplay: main:828: Fehler beim Öffnen des Gerätes: Kein passendes Gerät gefunden
    ALSA lib pcm_hw.c:1822:(_snd_pcm_hw_open) Invalid value for card
    aplay: main:828: Fehler beim Öffnen des Gerätes: Kein passendes Gerät gefunden
    ALSA lib pcm_hw.c:1822:(_snd_pcm_hw_open) Invalid value for card
    aplay: main:828: Fehler beim Öffnen des Gerätes: Kein passendes Gerät gefunden
    ALSA lib pcm_hw.c:1822:(_snd_pcm_hw_open) Invalid value for card
    aplay: main:828: Fehler beim Öffnen des Gerätes: Kein passendes Gerät gefunden
    ALSA lib pcm_hw.c:1822:(_snd_pcm_hw_open) Invalid value for card
    aplay: main:828: Fehler beim Öffnen des Gerätes: Kein passendes Gerät gefunden
    ALSA lib pcm_hw.c:1822:(_snd_pcm_hw_open) Invalid value for card
    aplay: main:828: Fehler beim Öffnen des Gerätes: Kein passendes Gerät gefunden
    ALSA lib pcm_hw.c:1822:(_snd_pcm_hw_open) Invalid value for card
    aplay: main:828: Fehler beim Öffnen des Gerätes: Kein passendes Gerät gefunden

  4. problems step 3
    im ok playing the audio but how when i press control and c the music stops?

    how do i play music and get the equaliser to run?

Comments are closed.