Skip to content

System Wide DSP Guide

Michael Barbour edited this page Jan 13, 2015 · 17 revisions

This is a guide to using dsp as a LADSPA plugin to do system-wide audio processing on Linux.

Install Packages

First, make sure you have git, the base development tools, and dsp's required dependencies installed. For Debian and derivatives, you'll need build-essential, pkg-config, git, libsndfile-dev, and ladspa-sdk. For Arch Linux, you need the base-devel metapackage, git, libsndfile, and ladspa.

If you want to build all the optional effects and codecs have a look at the Optional Dependencies. If your system splits development packages (like Debian does), make sure you install the -dev (or equivalent) packages.

Get the Code

Clone the dsp repository:

$ git clone https://github.com/bmc0/dsp.git
$ cd dsp

Build

If you only want the bare-bones LADSPA plugin, run configure manually to disable the FIR effect:

$ ./configure --disable-fftw3

Then build and install only the LADSPA plugin:

$ make ladspa_dsp
$ sudo make install_ladspa_dsp

If you want the CLI program and all the optional effects (assuming you have their dependencies installed), build and install the standard way:

$ make
$ sudo make install

Create the Configuration File

The LADSPA plugin reads $XDG_CONFIG_HOME/ladspa_dsp/config ($XDG_CONFIG_HOME defaults to ~/.config, so the path is usually ~/.config/ladspa_dsp/config). The README has a short description of the config format. For use as a basic equalizer, you only need to specify the effects chain:

effects_chain=gain -3.0 lowshelf 90 0.9s +3.0

This will apply a simple bass boost. See the README for more information about each effect.

If you want individual control over each channel, you need to set the number of input and output channels. For example, to implement a two-way LR2 crossover at 1.8kHz plus a mono LFE channel crossed at 80Hz (LR4) with a 6-channel soundcard:

input_channels=2
output_channels=6
effects_chain=remix 0 1 0 1 0,1 . :0,1 mult -1 highpass 1.8k 0.5 :2,3 lowpass 1.8k 0.5 highpass 80 0.7071 highpass 80 0.7071 :4 mult 0.5 lowpass 80 0.7071 lowpass 80 0.7071 :

Generate the Effects Chain from a Room EQ Wizard Filter Settings File

The script scripts/rew_to_dsp.sh can generate an effects chain from a Room EQ Wizard filter settings file. It currently supports the following filter types: PK, LP, HP, LPQ, HPQ, NO, LS, HS, and AP. The Equalizer APO style Preamp: line is also supported.

Let's use the Micca MB42x correction file from http://noaudiophile.com as an example:

Filter Settings file

Dated: October 14th, 2013 03:23:23 AM

Notes: NoAudiophile.com Micca MB42x Correction

Preamp: -3.7 dB


Filter 1: ON  PK	Fc   13058 Hz  Gain  -3.7 dB  Q  1.0
Filter 2: ON  PK	Fc   12260 Hz  Gain  2.3 dB  Q  1.0
Filter 3: ON  PK	Fc   10880 Hz  Gain  -2.3 dB  Q  3.0
Filter 4: ON  PK	Fc   16500 Hz  Gain  -2.1 dB  Q  3.0
Filter 5: ON  PK	Fc   6580 Hz  Gain  -2.5 dB  Q  6.38
Filter 6: ON  PK	Fc   8210 Hz  Gain  -5.0 dB  Q  2.4
Filter 7: ON  PK	Fc   8144 Hz  Gain  5.0 dB  Q  6.0
Filter 8: ON  PK	Fc   5895 Hz  Gain  5.2 dB  Q  5.0
Filter 9: ON  PK	Fc   2990 Hz  Gain  2.0 dB  Q  1.0
Filter 10: ON  PK	Fc   2750 Hz  Gain  -4.2 dB  Q  2.0
Filter 11: ON  PK	Fc   1836 Hz  Gain   3.0 dB  Q  5.7
Filter 12: ON  PK	Fc   1700 Hz  Gain  -1.6 dB  Q  4.0
Filter 13: ON  PK	Fc   1304 Hz  Gain  -2.5 dB  Q  4.19
Filter 14: ON  PK	Fc   1281 Hz  Gain  -3.1 dB  Q  2.0

