An ALSA plugin to apply arbitrary convolution filters to PCM streams. Released under the GNU GPLv3+.
FFTW is used with the overlap-add method to convolve the two signals in reasonable CPU time.
- DRC (digital room correction: room EQ, house curves, etc.)
- Other types of FIR filters
This plugin does not require the use of an ALSA loopback device. This is great for many reasons:
-
No unnecessary latency (of which ALSA programs cannot know about, this is problematic for precise syncing of audio). Of course, because of the way convolution filters work, some latency is inevitable.
-
All sample rates are supported without the need for continous resampling (only the impulse response is resampled, once), which saves system resources during playback.
-
No idle use of system resources (the device is normally closed when no application is playing audio).
For DRC, you can generate impulses using software like DRC-FIR (libre) or REW (proprietary).
For more general-purpose filters, you can generate impulses with rePhase (proprietary) or ffmpeg's sinc source (among others):
# generate a 100 Hz highpass filter impulse at 44100 Hz sample rate
ffmpeg -f lavfi -i sinc=r=44100:hp=100 -f f32le highpass_impulse.float32.pcm
Finally, you can also reuse impulses available online, some of which can be found on zconvolver's homepage.
-
No control mixer for toggling the filter on/off for now, patches welcome
-
16 channels maximum (can easily be increased in the code)
-
Only works with
FLOAT32
samples of native endianness, you will most likely need to useplug
slaves to feed data in and out -
Because
dmix
requires ahw
slave, one instance of the plugin will run for each process playing audio. This is inefficient if you have two (or more) processes that play audio concurrently. This only matters if you usedmix
. -
CPU usage will be significant if you use large impulses or short period sizes.
Dependencies: FFTW and libsamplerate (both lib and lib32 versions).
make
sudo make install
The plugin requires (and assumes) impulse files are raw PCM data
stored as 32-bit floats of native endianness. If your impulse files
are in a different format, you can convert them with tools like
ffmpeg(1)
: ffmpeg -i impulse.wav -f f32le impulse.float32.pcm
pcm.impulse {
type impulse
slave { pcm "plughw:0" }
# This is optional but increases CPU efficiency (except the very first time the plugin is loaded)
# Specified path must be writeable
# Recommended to delete the file after hardware changes / software upgrades
wisdom_path "/home/foo/.cache/alsa/impulse_wisdom"
impulse.0 {
path "/path/to/left_channel.float32.pcm"
rate 44100
gain -20.0 # preamp gain in dB, optional (default 0.0 dB)
}
impulse.1 {
path "/path/to/right_channel.float32.pcm"
rate 44100
gain -20.0
}
# add more channels as needed...
#impulse.2 {
# path "/path/to/center_channel.float32.pcm"
# rate 44100
# gain -20.0
# fft_size 16384 # for experts only, omit for optimal results
#}
}
pcm.!default {
type plug
slave { pcm impulse }
}
-
pipewire has a convolver plugin that can be used in filter chains, works with all ALSA/PulseAudio/JACK programs
-
BruteFIR and CamillaDSP, both of which can do convolution filters in real-ish time using a loopback device
-
alsaloudness, a loudness-compensated volume control for ALSA, must-have if you are listening at low SPLs
alsaimpulse
is released under the terms of the GNU General Public
License as published by the Free Software Foundation, either version 3
of the License, or (at your option) any later version. See the file
COPYING
for more details.