-
Notifications
You must be signed in to change notification settings - Fork 31
/
dsp.1
484 lines (478 loc) · 15.5 KB
/
dsp.1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
.TH DSP 1 dsp\-1.9
.SH NAME
dsp \- an audio processing program with an interactive mode
.SH SYNOPSIS
.B dsp
[\fIoptions\fR] \fIpath\fR ... [\fI!\fR] [:\fIchannel_selector\fR]
[@[~/]\fIeffects_file\fR] [\fIeffect\fR [\fIargs\fR ...]] ...
.SH DESCRIPTION
.B dsp
is an audio processing program with an interactive mode.
.SH OPTIONS
.SS Global options
.TP
\fB\-h\fR
Show help text.
.TP
\fB\-b\fR \fIframes\fR
Block size (must be given before the first input).
.TP
\fB\-i\fR
Force interactive mode.
.TP
\fB\-I\fR
Disable interactive mode.
.TP
\fB\-q\fR
Disable progress display.
.TP
\fB\-s\fR
Silent mode.
.TP
\fB\-v\fR
Verbose mode.
.TP
\fB\-d\fR
Force dithering.
.TP
\fB\-D\fR
Disable dithering.
.TP
\fB\-E\fR
Don't drain effects chain before rebuilding.
.TP
\fB\-p\fR
Plot effects chain magnitude response instead of processing audio.
.TP
\fB\-P\fR
Same as `-p', but also plot phase response.
.TP
\fB\-V\fR
Verbose progress display.
.TP
\fB\-S\fR
Use `sequence' input combining mode.
.SS Input/output options
.TP
\fB\-o\fR
Output.
.TP
\fB\-t\fR \fItype\fR
Type.
.TP
\fB\-e\fR \fIencoding\fR
Encoding.
.TP
\fB\-B\fR/\fBL\fR/\fBN\fR
Big/little/native endian.
.TP
\fB\-r\fR \fIfrequency\fR[\fBk\fR]
Sample rate.
.TP
\fB\-c\fR \fIchannels\fR
Number of channels.
.TP
\fB\-R\fR \fIratio\fR
Buffer ratio.
.TP
\fB\-n\fR
Equivalent to
.EX
\-t null null.
.EE
.SH INPUTS AND OUTPUTS
For a complete list of supported input/output types, run
.EX
$ dsp -h
.EE
.SS Input combining modes
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.
.PP
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 \fBresample\fR
and/or \fBremix\fR effects.
.SS Signal generator
The \fBsgen\fR input type is a basic (for now, at least) signal generator that can
generate impulses and exponential sine sweeps. The syntax for the \fIpath\fR
argument is as follows:
.PP
[\fItype\fR[@\fIchannel_selector\fR][:\fIarg\fR[=\fIvalue\fR]...]][/\fItype\fR...][+\fIlen\fR[\fBs\fR|\fBm\fR|\fBS\fR]]
.PP
\fItype\fR may be `sine' for sine sweeps or tones, or `delta' for a delta function
(impulse). `sine' accepts the following arguments:
.TP
\fBfreq\fR=\fIf0\fR[\fBk\fR][-\fIf1\fR[\fBk\fR]]
Frequency. If \fIlen\fR is set and \fIf1\fR is given, an exponential sine sweep
is generated.
.PP
The arguments for `delta' are:
.TP
\fBoffset\fR=\fItime\fR[\fBs\fR|\fBm\fR|\fBS\fR]
Offset in seconds, miliseconds or samples.
.PP
Example:
.EX
$ dsp -t sgen -c 2 sine@0:freq=500-1k/sine@1:freq=300-800+2 gain -10
.EE
.SH EFFECTS
.SS Full effects list
.TP
\fBlowpass_1\fR \fIf0\fR[\fBk\fR]
First-order lowpass filter.
.TP
\fBhighpass_1\fR \fIf0\fR[\fBk\fR]
First-order highpass filter.
.TP
\fBallpass_1\fR \fIf0\fR[\fBk\fR]
First-order allpass filter.
.TP
\fBlowshelf_1\fR \fIf0\fR[\fBk\fR] \fIgain\fR
First-order lowshelf filter.
.TP
\fBhighshelf_1\fR \fIf0\fR[\fBk\fR] \fIgain\fR
First-order highshelf filter.
.TP
\fBlowpass_1p\fR \fIf0\fR[\fBk\fR]
Single pole lowpass (EWMA) filter.
.TP
\fBlowpass\fR \fIf0\fR[\fBk\fR] \fIwidth\fR[\fBq\fR|\fBo\fR|\fBh\fR|\fBk\fR]
Second-order lowpass filter.
.TP
\fBhighpass\fR \fIf0\fR[\fBk\fR] \fIwidth\fR[\fBq\fR|\fBo\fR|\fBh\fR|\fBk\fR]
Second-order highpass filter.
.TP
\fBbandpass_skirt\fR \fIf0\fR[\fBk\fR] \fIwidth\fR[\fBq\fR|\fBo\fR|\fBh\fR|\fBk\fR]
Second-order bandpass filter with constant skirt gain.
.TP
\fBbandpass_peak\fR \fIf0\fR[\fBk\fR] \fIwidth\fR[\fBq\fR|\fBo\fR|\fBh\fR|\fBk\fR]
Second-order bandpass filter with constant peak gain.
.TP
\fBnotch\fR \fIf0\fR[\fBk\fR] \fIwidth\fR[\fBq\fR|\fBo\fR|\fBh\fR|\fBk\fR]
Second-order notch filter.
.TP
\fBallpass\fR \fIf0\fR[\fBk\fR] \fIwidth\fR[\fBq\fR|\fBo\fR|\fBh\fR|\fBk\fR]
Second-order allpass filter.
.TP
\fBeq\fR \fIf0\fR[\fBk\fR] \fIwidth\fR[\fBq\fR|\fBo\fR|\fBh\fR|\fBk\fR] \fIgain\fR
Second-order peaking filter.
.TP
\fBlowshelf\fR \fIf0\fR[\fBk\fR] \fIwidth\fR[\fBq\fR|\fBs\fR|\fBd\fR|\fBo\fR|\fBh\fR|\fBk\fR] \fIgain\fR
Second-order lowshelf filter.
.TP
\fBhighshelf\fR \fIf0\fR[\fBk\fR] \fIwidth\fR[\fBq\fR|\fBs\fR|\fBd\fR|\fBo\fR|\fBh\fR|\fBk\fR] \fIgain\fR
Second-order highshelf filter.
.TP
\fBlinkwitz_transform\fR \fIfz\fR[\fBk\fR] \fIqz\fR \fIfp\fR[\fBk\fR] \fIqp\fR
Linkwitz transform (see http://www.linkwitzlab.com/filters.htm#9).
.TP
\fBdeemph\fR
Compact Disc de-emphasis filter.
.TP
\fBbiquad\fR \fIb0\fR \fIb1\fR \fIb2\fR \fIa0\fR \fIa1\fR \fIa2\fR
Biquad filter.
.TP
\fBgain\fR [\fIchannel\fR] \fIgain\fR
Gain adjustment. Ignores the channel selector when the \fIchannel\fR argument
is given.
.TP
\fBmult\fR [\fIchannel\fR] \fImultiplier\fR
Multiplies each sample by \fImultiplier\fR. Ignores the channel selector when
the \fIchannel\fR argument is given.
.TP
\fBadd\fR [\fIchannel\fR] \fIvalue\fR
Applies a DC shift. Ignores the channel selector when the \fIchannel\fR
argument is given.
.TP
\fBcrossfeed\fR \fIf0\fR[\fBk\fR] \fIseparation\fR
Simple crossfeed for headphones. Very similar to Linkwitz/Meier/CMoy/bs2b
crossfeed.
.TP
\fBmatrix4\fR [\fIoptions\fR] [\fIsurround_level\fR]
2-to-4 channel (2 front and 2 surround) active matrix upmixer designed for
plain (i.e. unencoded) stereo material.
The intended speaker configuration is fronts at ±30° and surrounds between
±60° and ±120°. The surround speakers must be calibrated correctly in
level and frequency response for best results. The surrounds should be
delayed by about 10-25ms (acoustically) relative to the fronts. No
frequency contouring is done internally, so applying low pass and/or
shelving filters to the surround outputs is recommended:
.EX
matrix4 surround_delay=15m -6 :2,3 lowpass_1 10k :
.EE
The settings shown above (-6dB surround level, 15ms delay, and 10kHz
rolloff) are a good starting point, but may be adjusted to taste. The
default \fIsurround_level\fR is -6dB. Applying the \fBdecorrelate\fR effect to the
surround outputs (optionally with the \fI-m\fR flag) seems to further improve
the spatial impression (note: adjust `surround_delay' to compensate for
the \fBdecorrelate\fR effect's group delay).
The front outputs replace the original input channels and the surround
outputs are appended to the end of the channel list.
Options are given as a comma-separated list. Recognized options are:
.RS
.TP
no_dir_boost
Disable directional boost of front channels.
.TP
show_status
Show a status line (slightly broken currently, but still useful for
debugging).
.TP
signal
Toggle the effect when `effect.signal()' is called.
.TP
linear_phase (\fBmatrix4_mb\fR only)
Apply an FIR filter to correct the phase distortion caused by the IIR
filter bank. Has no effect with \fBmatrix4\fR. Requires the \fBfir\fR effect.
.TP
surround_delay=\fIdelay\fR[\fBs\fR|\fBm\fR|\fBS\fR]
Surround output delay. Default is zero.
.RE
.TP
\fBmatrix4_mb\fR [\fIoptions\fR] [\fIsurround_level\fR]
Like the \fBmatrix4\fR effect, but divides the input into ten individually
steered bands in order to improve separation of concurrent sound sources.
See the \fBmatrix4\fR effect description for more information.
.TP
\fBremix\fR \fIchannel_selector\fR|. ...
Select and mix input channels into output channels. Each channel selector
specifies the input channels to be mixed to produce each output channel.
`.' selects no input channels. For example,
.EX
remix 0,1 2,3
.EE
mixes input channels 0 and 1 into output channel 0, and input channels 2
and 3 into output channel 1.
.EX
remix -
.EE
mixes all input channels into a single output channel.
.TP
\fBst2ms\fR
Convert stereo to mid/side.
.TP
\fBms2st\fR
Convert mid/side to stereo.
.TP
\fBdelay\fR \fIdelay\fR[\fBs\fR|\fBm\fR|\fBS\fR]
Delay line. The unit for the \fIdelay\fR argument depends on the suffix used:
`\fBs\fR' is seconds (the default), `\fBm\fR' is milliseconds, and `\fBS\fR' is samples.
.TP
\fBresample\fR [\fIbandwidth\fR] \fIfs\fR[\fBk\fR]
Sinc resampler. Ignores the channel selector.
.TP
\fBfir\fR [file:][~/]\fIfilter_path\fR|coefs:\fIlist\fR[/\fIlist\fR...]
Non-partitioned 64-bit direct/FFT convolution. Latency is zero for filters
up to 16 samples. For longer filters, the latency is equal to the
\fIfft_len\fR reported in verbose mode. Each \fIlist\fR is a comma-separated list
of coefficients for one filter channel. Missing values are filled with
zeros.
.TP
\fBfir_p\fR [\fImax_part_len\fR] [file:][~/]\fIfilter_path\fR|coefs:\fIlist\fR[/\fIlist\fR...]
Zero-latency non-uniform partitioned 64-bit direct/FFT convolution. Runs
slower than the \fBzita_convolver\fR effect, but useful if you need higher
precision and/or zero latency. \fImax_part_len\fR must be a power of 2. Each
\fIlist\fR is a comma-separated list of coefficients for one filter channel.
Missing values are filled with zeros.
.TP
\fBzita_convolver\fR [\fImin_part_len\fR [\fImax_part_len\fR]] [~/]\fIfilter_path\fR
Partitioned 32-bit FFT convolution using the zita-convolver library.
Latency is equal to \fImin_part_len\fR (64 samples by default).
\fI{min,max}_part_len\fR must be powers of 2 between 64 and 8192.
.TP
\fBhilbert\fR [\fI-p\fR] \fItaps\fR
Simple FIR approximation of a Hilbert transform. The number of taps must be
odd. Bandwidth is controlled by the number of taps. If \fI-p\fR is given, the
\fBfir_p\fR convolution engine is used instead of the default \fBfir\fR engine.
.TP
\fBdecorrelate\fR [\fI-m\fR] [\fIstages\fR]
Allpass decorrelator as described in ``Frequency-Dependent Schroeder
Allpass Filters'' by Sebastian J. Schlecht (doi:10.3390/app10010187).
If \fI-m\fR is given, the same filter parameters are used for all input
channels. The default number of stages is 5, which results in an
average group delay of about 9.5ms at high frequencies.
.TP
\fBnoise\fR \fIlevel\fR
Add TPDF noise. The \fIlevel\fR argument specifies the peak level of the noise
(dBFS).
.TP
\fBladspa_host\fR \fImodule_path\fR \fIplugin_label\fR [\fIcontrol\fR ...]
Apply a LADSPA plugin. Supports any number of input/output ports (with
the exception of zero output ports). Plugins with zero input ports will
replace selected input channels with their output(s). 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_PATH' environment variable can be used to set the search path
for plugins.
.TP
\fBstats\fR [\fIref_level\fR]
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. If \fIref_level\fR is given, peak and RMS levels
relative to \fIref_level\fR will be shown as well (dBr).
.SS Exclamation mark
A `!' marks the effect that follows as `non-essential'. If an effect is marked
non-essential and it fails to initialize, it will be skipped.
.SS Selector syntax
[[\fIstart\fR][-[\fIend\fR]][,...]]
.TS
tab (|);
lB lB
lB l.
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
.TE
.SS Width suffixes
.TS
tab (|);
lB lB
lB l.
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.
.TE
.PP
Note: The `\fBd\fR' width suffix also changes the definition of \fIf0\fR from
center frequency to corner frequency (like Room EQ Wizard and the Behringer
DCX2496).
.SS File paths
.IP *
On the command line, relative paths are relative to `$PWD'.
.IP *
Within an effects file, relative paths are relative to the directory
containing said effects file.
.IP *
The `~/' prefix will be expanded to the contents of `$HOME'.
.SS Effects file syntax
.IP *
Arguments are delimited by whitespace.
.IP *
If the first non-whitespace character in a line is `#', the line is ignored.
.IP *
The `\\' character removes any special meaning of the next character.
.PP
Example:
.EX
gain -10
# This is a comment
eq 1k 1.0 +10.0 eq 3k 3.0 -4.0
lowshelf 90 0.7 +4.0
.EE
.PP
Effects files inherit a copy of the current channel selector. In other words,
if an effects chain is this:
.EX
:2,4 @eq_file.txt eq 2k 1.0 -2.0
.EE
\fIeq_file.txt\fR will inherit the `2,4' selector, but any selector specified
within \fIeq_file.txt\fR will not affect the `eq 2k 1.0 -2.0' effect that comes
after it.
.SH EXAMPLES
Read \fIfile.flac\fR, apply a bass boost, and write to alsa device \fIhw:2\fR:
.EX
dsp file.flac -ot alsa -e s24_3 hw:2 lowshelf 60 0.5 +4.0
.EE
.PP
Plot amplitude vs frequency for a complex effects chain:
.EX
dsp -pn gain -1.5 lowshelf 60 0.7 +7.8 eq 50 2.0 -2.7 eq 100 2.0 -3.9
eq 242 1.0 -3.8 eq 628 2.0 +2.1 eq 700 1.5 -1.0
lowshelf 1420 0.68 -12.5 eq 2500 1.3 +3.0 eq 3000 8.0 -1.8
eq 3500 2.5 +1.4 eq 6000 1.1 -3.4 eq 9000 1.8 -5.6
highshelf 10000 0.7 -0.5 | gnuplot
.EE
.PP
Implement an LR4 crossover at 2.2KHz, where output channels 0 and 2 are the
left and right woofers, and channels 1 and 3 are the left and right tweeters,
respectively:
.EX
dsp stereo_file.flac -ot alsa -e s32 hw:3 remix 0 0 1 1 :0,2
lowpass 2.2k 0.707 lowpass 2.2k 0.707 :1,3 highpass 2.2k 0.707
highpass 2.2k 0.707 :
.EE
.PP
Apply effects from a file:
.EX
dsp file.flac @eq.txt
.EE
.SH LADSPA FRONTEND
.SS Configuration
\fBladspa_dsp\fR looks for configuration files in the following directories:
.IP *
$XDG_CONFIG_HOME/ladspa_dsp
.IP *
$HOME/.config/ladspa_dsp (if $XDG_CONFIG_HOME is not set)
.IP *
/etc/ladspa_dsp
.PP
To override the default directories, set the `LADSPA_DSP_CONFIG_PATH'
environment variable to the desired path(s) (colon-separated).
.PP
Each file that is named either \fIconfig\fR or \fIconfig_<name>\fR (where \fI<name>\fR is
any string) is loaded as a separate plugin. The plugin label is either
\fIladspa_dsp\fR (for \fIconfig\fR) or \fIladspa_dsp:<name>\fR (for \fIconfig_<name>\fR).
.PP
Configuration files are a simple key-value format. Leading whitespace is
ignored. The valid keys are:
.TP
.B input_channels
Number of input channels. Default value is 1. May be left unset unless
you want individual control over each channel.
.TP
.B output_channels
Number of output channels. Default value is 1. Initialization will fail
if this value is set incorrectly.
.TP
.B LC_NUMERIC
Set `LC_NUMERIC' to the given value while building the effects chain. If
the decimal separator defined by your system locale is something other than
`.', you should set this to `C' (to use `.' as the decimal separator) or an
empty value (to use the decimal separator defined by your locale).
.TP
.B effects_chain
String to build the effects chain. The format is the same as an effects
file, but only a single line is interpreted.
.PP
Example configuration:
.EX
# This is a comment
input_channels=1
output_channels=1
LC_NUMERIC=C
effects_chain=gain -3.0 lowshelf 100 1.0s +3.0 @/path/to/eq_file
.EE
.PP
Relative file paths in the \fBeffects_chain\fR line are relative to the
directory in which the configuration file resides.
.PP
The loglevel can be set to `VERBOSE', `NORMAL', or `SILENT' through the
`LADSPA_DSP_LOGLEVEL' environment variable.
.PP
Note: The resample effect cannot be used with the LADSPA frontend.
.SS Examples
See https://github.com/bmc0/dsp/blob/master/README.md for usage examples.
.SH BUGS
No support for metadata.
.PP
Some effects do not support plotting.
.SH LICENSE
This software is released under the ISC license.