The Raspberry Pi doesn’t come with a sound equalizer out of the box. Even if you install a custom media player/server like Mopidy, you won’t have an equalizer installed on your system by default. Arguably, not having an equalizer installed on the Raspberry Pi isn’t a big deal. After all, the Raspberry’s sound quality is middling, so an equalizer isn’t a huge help. In fact, any changes to the equalizer beyond some fine tuning is likely to introduce more sound issues than it resolves. Having said that, if you’re using the Pi for your home audio and need a small tweak or if you have installed a DAC to improve your device’s sound quality, the equalizer might be exactly what you need.
Installing The Equalizer
The Raspberry Pi uses the standard Linux sound framework called ALSA. To add an equalizer, we’ll use a library designed to work specifically with ALSA called — simply enough — ALSAequal. The library can be installed as follows:
sudo apt-get install -y libasound2-plugin-equal
Once this command is finished, you will have the equalizer installed. That was pretty painless, right? Well, we’re not quite done yet.
While we have installed the equalizer, we now need to configure ALSA to recognize and use the new equalizer. We’ll do that by making some relatively simple changes to the ALSA configuration file. First, however, we’re going to need to know the card and device ID that the Pi is using for your sound output. In order to determine this, you’ll want to run the following command which will list all of your sound output devices:
From these results, you’ll be able determine the card and device ID of your sound output. For example, in the above image, the standard headphone jack is card 0, device 0 and the HDMI sound output is card 0, device 1. If you have installed an optional DAC or a USB sound card, it will likely appear here as “card 1” or “card 2.” Once you have this number, we can go ahead and either create or modify the ALSA configuration file. If this file doesn’t exist, you can create it in the correct location with the following command:
sudo nano -c /etc/asound.conf
If you’re only reading this guide in order to add an equalizer to the Raspberry Pi, then you’re done at this point. You can access the equalizer by typing alsamixer -D equal into the command line. The above steps, however, will unfortunately not apply the equalizer to Mopidy. For that, you’ll need to take a few more steps.
Getting Alsamixer to work with Mopidy
We now need to let Mopidy know that the equalizer exists and that the sound should be piped through the equalizer and not straight to ALSA. To do that, we’re going to complete a few more steps.
First, we’re going to install the mopidy plugin “mopidy-alsamixer.” This will allow ALSA to handle the mixing for mopidy instead of the software mixer that Mopidy uses (but obviously doesn’t expose the equalizer, otherwise we wouldn’t be going through this). The plugin has a dependency of python-alsaaudio that will also need to be installed if you don’t have it already:
sudo apt-get install python-alsaaudio
sudo pip2 install Mopidy-ALSAMixer
Now that we have that plugin out of the way, we will need to make a few changes to our Mopidy configuration file to send audio output to the new equalizer. As noted elsewhere, the mopidy configuration file will be found at /etc/mopidy/mopidy.conf. Once the file is opened, we can supplement the configuration file with the following changes. To the extent that any of these settings already exist, you will need to delete the existing entries.
# The "Audio" section should already exist in your configuration. The two settings below can simply be added to the end of that section.
mixer = alsamixer
output = alsasink device=plug:plugequal
# This section is likely to be new and can safely be added to the end of your
# configuration file
enabled = true
card = 0
control = Digital
With these changes made, you can safely restart Mopidy. Once it has restarted, you should have a functional equalizer working not only in Raspbian but directly in Mopidy, too. However, if you type in the equalizer command from earlier, it won’t work – you will actually need to use a different command that changes only the equalizer used by Mopidy. In order to view the Mopidy equalizer, you can type sudo -H -u mopidy alsamixer -D equal into the command and change the individual levels as desired. The equalizer works instantly, so you can start a song of your choice and begin tinkering with the levels to find the optimum settings for your system.
As I noted earlier, this equalizer will let you fine tune the sound output from the Raspberry Pi. However, if you play with the equalizer for long, you’ll realize that if you move the settings too far from the defaults that the Pi starts to heavily distort the sound output – at least if you don’t have a DAC installed. As a result, you’ll want to have a light hand with any changes that you make here.