To generate the effects chain, run:

$ ./scripts/rew_to_dsp.sh ~/Micca_MB42x.txt
gain -3.7 eq 13058 1.0 -3.7 eq 12260 1.0 2.3 eq 10880 3.0 -2.3 eq 16500 3.0 -2.1 eq 6580 6.38 -2.5 eq 8210 2.4 -5.0 eq 8144 6.0 5.0 eq 5895 5.0 5.2 eq 2990 1.0 2.0 eq 2750 2.0 -4.2 eq 1836 5.7 3.0 eq 1700 4.0 -1.6 eq 1304 4.19 -2.5 eq 1281 2.0 -3.1

Now you can copy and paste the output into the configuration file:

effects_chain=gain -3.7 eq 13058 1.0 -3.7 eq 12260 1.0 2.3 eq 10880 3.0 -2.3 eq 16500 3.0 -2.1 eq 6580 6.38 -2.5 eq 8210 2.4 -5.0 eq 8144 6.0 5.0 eq 5895 5.0 5.2 eq 2990 1.0 2.0 eq 2750 2.0 -4.2 eq 1836 5.7 3.0 eq 1700 4.0 -1.6 eq 1304 4.19 -2.5 eq 1281 2.0 -3.1

Configure PulseAudio

Run this command to make PulseAudio load the LADSPA plugin:

$ pacmd load-module module-ladspa-sink sink_name=dsp master=<sinkname> plugin=ladspa_dsp label=ladspa_dsp

Replace <sinkname> with the preferred output device (example: alsa_output.pci-0000_00_1b.0.analog-stereo). You can find the device name with pacmd list-sinks. Now you can make the dsp sink the default. See this Ask Ubuntu post for more information about changing the default sink.

To make PulseAudio load the plugin every time and set dsp as the default sink, put this in ~/.config/pulse/defualt.pa:

.include /etc/pulse/default.pa

pacmd load-module module-ladspa-sink sink_name=dsp master=<sinkname> plugin=ladspa_dsp label=ladspa_dsp
set-default-sink dsp

Again, replace <sinkname> with the preferred output device.

Configure ALSA

If you don't use PulseAudio (I don't), you can configure ALSA to load the LADSPA plugin. Put this in ~/.asoundrc:

pcm.dsp {
	type plug
	slave {
		format FLOAT
		rate unchanged
		channels unchanged
		pcm {
			type ladspa
			playback_plugins [{
				label "ladspa_dsp"
			}]
			slave.pcm {
				type plug
				slave {
					pcm "<hw_device>"
					rate unchanged
					channels unchanged
				}
			}
		}
	}
}

Replace <hw_device> with the preferred output device. To set the dsp pcm as the default device, add this:

pcm.!default {
	type copy
	slave.pcm "dsp"
}

If you want to use multiple clients with the dsp pcm, you can use the dmix plugin instead of copy:

pcm.!default {
	type dmix
	ipc_key 321456
	ipc_key_add_uid true
	slave {
		pcm "dsp"
		format <format>
		channels 2
		rate 44100
	}
}

Notes

  • Currently, the configuration file is not reloaded when it is changed. In order to reload the configuration file, the plugin must be reinitialized. If you're using PulseAudio, you can accomplish this by either unloading and reloading the LADSPA module, or by restarting the server (pulseaudio -k). With ALSA, the pcm must be reset.
  • It would appear that when the input to a biquad filter is non-silence followed by silence, the required cpu time starts to climb when the silence starts. You can avoid this by using the noise effect to add extremely low-level (totally inaudible) noise to the signal before it gets to the filters (noise -200, for example).

Clone this wiki locally