How to add a low-pass filter to a system-wide PulseAudio profile?

I would like to know how to add a low-pass sound filter to the system-wide PulseAudio profile in order to allow only frequencies under 18000Hz to my speakers.


Solution 1:

PulseAudio Profiles

The system-wide default PulseAudio profile is configured in /etc/pulse/default.pa and overridden by per-user profiles in ~/.pulse/default.pa if the latter exists. PulseAudio profiles consist of a series of commands issued to the PulseAudio daemon.

  • To apply a new configuration one needs to restart the PulseAudio daemon:

    pulseaudio --kill
    pulseaudio --start
    

    If the daemon doesn't start after a configuration change you can run PulseAudio un-daemonized if you leave out the --start option and you can elicit debugging information with --log-level or one or more -v options, e. g.:

    pulseaudio --kill
    pulseaudio --log-level=info
    
  • Instead of restarting the PulseAudio daemon you can also change its configuration and (un-)load modules through direct commands via pactl or pacmd. This is often easier than restarting the daemon all the time for minor changes.

Module Loading

To add a module use the load-module command. You can find a PulseAudio-compatible low-pass filter in Ubuntu's package repositories in the form of the LADSPA plug-in lowpass_iir_1891 in the package swh-plugins and available to PulseAudio through the module-ladspa-sink module. The full command looks like this:

load-module module-ladspa-sink plugin=lowpass_iir_1891 label=lowpass_iir master=<MASTER_SINK> sink_name=<NAME> [control=<FILTER_PARAMETERS>] [channel_map=<CHANNEL_MAP>] [channels=<CHANNEL_COUNT>]

where <MASTER_SINK> is the name of the down-stream "sink" that receives the audio data from the filter1 and <NAME> is the name of the sink that the filter module represents. <FILTER_PARAMETERS> is used for things like the cut-off frequency and steepness. For the other parameters and more details see the PulseAudio Wiki entry on modules.

Setting a Default Sink

Now if you want all applications to use the filter sink by default you need to inform PulseAudio like this:

set-default-sink <NAME>

where <NAME> is the same as in the previous section.

PulseAudio stores the last sink of each application using it and may use that in favour of the new default. To reset those remove ~/.pulse/*-stream-volumes.tdb. You can also configure the per-stream sink with tools like pavucontrol (GUI) or pactl move-sink-input (command-line).


1 You can list all sinks with pactl list short sinks. Your actual audio device sink name will usually consist of alsa_output, the device path and the channel profile name, e. g. (on my system) alsa_output.pci-0000_00_1b.0.analog-stereo.