Skip to content

Instantly share code, notes, and snippets.

@stephanb2
Last active June 12, 2022 18:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stephanb2/553606f7af5cfd3e7c080ecbd1355200 to your computer and use it in GitHub Desktop.
Save stephanb2/553606f7af5cfd3e7c080ecbd1355200 to your computer and use it in GitHub Desktop.
Raspberry Pi based Parametric Audio Equaliser

Description

The aim of this project is to build a headless parametric audio equaliser. This is a DIY version of what can be achieved with a MiniDSP type device.

Hardware:

  • a Raspberry Pi (starting from a Model B)
  • an external USB sound card

Build example with a Behringer UCA-202 audio interface Example build

Specifications:

  • Device accepts a line-in audio signal and outputs a line-out audio signal
  • Typically sits between a pre-amp and amplifier, or between a TV line-out and a mini speaker
  • Latency less than 40 ms (1 video frame at 25 fps) on Raspberry pi model B, 2 channels at 48kHz
  • Headless operation. Configured via text files (no graphic user interface).
  • Parametric EQ uses parameters from Room EQ Wizard acoustics software
  • Equaliser starts automatically after boot.

I am assuming that you are familiar with Linux and the Linux command-line.

Raspberry Pi OS install

  • Install RPI OS Lite 32 bits using the Debian/Ubuntu imager
  • Configure ssh, wifi, etc with the imager
  • Unmount and remount the card. Resize (expand) /root partition with gparted
  • ssh login will be ssh pi@raspberrypi.local

System-wide DSP with bmc0/dsp

bmc0/dsp provides dsp functions with low CPU requirements that can works with pulseaudio and alsa. I will be using alsa to fit the CPU capabilites of a Raspberry Pi model B.

Install bmc0/dsp

Follow the build instructions from System Wide DSP Guide

sudo apt-get install ladspa-sdk
git clone https://github.com/bmc0/dsp.git
cd dsp
./configure --disable-dsp --disable-fftw3 --disable-zita-convolver
make
sudo make install

ALSA Configuration

find the name of your external sound card with:

aplay -L

configure /etc/asound.conf. In this example the card is hw:CARD=CODEC.

pcm.dsp {
    type plug
    slave {
        format FLOAT
        rate unchanged
        channels 2
        pcm {
            type ladspa
            path "/usr/lib/ladspa"
            playback_plugins [{
                label "ladspa_dsp"
            }]
            slave.pcm {
                type plug
                slave {
                    pcm "hw:CARD=CODEC"
                    rate unchanged
                    channels unchanged
                }
            }
        }
    }
}

Then create the file /etc/ladspa_dsp/config for the equaliser settings.
This is an extreme example for test purposes:

effects_chain=highpass 300 1.0 highpass 300 1.0 lowpass 3500 1.0 lowpass 3500 1.0

Test effect on playback:

aplay -D dsp my_test_audio_file.wav

Test buffer overrun, latency, cpu load. Connect an audio signal to the inputs of the soundcard.

alsaloop -C hw:CARD=CODEC -P dsp -t 40000 --sync=1 -v

Run equaliser at startup

Add those instructions to your /etc/rc.local.

# play startup sound (optional)
aplay -D plughw:CARD=CODEC /home/pi/blip.wav

# run ladspa_dsp. Note: ladspa_dsp doesn't run from root
(sleep 18; su pi -c 'alsaloop -C hw:CARD=CODEC -P dsp -t 50000 --sync=1') &

Notes:

  • ladspa_dsp doesn't run from the root user
  • If pulseaudio is installed, uninstall or disable pulseaudio
  • The sleep delay is required on a Model B to start alsaloop after completion of the boot process.
  • If latency is not an issue, you can reduce the sleep value, you will get around 0.5 sec latency
@stephanb2
Copy link
Author

Image of build:
rpi_auido_eq_02

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment