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
|
.\" $OpenBSD: aucat.1,v 1.25 2008/06/03 19:27:42 jmc 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: June 3 2008 $
.Dt AUCAT 1
.Os
.Sh NAME
.Nm aucat
.Nd manipulate linear audio streams
.Sh SYNOPSIS
.Nm aucat
.Bk -words
.Op Fl qu
.Op Fl C Ar min : Ns Ar max
.Op Fl c Ar min : Ns Ar max
.Op Fl E Ar enc
.Op Fl e Ar enc
.Op Fl f Ar device
.Op Fl H Ar fmt
.Op Fl h Ar fmt
.Op Fl i Ar file
.Op Fl o Ar file
.Op Fl R Ar rate
.Op Fl r Ar rate
.Op Fl X Ar policy
.Op Fl x Ar policy
.Ek
.Sh DESCRIPTION
The
.Nm
utility can record one input stream
and store it on multiple destination files,
doing the necessary conversions on the fly.
It can play, convert, and mix multiple input files simultaneously.
.Nm
also has a legacy mode that works like previous versions of
.Nm ,
which does not convert on the fly and supports playback of .au files.
.Pp
The options are as follows:
.Bl -tag -width "-m mmmmmmmm "
.It Xo
.Fl C Ar min : Ns Ar max ,
.Fl c Ar min : Ns Ar max
.Xc
The range of channel numbers on the output or input stream, respectively.
The default is 0:1, i.e. stereo.
.It Fl E Ar enc , Fl e Ar enc
Encoding of the output or input stream, respectively (see below).
The default is signed, 16-bit, native byte order.
.It Fl f Ar device
The
.Xr audio 4
device to use for playing and/or recording.
The default is
.Pa /dev/audio .
.It Fl H Ar fmt , Fl h Ar fmt
File format of the output or input stream, respectively (see below).
The default is auto.
.It Fl i Ar file
Add this file to the list of files to play.
If the option argument is
.Sq -
then standard input will be used.
.It Fl o Ar file
Add this file to the list of files in which to store recorded samples.
If the option argument is
.Sq -
then standard output will be used.
.It Fl q
Do not print progress information; run quietly.
.It Fl R Ar rate , Fl r Ar rate
Sample rate in Hertz of the output or input stream, respectively.
The default is 44100Hz.
.It Fl u
Normally
.Nm
tries to automatically determine the optimal parameters for the audio device;
if this option is specified,
it will instead use the parameters specified by the
.Fl CcEeRr
options.
.It Fl X Ar policy
Action when the output stream cannot accept
recorded data fast enough.
If the policy
is
.Dq ignore
(the default) then samples that cannot be written are discarded.
If the policy is
.Dq sync
then 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.
If the policy is
.Dq error
then the stream is closed permanently.
.It Fl x Ar policy
Action when the input stream cannot provide
data to play fast enough.
If the policy is
.Dq ignore
(the default) then silence is played.
If the policy is
.Dq sync
then silence is played, but the same amount of samples will be discarded
once the stream is unblocked, in order to reach the right position in time.
If the policy is
.Dq error
then the stream is closed permanently.
.El
.Pp
Settings for input
.Pq Fl i
and output
.Pq Fl o
files can be changed using the
.Fl CcEeHhRrXx
options.
The last
.Fl CcEeHhRrXx
options specified before an
.Fl i
or
.Fl o
are applied to
.Ar file .
.Pp
Settings for the audio device
can be changed using the
.Fl CcEeRr
options.
They apply to the audio device only if the
.Fl u
option is given as well.
The last
.Fl CcEeRr
option specified before an
.Fl f
is applied to
.Ar device .
.Pp
If no audio device
.Pq Fl f
is specified but
.Fl u
is given anyway,
any
.Fl CcEeRr
options specified before
.Fl io
options are applied both to
.Ar file
and the default audio device;
if they are specified after
.Fl io
options,
they will be applied only to the default audio device.
.Pp
File formats are specified using the
.Fl H
and
.Fl h
options.
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
and
.Fl e
options.
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 LEGACY MODE
If neither
.Fl i
nor
.Fl o
are specified,
.Nm
will run in legacy mode, and won't convert sample formats or sampling rates.
In legacy mode, all options except
.Fl f
are ignored, and all other arguments are assumed to be names of files.
In legacy mode
.Nm
reads files sequentially, and writes them to the specified device.
If a Sun .au header is detected it is skipped over and not copied to
the audio device.
.Nm
will attempt to play data from Sun .au files as monaural 8-bit ulaw
samples with a sampling frequency of 8000 Hz.
However,
.Nm
will not fail if the audio device cannot be configured for these
parameters.
If a Microsoft .wav header (RIFF) is detected it is interpreted
to select the right audio encoding for playback and the data chunk of the
file is copied to the audio device.
If the device does not support the encoding,
.Nm
will exit with an error.
.Sh ENVIRONMENT
.Bl -tag -width "AUDIODEVICEXXX" -compact
.It Ev AUCAT_DEBUG
The debug level:
may be a value between 0 and 4.
.It Ev AUDIODEVICE
The audio device to use.
.El
.Sh EXAMPLES
The following command will record a stereo s16le stream at
44100Hz from the default device.
If necessary, the stream will be converted and/or resampled
to match parameters supported by the device:
.Bd -literal -offset indent
$ aucat -o file.raw
.Ed
.Pp
The following command will play a stereo s16le stream at
44100Hz on the default device, doing any necessary conversions:
.Bd -literal -offset indent
$ aucat -i file.raw
.Ed
.Pp
The following will 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
The following will 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 -R 96000 -C 2:3 -o file1.raw -C 6:7 -o file2.raw
.Ed
.Pp
The following will play two s18le mono files, one on each channel:
.Bd -literal -offset indent
$ aucat -e s18le -c 0:0 -i f1.raw -c 1:1 -i f2.raw
.Ed
.Pp
The following will mix and play two files and record a third one in
full-duplex:
.Bd -literal -offset indent
$ aucat -i drums.raw -i bass.raw -o guitar.raw
.Ed
.Sh SEE ALSO
.Xr audioctl 1 ,
.Xr cdio 1 ,
.Xr mixerctl 1 ,
.Xr audio 4
.Sh BUGS
The
.Nm
utility assumes non-blocking I/O for input and output streams.
It will not work reliably on files that may block
(ordinary files block, pipes don't).
.Pp
Resampling is low quality; down-sampling especially should be avoided
when recording.
.Pp
CPU usage is the same for all conversions.
It should be smaller for simpler ones.
.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.
|