summaryrefslogtreecommitdiff
path: root/usr.bin/aucat/aucat.1
blob: 990ccb75ff3d1e06d8d3b73b5ca894343077fe19 (plain)
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
.\"	$OpenBSD: aucat.1,v 1.104 2014/01/28 06:20:51 ratchov Exp $
.\"
.\" Copyright (c) 2006 Alexandre Ratchov <alex@caoua.org>
.\"
.\" Permission to use, copy, modify, and distribute this software for any
.\" purpose with or without fee is hereby granted, provided that the above
.\" copyright notice and this permission notice appear in all copies.
.\"
.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
.Dd $Mdocdate: January 28 2014 $
.Dt AUCAT 1
.Os
.Sh NAME
.Nm aucat
.Nd audio/MIDI stream manipulation tool
.Sh SYNOPSIS
.Nm aucat
.Bk -words
.Op Fl dMn
.Op Fl C Ar min : Ns Ar max
.Op Fl c Ar min : Ns Ar max
.Op Fl e Ar enc
.Op Fl f Ar device
.Op Fl h Ar fmt
.Op Fl i Ar file
.Op Fl j Ar flag
.Op Fl o Ar file
.Op Fl q Ar port
.Op Fl r Ar rate
.Op Fl t Ar mode
.Op Fl v Ar volume
.Op Fl w Ar flag
.Op Fl x Ar policy
.Ek
.Sh DESCRIPTION
The
.Nm
utility can play, record, mix, and convert audio files.
During playback,
.Nm
reads audio data concurrently from all played files, mixes it and sends
the result to the device.
Similarly, during recording it duplicates audio data recorded
from the device and stores it into corresponding files.
It can process audio data on the fly:
.Pp
.Bl -bullet -offset indent -compact
.It
Change the sound encoding.
.It
Route the sound from one channel to another,
join stereo or split mono.
.It
Control the per-file playback volume.
.It
Monitor the sound being played, allowing to playback mix
to be recorded.
.El
.Pp
Finally,
.Nm
can accept MIDI messages usable for:
.Pp
.Bl -bullet -offset indent -compact
.It
Volume control.
.It
Start, stop and relocate playback and recording.
.El
.Pp
The options are as follows:
.Bl -tag -width Ds
.It Xo
.Fl C Ar min : Ns Ar max ,
.Fl c Ar min : Ns Ar max
.Xc
The range of stream channel numbers for recording and playback directions,
respectively.
The default is
.Cm 0:1 ,
i.e. stereo.
.It Fl d
Increase log verbosity.
.It Fl e Ar enc
Encoding of the playback or recording stream (see below).
The default is signed, 16-bit, native byte order.
.It Fl f Ar device
Use this
.Xr sndio 7
audio device.
Preceding per-device options apply to this device.
Streams
.Pq Fl io
and control MIDI ports
.Pq Fl q
that are applied after will be attached to this device.
Device mode and parameters are determined from streams
attached to it.
.It Fl h Ar fmt
File format of the playback or record stream (see below).
The default is
.Cm auto .
.It Fl i Ar file
Add this file to the list of streams to play.
If the option argument is
.Sq -
then standard input will be used.
.It Fl j Ar flag
Control whether stream channels are joined or expanded if
the stream number of channels is not equal to the device number of channels.
If the flag is
.Cm off
then stream channels are routed to the corresponding
device channel, possibly discarding channels not present in the device.
If the flag is
.Cm on ,
then a single stream channel may be sent on multiple device channels,
or multiple stream channels may be sent to a single device channel.
For instance, this feature could be used to request mono streams to
be sent on multiple outputs or to record a stereo input into a mono stream.
The default is
.Cm on .
.It Fl M
Create a MIDI thru box
.Pq i.e. MIDI-only pseudo device .
It merges any number of MIDI inputs and broadcasts the result
to any number of MIDI outputs, similarly to a hardware MIDI thru box.
Only MIDI ports
.Pq Fl q
and MIDI files
can be attached to it.
.It Fl n
Create a loopback pseudo audio device.
Send input streams
to the output, processing them on the fly.
This pseudo-device is useful to mix, demultiplex, resample or re-encode
audio files offline.
It requires at least one input
.Pq Fl i
and one output
.Pq Fl o .
.It Fl o Ar file
Add this file to the list of recording streams.
If the option argument is
.Sq -
then standard output will be used.
.It Fl q Ar port
Allow audio device properties to be controlled
through this MIDI port.
This includes per-stream volumes and the ability to
synchronously start, stop and relocate streams created in
MIDI Machine
Control (MMC) slave mode
.Pq Fl t .
.It Fl r Ar rate
Sample rate in Hertz of the stream.
The default is
.Cm 48000 .
.It Fl t Ar mode
Select the way streams are controlled by MIDI Machine Control (MMC)
messages.
If the mode is
.Cm off
(the default), then streams are not affected by MMC messages.
If the mode is
.Cm slave ,
then streams are started synchronously by MMC start messages.
.It Fl v Ar volume
Software volume attenuation of the playback stream.
The value must be between 1 and 127,
corresponding to \-42dB and \-0dB attenuation in 1/3dB steps.
The default is 127, i.e. no attenuation.
.It Fl w Ar flag
Control
.Nm
behaviour when the maximum volume of the hardware is reached
and a new stream is connected.
This happens only when stream volumes
are not properly set using the
.Fl v
option.
If the flag is
.Va on ,
then the master volume (corresponding to the mix of all playback streams)
is automatically adjusted to avoid clipping.
Using
.Va off
makes sense when all streams are recorded or produced with properly lowered
volumes.
The default is
.Cm on .
.It Fl x Ar policy
Action when the output stream cannot accept
recorded data fast enough or the input stream
cannot provide data to play fast enough.
If the policy is
.Cm ignore
(the default) then samples that cannot be written are discarded
and samples that cannot be read are replaced by silence.
If the policy is
.Cm sync
then recorded samples are discarded,
but the same amount of silence will be written
once the stream is unblocked, in order to reach the right position in time.
Similarly silence is played, but the same amount of samples will be discarded
once the stream is unblocked.
If the policy is
.Cm error
then the stream is closed permanently.
.Pp
If a stream is created with the
.Fl t
option,
the
.Cm ignore
action is disabled for any stream connected to it
to ensure proper synchronization.
.El
.Pp
On the command line,
per-device parameters must precede the device definition
.Pq Fl fMn ,
and per-stream parameters
.Pq Fl Ccehjmrtvx
must precede the stream definition
.Pq Fl io .
MIDI ports
.Pq Fl q
and stream definitions
.Pq Fl io
must follow the definition of the device
.Pq Fl fMn
to which they are attached.
.Pp
If no audio devices
.Pq Fl fMn
are specified,
settings are applied as if
the default device is specified.
.Pp
If
.Nm aucat
is sent
.Dv SIGHUP ,
.Dv SIGINT
or
.Dv SIGTERM ,
it terminates recording to files.
.Pp
File formats are specified using the
.Fl h
option.
The following file formats are supported:
.Bl -tag -width s32lexxx -offset indent
.It raw
Headerless file.
This format is recommended since it has no limitations.
.It wav
Microsoft WAVE file format.
There are limitations inherent to the file format itself:
not all encodings are supported,
file sizes are limited to 2GB,
and the file must support the
.Xr lseek 2
operation (e.g. pipes do not support it).
.It auto
Try to guess, depending on the file name.
.El
.Pp
Encodings are specified using the
.Fl e
option.
The following encodings are supported:
.Pp
.Bl -tag -width s32lexxx -offset indent -compact
.It s8
signed 8-bit
.It u8
unsigned 8-bit
.It s16le
signed 16-bit, little endian
.It u16le
unsigned 16-bit, little endian
.It s16be
signed 16-bit, big endian
.It u16be
unsigned 16-bit, big endian
.It s24le
signed 24-bit, stored in 4 bytes, little endian
.It u24le
unsigned 24-bit, stored in 4 bytes, little endian
.It s24be
signed 24-bit, stored in 4 bytes, big endian
.It u24be
unsigned 24-bit, stored in 4 bytes, big endian
.It s32le
signed 32-bit, little endian
.It u32le
unsigned 32-bit, little endian
.It s32be
signed 32-bit, big endian
.It u32be
unsigned 32-bit, big endian
.It s24le3
signed 24-bit, packed in 3 bytes, little endian
.It u24le3
unsigned 24-bit, packed in 3 bytes, big endian
.It s24be3
signed 24-bit, packed in 3 bytes, little endian
.It u24be3
unsigned 24-bit, packed in 3 bytes, big endian
.It s20le3
signed 20-bit, packed in 3 bytes, little endian
.It u20le3
unsigned 20-bit, packed in 3 bytes, big endian
.It s20be3
signed 20-bit, packed in 3 bytes, little endian
.It u20be3
unsigned 20-bit, packed in 3 bytes, big endian
.It s18le3
signed 18-bit, packed in 3 bytes, little endian
.It u18le3
unsigned 18-bit, packed in 3 bytes, big endian
.It s18be3
signed 18-bit, packed in 3 bytes, little endian
.It u18be3
unsigned 18-bit, packed in 3 bytes, big endian
.El
.Sh MIDI CONTROL
.Nm
can be controlled through MIDI
.Pq Fl q
as follows:
a MIDI channel is assigned to each stream, and the volume
is changed using the standard volume controller (number 7).
Similarly, when the audio client changes its volume,
the same MIDI controller message is sent out; it can be used
for instance for monitoring or as feedback for motorized
faders.
.Pp
The master volume can be changed using the standard master volume
system exclusive message.
.Pp
Streams created with the
.Fl t
option are controlled by the following MMC messages:
.Bl -tag -width relocateXXX -offset indent
.It relocate
Files are relocated to the requested time position.
If the requested position is beyond the end of file,
playback of the file is temporarly disabled until a valid
position is requested.
.It start
Files are started.
.It stop
Files are stopped and rewound back to the starting position.
.El
.Pp
MIDI control is intended to be used together with
.Xr sndiod 1 .
For instance, the following command will create two devices:
the default
.Va snd/0
and a MMC-controlled one
.Va snd/0.mmc :
.Bd -literal -offset indent
$ sndiod -r 48000 -z 400 -s default -t slave -s mmc
.Ed
.Pp
Programs using
.Va snd/0
behave normally, while programs using
.Va snd/0.mmc
wait for the MMC start signal and start synchronously.
Then, the following command will play a file on the
.Va snd/0.mmc
audio device, giving full control to MIDI software or hardware
connected to the
.Va midithru/0
MIDI port:
.Bd -literal -offset indent
$ aucat -f snd/0.mmc -t slave -q midithru/0 -i file.wav
.Ed
.Pp
At this stage,
.Nm
will start, stop and relocate automatically following all user
actions in the MIDI sequencer, assuming it's configured to
transmit MMC on
.Va midithru/0 .
Furthermore, the MIDI sequencer could be configured to use the
.Va snd/0
port as MTC clock source, assured to be synchronous to playback of
.Pa file.wav .
.Sh EXAMPLES
Mix and play two stereo streams,
the first at 48kHz and the second at 44.1kHz:
.Bd -literal -offset indent
$ aucat -r 48000 -i file1.raw -r 44100 -i file2.raw
.Ed
.Pp
Record channels 2 and 3 into one stereo file and
channels 6 and 7 into another stereo file using a 96kHz sampling rate for
both:
.Bd -literal -offset indent
$ aucat -j off -r 96000 -C 2:3 -o file1.raw -C 6:7 -o file2.raw
.Ed
.Pp
Split a stereo file into two mono files:
.Bd -literal -offset indent
$ aucat -n -j off -i stereo.wav -C 0:0 -o left.wav -C 1:1 \e
	-o right.wav
.Ed
.Sh SEE ALSO
.Xr audioctl 1 ,
.Xr cdio 1 ,
.Xr mixerctl 1 ,
.Xr sndiod 1 ,
.Xr audio 4 ,
.Xr sndio 7
.Sh BUGS
Resampling is low quality; down-sampling especially should be avoided
when recording.
.Pp
Processing is done using 16-bit arithmetic,
thus samples with more than 16 bits are rounded.
16 bits (i.e. 97dB dynamic) are largely enough for most applications though.