dsp is an audio processing program with an interactive mode.
- GNU Make
- pkg-config
- fftw3: For
matrix4_mb,resample,fir,fir_p, andhilberteffects. - zita-convolver: For the
zita_convolvereffect. - libsndfile: For sndfile input/output support (recommended).
- ffmpeg (libavcodec, libavformat, and libavutil): For ffmpeg input support.
- alsa-lib: For alsa input/output support.
- libao: For ao output support.
- libmad: For mp3 input support (disabled by default).
- libpulse-simple: For PulseAudio input/ouput support.
- LADSPA: For the LADSPA frontend and the
ladspa_hosteffect.
$ make
Run ./configure [options] manually if you want to build with non-default
options. Run ./configure --help to see all available options.
# make install
dsp [options] path ... [effect [args]] ...
| Option | Description |
|---|---|
-h |
Show help text. |
-b frames |
Block size (must be given before the first input). |
-i |
Force interactive mode. |
-I |
Disable interactive mode. |
-q |
Disable progress display. |
-s |
Silent mode. |
-v |
Verbose mode. |
-d |
Force dithering. |
-D |
Disable dithering. |
-E |
Don't drain effects chain before rebuilding. |
-p |
Plot effects chain magnitude response instead of processing audio. |
-P |
Same as -p, but also plot phase response. |
-V |
Verbose progress display. |
-S |
Use "sequence" input combining mode. |
| Option | Description |
|---|---|
-o |
Output. |
-t type |
Type. |
-e encoding |
Encoding. |
-B/L/N |
Big/little/native endian. |
-r frequency[k] |
Sample rate. |
-c channels |
Number of channels. |
-R ratio |
Buffer ratio. |
-T time_range |
Set start and end positions (input only). |
-l[n] |
Repeat n times or indefinitely (input only). |
-n |
Equivalent to -t null null. |
The time_range argument has the form start_timespec[{-,+}end_timespec]. The
interpretation of end_timespec depends on the joining character: + means
relative to start_timespec, while - means absolute. Negative timespecs are
referenced to the end of the associated input. Also see the "Timespec syntax"
section below.
| Type | Modes | Encodings |
|---|---|---|
| null | rw | sample_t |
| sgen | r | sample_t |
| sndfile | r | autodetected |
| wav | rw | s16 u8 s24 s32 float double mu-law a-law ima_adpcm ms_adpcm gsm6.10 nms_adpcm_16 nms_adpcm_24 nms_adpcm_32 g721_32 mpeg2.3 |
| aiff | rw | s16 s8 u8 s24 s32 float double mu-law a-law ima_adpcm gsm6.10 dwvw_12 dwvw_16 dwvw_24 |
| au | rw | s16 s8 s24 s32 float double mu-law a-law g721_32 g723_24 g723_40 |
| raw | rw | s16 s8 u8 s24 s32 float double mu-law a-law gsm6.10 vox_adpcm nms_adpcm_16 nms_adpcm_24 nms_adpcm_32 dwvw_12 dwvw_16 dwvw_24 |
| paf | rw | s16 s8 s24 |
| svx | rw | s16 s8 |
| nist | rw | s16 s8 s24 s32 mu-law a-law |
| voc | rw | s16 u8 mu-law a-law |
| ircam | rw | s16 s32 float mu-law a-law |
| w64 | rw | s16 u8 s24 s32 float double mu-law a-law ima_adpcm ms_adpcm gsm6.10 |
| mat4 | rw | s16 s32 float double |
| mat5 | rw | s16 u8 s32 float double |
| pvf | rw | s16 s8 s32 |
| xi | rw | dpcm_8 dpcm_16 |
| htk | rw | s16 |
| sds | rw | s16 s8 s24 |
| avr | rw | s16 s8 u8 |
| wavex | rw | s16 u8 s24 s32 float double mu-law a-law |
| sd2 | rw | s16 s8 s24 s32 |
| flac | rw | s16 s8 s24 |
| caf | rw | s16 s8 s24 s32 float double mu-law a-law alac_16 alac_20 alac_24 alac_32 |
| wve | rw | a-law |
| ogg | rw | vorbis opus |
| mpc2k | rw | s16 |
| rf64 | rw | s16 u8 s24 s32 float double mu-law a-law |
| sf/mpeg | rw | mpeg1.1 mpeg1.2 mpeg2.3 |
| ffmpeg | r | autodetected |
| alsa | rw | s16 u8 s8 s24 s24_3 s32 float double |
| ao | w | s16 u8 s32 |
| mp3 | r | mad_f |
| pcm | rw | s16 u8 s8 s24 s24_3 s32 float double |
| pulse | rw | s16 u8 s24 s24_3 s32 float |
In concatenate mode (the default), the inputs are concatenated in the order given and sent to the output. All inputs must have the same sample rate and number of channels.
In sequence mode, the inputs are sent serially to the output like concatenate
mode, but the inputs do not need to have the same sample rate or number of
channels. The effects chain and/or output will be rebuilt/reopened when
required. Note that if the output is a file, the file will be truncated if it
is reopened. This mode is most useful when the output is an audio device, but
can also be used to concatenate inputs with different sample rates and/or
numbers of channels into a single output file when used with the resample
and/or remix effects.
The sgen input type is a basic (for now, at least) signal generator that can
generate impulses and exponential sine sweeps. The syntax for the path
argument is as follows:
[type[@channel_selector][:arg[=value]...]][/type...][+length]
type may be sine for sine sweeps or tones, or delta for a delta function
(impulse). length is a timespec (see "Timespec syntax"). sine accepts the
following arguments:
freq=f0[k][-f1[k]]Frequency. Iflenis set andf1is given, an exponential sine sweep is generated.
The arguments for delta are:
offset=time[s|m|S]Offset in seconds, miliseconds or samples.
Example:
$ dsp -t sgen -c 2 sine@0:freq=500-1k/sine@1:freq=300-800+2 gain -10
-
lowpass_1 [-r[thresh]] f0[k]
First-order lowpass filter. Seebiquadfor an explanation of the-roption. -
highpass_1 [-r[thresh]] f0[k]
First-order highpass filter. Seebiquadfor an explanation of the-roption. -
allpass_1 [-r[thresh]] f0[k]
First-order allpass filter. Seebiquadfor an explanation of the-roption. -
lowshelf_1 [-r[thresh]] f0[k] gain
First-order lowshelf filter. Seebiquadfor an explanation of the-roption. -
highshelf_1 [-r[thresh]] f0[k] gain
First-order highshelf filter. Seebiquadfor an explanation of the-roption. -
lowpass_1p [-r[thresh]] f0[k]
Single pole lowpass (EWMA) filter. Seebiquadfor an explanation of the-roption. -
lowpass [-r[thresh]] f0[k] width[q|o|h|k]
Second-order lowpass filter. Seebiquadfor an explanation of the-roption. -
highpass [-r[thresh]] f0[k] width[q|o|h|k]
Second-order highpass filter. Seebiquadfor an explanation of the-roption. -
bandpass_skirt [-r[thresh]] f0[k] width[q|o|h|k]
Second-order bandpass filter with constant skirt gain. Seebiquadfor an explanation of the-roption. -
bandpass_peak [-r[thresh]] f0[k] width[q|o|h|k]
Second-order bandpass filter with constant peak gain. Seebiquadfor an explanation of the-roption. -
notch [-r[thresh]] f0[k] width[q|o|h|k]
Second-order notch filter. Seebiquadfor an explanation of the-roption. -
allpass [-r[thresh]] f0[k] width[q|o|h|k]
Second-order allpass filter. Seebiquadfor an explanation of the-roption. -
eq [-r[thresh]] f0[k] width[q|o|h|k] gain
Second-order peaking filter. Seebiquadfor an explanation of the-roption. -
lowshelf [-r[thresh]] f0[k] width[q|s|d|o|h|k] gain
Second-order lowshelf filter. Seebiquadfor an explanation of the-roption. -
highshelf [-r[thresh]] f0[k] width[q|s|d|o|h|k] gain
Second-order highshelf filter. Seebiquadfor an explanation of the-roption. -
lowpass_transform [-r[thresh]] fz[k] width_z[q] fp[k] width_p[q]
Second-order lowpass transformation filter. Cancels the poles defined byfzandwidth_zand replaces them with new poles defined byfpandwidth_p. Gain is unity at DC. Seebiquadfor an explanation of the-roption. -
highpass_transform [-r[thresh]] fz[k] width_z[q] fp[k] width_p[q]
Second-order highpass transformation filter. Also known as a Linkwitz transform (see http://www.linkwitzlab.com/filters.htm#9). Same aslowpass_transformexcept the gain is unity at Fs/2. Seebiquadfor an explanation of the-roption. -
linkwitz_transform [-r[thresh]] fz[k] width_z[q] fp[k] width_p[q]
Alias forhighpass_transform. Seebiquadfor an explanation of the-roption. -
deemph [-r[thresh]]
Compact Disc de-emphasis filter. Seebiquadfor an explanation of the-roption. -
biquad [-r[thresh]] b0 b1 b2 a0 a1 a2
Biquad filter.If the
-roption is given, the filter is reversed in time using the method described in [1]. The optionalthreshparameter sets the truncation threshold in negative dB based on the pole with the longest decay time. The defaultthreshis 80. Cascaded time-reversed filters are transformed into a parallel structure for minimum latency.[1] M. Vicanek, "A New Reverse IIR Filtering Algorithm," Oct. 2015, rev. Jan. 2022
-
gain gain_dB
Gain adjustment in decibels. -
mult multiplier
Multiplies each sample bymultiplier. -
add value
Applies a DC shift. -
crossfeed f0[k] separation
Simple crossfeed for headphones. Very similar to Linkwitz/Meier/CMoy/bs2b crossfeed. -
matrix4 [options] [surround_level][/surround_level_rear]
2-to-4 channel (2 front and 2 surround) active matrix upmixer designed primarily for music. The intended speaker configuration is fronts at ±30° and surrounds between ±60° and ±120°. The front outputs replace the original input channels and the surround outputs are appended to the end of the channel list.For best results, the surround speakers must be calibrated to match the front speakers in both level and spectral balance.
matrix4is designed to preserve the total power of the original 2-channel input and incorrect calibration will compromise this property. After calibration, surround levels may be adjusted using thesurround_levelandsurround_level_rearparameters.surround_levelsets the level for neutral and forward steering. As steering moves from neutral to half rear,surround_level_reargradually takes effect. This allows fine-tuning of the overall front/rear balance while still allowing full level from the surrounds when needed. The default levels are -3dB and 0dB, respectively.Options are given as a comma-separated list. Recognized options are:
-
status[=bars|text|none]
Show real-time steering information. -
matrix=v1|v4[:param]|v2|v3
Controls steering behavior for rear-encoded sounds.v1does not remove anything from the front outputs.v4fully steers sounds encoded full rear (C/S=-45°) and restores lateral separation of sounds encoded along the C/S axis from 0° to -45° in the front outputs and from 0° to -22.5° in the surround outputs. Steering of sounds encoded to the left and right surround positions (L/R=±22.5° C/S=-22.5°) is adjustable viaparam. The default value of 0.5 gives approximately 12dB front/surround separation.v2andv3are retained for backwards compatability and are the same asv4withparamset to 0 (4.8dB separation) or 1 (full separation), respectively. The default matrix isv4. -
shelf=gain[:f0[k]]|none
Dynamic shelving of frequencies abovef0in surround outputs. Active when C/S is positive and gradually removed as C/S goes from 0° to -22.5°. The default values are -3dB and 500Hz. -
lowpass=f0[k]|none
Dynamic high-frequency rolloff (first-order lowpass shape) abovef0in surround outputs. Active when C/S is positive and gradually removed as C/S goes from 0° to -22.5°. The default is 6kHz. -
contour_pwrcmp=factor
Dynamic compensation for loss of high-frequency power related to frequency contouring in surround outputs. Attempts to minimize perceived timbral modification of both transient and sustained sounds. The default value is 1. -
phase_flip[=true|false]
Dynamically flip the relative phase of the right surround output under rear steering so that stongly rear-encoded sounds are in phase. The default istrue. -
signal[=true|false]
Toggle the effect wheneffect.signal()is called. -
direct_path[=true|false]
Redirect strongly rear-encoded sounds to two additional surround outputs which are not delayed. Enables sharper localization of such sounds while still allowing delay/decorrelation to be applied to ambient components. The default isfalse. -
rear_event_mask=factor
Sensitivity to rear-encoded sound events. If set to zero, sensitivity is the same for all directions. If set to a high value (e.g. 5), most rear events will be ignored. The default values are 1 formatrix4and 0.3 formatrix4_mb. -
surround_delay=delay[s|m|S]
Surround output delay. Generally, this should be set so that the surrounds are delayed 10-25 milliseconds relative to the fronts (measured acoustically). The default is value 15 milliseconds. -
filter_type=filter[:stop_dB[:stop_dB]](matrix4_mbonly)
Type of filter used for low pass sections of the filter bank.filtermay bebutterworth,chebyshev1,chebyshev2, orelliptic(default).The optional
stop_dBparameter(s) set the stopband attenuation in decibels for the Chebyshev and elliptic filters. Only the first parameter is used forchebyshev1andchebyshev2. Forelliptic, the first parameter applies to the lowpass and the second to the highpass. If only one parameter is given, it applies to both stopbands. Default values are 25 forchebyshev1andchebyshev2, and 35:50 forelliptic.
Applying decorrelation filters to the surround outputs can further improve spatial impression over simple delay. Example:
matrix4 -3/0 :2,3 delay -10m decorrelate -s1 -m -f0.7k -l35m 5 allpass 80 0.6 :The surround outputs are advanced by 10ms using the
delayeffect to compensate for the peak energy time of the decorrelation filters. An additionalallpassfilter equalizes the group delay at low frequencies.See
examples/matrix4_*for more examples. -
-
matrix4_mb [options] [surround_level][/surround_level_rear]
Like thematrix4effect, but divides the input into 13 individually steered bands in order to improve separation of concurrent sound sources. See thematrix4effect description for more information. -
remix selector|. ...
Select and mix input channels into output channels. Each selector argument specifies the input channels to be mixed to produce an output channel..selects no input channels. For example,remix 0,1 2,3mixes input channels 0 and 1 into output channel 0, and input channels 2 and 3 into output channel 1.remix -mixes all input channels into a single output channel. The active channel selector is used as an input channel mask for the selector arguments. -
st2msConvert stereo to mid/side. -
ms2stConvert mid/side to stereo. -
delay [-f[order]] delay[s|m|S]
Delay line. The unit for the delay argument depends on the suffix used:sis seconds (the default),mis milliseconds, andSis samples. Ifdelayis negative, a positive delay is applied to all channels which are not selected (except when plotting—an actual negative delay is possible in that case).By default, the delay is rounded to whole samples. The
-foption enables fractional delay using Thiran allpass interpolation. Theorderargument sets the allpass filter order and may be any integer from 1 through 50. The default value is 2. -
resample [bandwidth] fs[k]
Sinc resampler. Ignores the channel selector. -
fir [-a[offset[s|m|S]]] [input_options] [file:][~/]filter_path|coefs:list[/list...]
Non-partitioned 64-bit direct or FFT convolution. Latency is zero for filters up to 16 taps. For longer filters, the latency is equal to thefft_lenreported in verbose mode. Eachlistis a comma-separated list of coefficients for one filter channel. Missing values are filled with zeros.If
-ais given andoffsetis zero or unspecified, channels are aligned to the filter's peak sample. Positive or negativeoffsetvalues specify a fixed offset relative to the start or end of the filter, respectively.The
input_optionsare useful mostly when loading raw (headerless) input files and are as follows:Option Description -t typeType. -e encodingEncoding. -B/L/NBig/little/native endian. -r frequency[k]Sample rate. -c channelsNumber of channels. By default, the sample rate of the filter must match that of the effect. Mismatches may be ignored by setting the sample rate to "any".
-
fir_p [-a[offset[s|m|S]]] [input_options] [max_part_len] [file:][~/]filter_path|coefs:list[/list...]
Zero-latency non-uniform partitioned 64-bit direct/FFT convolution. Usually a bit slower than thezita_convolvereffect except for very long filters on some hardware.max_part_lenmust be a power of 2 and has a default value of 16384. Eachlistis a comma-separated list of coefficients for one filter channel. Missing values are filled with zeros.See the
fireffect description for an explanation of the-aoption and theinput_options. -
zita_convolver [-a[offset[s|m|S]]] [input_options] [min_part_len [max_part_len]] [file:][~/]filter_path|coefs:list[/list...]
Partitioned 32-bit FFT convolution using the zita-convolver library. Latency is equal tomin_part_len(64 samples by default).{min,max}_part_lenmust be powers of 2 between 64 and 8192. Eachlistis a comma-separated list of coefficients for one filter channel. Missing values are filled with zeros.See the
fireffect description for an explanation of the-aoption and theinput_options. -
hilbert [-pzc] [-a angle] taps
Simple FIR approximation of a Hilbert transform. The number of taps must be odd. Bandwidth is controlled by the number of taps. If-pis given, thefir_pconvolution engine is used instead of the defaultfirengine. Similarly, if-zis given,zita_convolveris used (if available). If-cis given, channels are automatically aligned to the middle tap. The-aoption sets the phase shift in degrees. The default is -90°. -
decorrelate [options] [stages]
Allpass decorrelator as described in "Frequency-Dependent Schroeder Allpass Filters" by Sebastian J. Schlecht (doi:10.3390/app10010187). With the default settings, the average group delay is around 9.5ms at high frequencies. The options are:Option Description -mUse the same filters for all input channels. -s seedRandom seed value. -d delay_min[s|m|S]Minimum filter delay (default: 0.83333ms). -D delay_max[s|m|S]Maximum filter delay (default: 3.12503ms). -f fc[k]Damping filter center frequency (default: 1.1kHz). -l rt60_lf[s|m|S]RT60 at low frequencies (default: 100ms). -h rt60_hf[s|m|S]RT60 at high frequencies (default: 8ms). The default number of stages is 5.
-
noise level[b]
Add TPDF noise. Thelevelargument specifies the peak level of the noise in dBFS if no suffix is given, or the effective precision in bits if thebsuffix is given. -
dither [shape] [[quantize_bits] bits]
Apply dither with optional noise shaping. Theshapeargument determines the type of dither and the noise shaping filter (if any):Name Description flatFlat TPDF with no feedback (default). slopedFlat TPDF with feedback. First-order highpass response. sloped2Sloped TPDF with feedback. Stronger HF emphasis than sloped.lipshitz5-tap E-weighted curve from [1]. Notches around 4k and 12k. wan33-tap F-weighted curve from [2]. Notch around 4k. wan99-tap F-weighted curve from [2]. Notches around 3.5k and 12k. The
bitsargument sets the dither level in bits. Thequantize_bitsargument sets the number of levels to quantize to. The default setting for both isauto. Ifbitsis notauto, dither is applied at the specified bit depth regardless of the output sample format.bitsmay be any number.quantize_bitsmust be an integer between 2 and 32. Ifquantize_bitsis not given, it is set to the same value asbits(rounded to the nearest integer).Note: Currently, setting
bitstoautodisables dither if the effect is loaded viawatchor used inladspa_dsp.[1] S. P. Lipshitz, J. Vanderkooy, and R. A. Wannamaker, "Minimally Audible Noise Shaping," J. AES, vol. 39, no. 11, November 1991
[2] R. A. Wannamaker, "Psychoacoustically Optimal Noise Shaping," J. AES, vol. 40, no. 7/8, July 1992 -
ladspa_host [~/]module_path plugin_label [control ...]
Apply a LADSPA plugin. Supports any number of input/output ports (with the exception of zero output ports). If a plugin has one or zero input ports, it will be instantiated multiple times to handle multi-channel input.Controls which are not explicitly set or are set to
-will use default values (if available).The
LADSPA_PATHenvironment variable can be used to set the search path for plugins. -
stats [-i] [-w cols] [ref_level]
Display the DC offset, minimum, maximum, peak level (dBFS), RMS level (dBFS), crest factor (dB), peak count, peak sample, number of samples, and length (s) for each channel. Ifref_levelis given, peak and RMS levels relative toref_levelwill be shown as well (dBr). The-ioption enables interpolation (4x oversampling plus quadratic peak estimation) to better approximate true peak values. The-woption sets the display width in characters. Zero means unlimited width.autoqueries the size of the terminal (if available). The default value is 80. -
watch [-e] [~/]path
Load effects from a file into a sub-chain and reload if the file is modified. Other than the automatic reload, the behavior is similar to sourcing a file using the@directive (see "Effects Files"). Some restrictions apply to automatic reload:- The new sub-chain must have the same output sample rate and number of channels as the previous sub-chain.
- The new sub-chain must not require larger buffers than the previous sub-chain.
If these conditions are not met, the new sub-chain will not be applied and an error message will be printed.
Currently, this effect polls for file modifications once per second. Support
inotifyevents my be added in the future. Ideally, file modifications should be atomic (i.e. by writing to a temporary file, thenrename(3)-ing it over top of the original file). If this is not possible, the-eoption may be given, which enforces an end-of-file marker in order to detect partially-written files. This marker,#EOF#, must be placed at the beginning of a line and may only be followed by whitespace characters. -
levels [-t time_const]
Show a basic real-time level meter for each channel. Values are in dBFS. The-toption sets the averaging time constant as well as the decay rate of the peak indicator.
| Example | Description |
|---|---|
<empty> |
all |
- |
all |
2- |
2 to n |
-4 |
0 through 4 |
1,3 |
1 and 3 |
1-4,7,9- |
1 through 4, 7, and 9 to n |
Note: There is no difference between 1,3 and 3,1. Order is not
preserved.
A timespec may be given in one of two forms: [[hours:]minutes:]seconds or
offset[s|m|S]. In the latter form, the suffix specifies whether offset is
in seconds (default), milliseconds, or samples, respectively.
The following suffixes are supported:
| Suffix | Description |
|---|---|
q |
Q-factor (default). |
s |
Slope (shelving filters only). |
d |
Slope in dB/octave (shelving filters only). |
o |
Bandwidth in octaves. |
h |
Bandwidth in Hz. |
k |
Bandwidth in kHz. |
Note: The d width suffix also changes the definition of f0 from center
frequency to corner frequency (like Room EQ Wizard and the Behringer DCX2496).
Additionally, a macro is provided for constructing arbitrary-order Butterworth
filters from cascaded second-order sections: bw<order>[.n], where <order> is
the filter order and n is an index corresponding to a particular pair of
poles. The Q-factors are always in ascending order. For example,
lowpass 1k bw6.0 lowpass 1k bw6.1 lowpass 1k bw6.2
creates a 6th-order Butterworth lowpass filter. Odd-order filters require an additional first-order section:
lowpass_1 1k lowpass 1k bw5.0 lowpass 1k bw5.1
On the command line, relative paths are relative to $PWD. Within an effects
file, relative paths are relative to the directory containing said effects
file. A ~/ prefix will be expanded to the contents of $HOME. The following
substitutions are supported anywhere within a file path:
| Sequence | Substitution |
|---|---|
%r |
Sample rate in Hz |
%k |
Sample rate in kHz |
%c |
Number of channels |
%% |
Literal % |
A colon (:) followed by a selector (see "Selector syntax") specifies the
input channels for effects that follow. For example,
:0,2 eq 1k 1.0 -6
will apply an eq effect to channels 0 and 2. If an effect changes the total
number of channels, the last channel selector given is parsed again. Additional
channels are not added unless the selector includes an unbounded range.
Channel numbers refer to the channels in the active channel mask, which is a
property of the containing block. Blocks may be created using braces
({ ... }) or by sourcing a file (see "Effects files"). The channel mask is
derived from the active channel selector at creation. For example,
:1,3 { :0 gain -6 :1 gain +6 }
creates a block with the mask 1,3. Within the block, :0 selects the first
channel in the mask (channel 1), and :1 selects the second channel in the
mask (channel 3). Channel selectors have block scope.
Channels are automatically added or removed from the active channel mask if an effect changes the total number of channels. Additional channels are always appended to the end of the channel list.
Files may be sourced using the @ directive: @[~/]path/to/file. See "File
paths" for more information about how paths are interpreted. Note that sourcing
a file implicitly creates a block (see "Channel selectors and masks"). Within a
file, lines in which the first non-whitespace character is # are ignored. A
backslash (\) may be used to escape whitespace, #, or \. Example:
gain -4.0
# This is a comment
lowshelf 90 1s +4 eq 3k 1.5 -3
An exclamation mark (!) allows initialization failure of the effect that
follows.
Effects utilizing FFTW3 can optionally load and save wisdom. For dsp, set the
DSP_FFTW_WISDOM_PATH environment variable. ladspa_dsp reads
LADSPA_DSP_FFTW_WISDOM_PATH instead. If a path is set, FFTW plans are created
with the FFTW_MEASURE flag. Accumulated wisdom is written on exit.
TSTP is handled gracefully, pausing the active input and output and restoring terminal state. USR1 triggers a rebuild of the effects chain. USR2 sends a signal to the effects chain.
Read file.flac, apply a bass boost, and write to alsa device hw:2:
dsp file.flac -ot alsa -e s24_3 hw:2 lowshelf 60 0.5 +4
Plot the magnitude vs frequency response of an effects chain:
dsp -pn [effect [args]] ... | gnuplot
Implement an LR4 crossover at 2.2KHz, where output channels 0 and 1 are the left and right tweeters, and channels 2 and 3 are the left and right woofers, respectively:
dsp stereo_file.flac -ot alsa -e s32 hw:3 remix 0 1 0 1
:0,1 highpass 2.2k 0.7071 highpass 2.2k 0.7071 :
:2,3 lowpass 2.2k 0.7071 lowpass 2.2k 0.7071 :
Apply effects from a file:
dsp file.flac @eq.txt
ladspa_dsp looks for configuration files in the following directories:
$XDG_CONFIG_HOME/ladspa_dsp$HOME/.config/ladspa_dsp(if$XDG_CONFIG_HOMEis not set)/etc/ladspa_dsp
To override the default directories, set the LADSPA_DSP_CONFIG_PATH
environment variable to the desired path(s) (colon-separated).
Each file that is named either config or config_<name> (where <name> is
any string) is loaded as a separate plugin. The plugin label is either
ladspa_dsp (for config) or ladspa_dsp:<name> (for config_<name>).
Configuration files are a simple key-value format. Leading whitespace is ignored. The valid keys are:
input_channels
Number of input channels. Default value is1. May be left unset unless you want individual control over each channel.output_channels
Number of output channels. Default value is1. This parameter is not currently set automatically because the number of LADSPA ports must be known before the effects chain is built. Initialization will fail if it does not match the effects chain.LC_NUMERIC
SetLC_NUMERICto the given value while building the effects chain. Default value isC, which gives consistent number parsing behavior regardless of the system locale and LADSPA host behavior. Setting this to an empty value uses the default system locale. The special valuenoneleavesLC_NUMERICup to the LADSPA host (not generally recommended).effects_chain
String to build the effects chain. The format is the same as an effects file, but only a single line is interpreted. Alternatively, the special[effects_chain]directive causes all subsequent lines to be interpreted as in an effects file.
Example configuration:
# This is a comment
input_channels=1
output_channels=1
LC_NUMERIC=C
[effects_chain]
gain -3 lowshelf 100 1s +3
@/path/to/eq_file
Relative file paths in the effects chain are relative to the directory in which the configuration file resides.
The loglevel can be set to VERBOSE, NORMAL, or SILENT through the
LADSPA_DSP_LOGLEVEL environment variable.
The resample effect cannot be used with the LADSPA frontend.
Some LADSPA hosts cache plugin information and may exhibit unexpected behavior if configuration files are added or removed, or if a configuration is edited to change the number of input and/or output channels. In these cases, it may be necessary to manually delete the cache file(s) or otherwise force the host to update its cache.
Put this in ~/.asoundrc:
pcm.dsp {
type plug
slave {
format FLOAT
rate unchanged
channels unchanged
pcm {
type ladspa
path "/usr/lib/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 (hw:0, for example).
If you need individual control over each channel, you need to set the number of (output) channels:
pcm.dsp {
type plug
slave {
format FLOAT
rate unchanged
pcm {
type ladspa
channels <channels>
path "/usr/lib/ladspa"
playback_plugins [{
label "ladspa_dsp"
}]
slave.pcm {
type plug
slave {
pcm "<hw_device>"
rate unchanged
channels unchanged
}
}
}
}
}
To make dsp the default device, append this to ~/.asoundrc:
pcm.!default {
type copy
slave.pcm "dsp"
}
Usage example: Route pulseaudio audio through ladspa_dsp (tested with Ubuntu 18.04; contributed by shaffenmeister)
- Prepare .asoundrc as stated above.
- Determine pulseaudio master sink using
pacmd list sinks. Use attributenameof the pulseaudio sink you plan to use (e.g.alsa_output.pci-0000_00_14.2.analog-stereo). - Execute
analyseplugin <path to LADSPA plugin>/ladspa_dsp.soto determine plugin name and label. - Run
pacmd load-module module-ladspa-sink sink_name=ladspa_out sink_master=<master_sink> plugin=<plugin name> label=<plugin label>. - Select new LADSPA sink as system sink (Ubuntu 18.04 Desktop:
Settings > Sound > Output > LADSPA_Plugin
<plugin label>on<master sink>).
Example:
pacmd list sinks
analyseplugin /usr/local/lib/ladspa/ladspa_dsp.so
pacmd load-module module-ladspa-sink sink_name=ladspa_out sink_master=alsa_output.pci-0000_00_14.2.analog-stereo plugin=ladspa_dsp label=ladspa_dsp
To load the LADSPA module at system startup for all users include settings in /etc/pulse/default.pa:
.ifexists module-ladspa-sink.so
.nofail
load-module module-ladspa-sink sink_name=ladspa_out sink_master=<master_sink> plugin=<plugin name> label=<plugin label>
.fail
.endif
To load the LADSPA module at user login include settings in
~/.config/pulse/default.pa:
#!/usr/bin/pulseaudio -nF
.include /etc/pulse/default.pa
.ifexists module-ladspa-sink.so
.nofail
load-module module-ladspa-sink sink_name=ladspa_out sink_master=<master_sink> plugin=<plugin name> label=<plugin label>
.fail
.endif
- No support for metadata.
- Some effects do not support plotting.
- When plotting an effects chain containing the
noiseeffect, a different random sequence is generated for each output channel regardless of whether the noise should be correlated between outputs. Summing correlated noise works correctly.
This software is released under the ISC license.