Annotation of src/usr.bin/aucat/aucat.1, Revision 1.41
1.41 ! jmc 1: .\" $OpenBSD: aucat.1,v 1.40 2008/11/17 09:40:09 jmc Exp $
1.1 kstailey 2: .\"
1.16 ratchov 3: .\" Copyright (c) 2006 Alexandre Ratchov <alex@caoua.org>
1.1 kstailey 4: .\"
1.16 ratchov 5: .\" Permission to use, copy, modify, and distribute this software for any
6: .\" purpose with or without fee is hereby granted, provided that the above
7: .\" copyright notice and this permission notice appear in all copies.
1.1 kstailey 8: .\"
1.16 ratchov 9: .\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10: .\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11: .\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12: .\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13: .\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14: .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15: .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
1.1 kstailey 16: .\"
1.38 ratchov 17: .Dd $Mdocdate: November 17 2008 $
1.1 kstailey 18: .Dt AUCAT 1
1.5 aaron 19: .Os
1.1 kstailey 20: .Sh NAME
21: .Nm aucat
1.16 ratchov 22: .Nd manipulate linear audio streams
1.1 kstailey 23: .Sh SYNOPSIS
24: .Nm aucat
1.16 ratchov 25: .Bk -words
1.27 jmc 26: .Op Fl lu
1.26 ratchov 27: .Op Fl b Ar nsamples
1.16 ratchov 28: .Op Fl C Ar min : Ns Ar max
29: .Op Fl c Ar min : Ns Ar max
30: .Op Fl e Ar enc
1.9 millert 31: .Op Fl f Ar device
1.16 ratchov 32: .Op Fl h Ar fmt
33: .Op Fl i Ar file
1.37 ratchov 34: .Op Fl m Ar mode
1.16 ratchov 35: .Op Fl o Ar file
36: .Op Fl r Ar rate
1.40 jmc 37: .Op Fl s Ar socket
1.30 ratchov 38: .Op Fl v Ar volume
1.22 ratchov 39: .Op Fl x Ar policy
1.16 ratchov 40: .Ek
1.1 kstailey 41: .Sh DESCRIPTION
42: The
1.7 aaron 43: .Nm
1.16 ratchov 44: utility can record one input stream
45: and store it on multiple destination files,
46: doing the necessary conversions on the fly.
1.17 jmc 47: It can play, convert, and mix multiple input files simultaneously.
1.9 millert 48: .Nm
1.16 ratchov 49: also has a legacy mode that works like previous versions of
50: .Nm ,
51: which does not convert on the fly and supports playback of .au files.
1.17 jmc 52: .Pp
1.16 ratchov 53: The options are as follows:
1.26 ratchov 54: .Bl -tag -width Ds
55: .It Fl b Ar nsamples
56: The buffer size in frames.
57: This is the number of samples that will be buffered before being played
58: and controls the playback latency.
1.25 jmc 59: .It Xo
60: .Fl C Ar min : Ns Ar max ,
61: .Fl c Ar min : Ns Ar max
62: .Xc
1.26 ratchov 63: The range of channel numbers on the record or playback stream, respectively.
1.17 jmc 64: The default is 0:1, i.e. stereo.
1.26 ratchov 65: .It Fl e Ar enc
66: Encoding of the playback or recording stream (see below).
1.17 jmc 67: The default is signed, 16-bit, native byte order.
68: .It Fl f Ar device
69: The
70: .Xr audio 4
71: device to use for playing and/or recording.
72: The default is
73: .Pa /dev/audio .
1.26 ratchov 74: .It Fl h Ar fmt
75: File format of the playback or record stream (see below).
1.17 jmc 76: The default is auto.
1.16 ratchov 77: .It Fl i Ar file
78: Add this file to the list of files to play.
79: If the option argument is
80: .Sq -
81: then standard input will be used.
1.26 ratchov 82: .It Fl l
1.35 ratchov 83: Listen for incoming connections on Unix domain sockets.
1.39 jmc 84: This allows clients to use
1.26 ratchov 85: .Nm
86: instead of the regular
87: .Xr audio 4
88: device for audio input and output
89: in order to share the physical device with other clients.
90: The default socket path is
91: .Pa /tmp/aucat.sock
1.35 ratchov 92: but other paths can be used with the
93: .Fl s
94: option.
1.37 ratchov 95: .It Fl m Ar mode
96: Set the server mode.
97: Valid modes are
1.39 jmc 98: .Ar play ,
99: .Ar rec ,
1.37 ratchov 100: and
1.39 jmc 101: .Ar duplex ,
102: for play-only, record-only, and full-duplex, respectively.
1.37 ratchov 103: The default is
1.39 jmc 104: .Ar duplex .
1.16 ratchov 105: .It Fl o Ar file
106: Add this file to the list of files in which to store recorded samples.
107: If the option argument is
108: .Sq -
109: then standard output will be used.
1.26 ratchov 110: .It Fl r Ar rate
111: Sample rate in Hertz of the playback or record stream.
1.17 jmc 112: The default is 44100Hz.
1.40 jmc 113: .It Fl s Ar socket
114: Add the path
115: .Ar socket
116: to the list of sockets to listen on.
1.39 jmc 117: Meaningful in server mode only.
1.16 ratchov 118: .It Fl u
1.21 jmc 119: Normally
120: .Nm
121: tries to automatically determine the optimal parameters for the audio device;
122: if this option is specified,
123: it will instead use the parameters specified by the
1.26 ratchov 124: .Fl Ccer
1.21 jmc 125: options.
1.30 ratchov 126: .It Fl v Ar volume
127: Software volume attenuation of the playback stream.
128: The value must be between 1 and 127,
1.31 jmc 129: corresponding to \-42dB and \-0dB attenuation.
1.33 ratchov 130: In server mode, clients inherit this parameter.
1.34 jmc 131: Reducing the volume in advance reduces a client's dynamic range,
132: but allows client volume to stay independent from the number
1.33 ratchov 133: of clients as long as their number is small enough.
1.34 jmc 134: A good compromise is to use \-4dB attenuation (12 volume units)
135: for each additional client expected
136: (115 if 2 clients are expected, 103 for 3 clients, and so on).
1.26 ratchov 137: .It Fl x Ar policy
1.22 ratchov 138: Action when the output stream cannot accept
1.26 ratchov 139: recorded data fast enough or the input stream
140: cannot provide data to play fast enough.
1.22 ratchov 141: If the policy
142: is
1.23 jmc 143: .Dq ignore
1.26 ratchov 144: (the default) then samples that cannot be written are discarded
145: and samples that cannot be read are replaced by silence.
1.22 ratchov 146: If the policy is
1.23 jmc 147: .Dq sync
1.26 ratchov 148: then recorded samples are discarded, but the same amount of silence will be written
1.22 ratchov 149: once the stream is unblocked, in order to reach the right position in time.
1.26 ratchov 150: Similarly silence is played, but the same amount of samples will be discarded
151: once the stream is unblocked.
1.22 ratchov 152: If the policy is
1.23 jmc 153: .Dq error
154: then the stream is closed permanently.
1.21 jmc 155: .El
156: .Pp
1.32 ratchov 157: If
158: .Nm
159: is sent
160: .Dv SIGINT ,
161: it terminates recording to files.
162: If sent
163: .Dv SIGUSR1
164: or
165: .Dv SIGUSR2 ,
166: it increases or decreases debug level, respectively.
167: .Pp
1.35 ratchov 168: Settings for input files
169: .Pq Fl i ,
170: output files
1.39 jmc 171: .Pq Fl o ,
1.35 ratchov 172: and sockets
173: .Pq Fl s
174: can be changed using the
175: .Fl Ccehrvx
1.16 ratchov 176: options.
1.21 jmc 177: The last
1.35 ratchov 178: .Fl Ccehrvx
1.23 jmc 179: options specified before an
1.35 ratchov 180: .Fl i ,
1.39 jmc 181: .Fl o ,
182: or
1.35 ratchov 183: .Fl s
1.41 ! jmc 184: are applied to the corresponding file.
1.21 jmc 185: .Pp
186: Settings for the audio device
187: can be changed using the
1.26 ratchov 188: .Fl Ccer
1.21 jmc 189: options.
190: They apply to the audio device only if the
191: .Fl u
192: option is given as well.
193: The last
1.26 ratchov 194: .Fl Ccer
1.21 jmc 195: option specified before an
1.16 ratchov 196: .Fl f
1.21 jmc 197: is applied to
198: .Ar device .
199: .Pp
200: If no audio device
201: .Pq Fl f
202: is specified but
203: .Fl u
204: is given anyway,
205: any
1.26 ratchov 206: .Fl Ccer
1.21 jmc 207: options specified before
1.41 ! jmc 208: .Fl ios
! 209: options are applied both to the corresponding file
1.21 jmc 210: and the default audio device;
211: if they are specified after
1.41 ! jmc 212: .Fl ios
1.21 jmc 213: options,
214: they will be applied only to the default audio device.
1.14 jmc 215: .Pp
1.20 jmc 216: File formats are specified using the
217: .Fl h
1.26 ratchov 218: option.
1.16 ratchov 219: The following file formats are supported:
220: .Bl -tag -width s32lexxx -offset -indent
221: .It raw
222: Headerless file.
1.17 jmc 223: This format is recommended since it has no limitations.
1.16 ratchov 224: .It wav
225: Microsoft WAVE file format.
226: There are limitations inherent to the file format itself:
227: not all encodings are supported,
228: file sizes are limited to 2GB,
1.17 jmc 229: and the file must support the
1.16 ratchov 230: .Xr lseek 2
1.17 jmc 231: operation (e.g. pipes do not support it).
1.16 ratchov 232: .It auto
233: Try to guess, depending on the file name.
1.9 millert 234: .El
235: .Pp
1.20 jmc 236: Encodings are specified using the
237: .Fl e
1.26 ratchov 238: option.
1.16 ratchov 239: The following encodings are supported:
240: .Pp
241: .Bl -tag -width s32lexxx -offset -indent -compact
242: .It s8
243: signed 8-bit
244: .It u8
245: unsigned 8-bit
246: .It s16le
247: signed 16-bit, little endian
248: .It u16le
249: unsigned 16-bit, little endian
250: .It s16be
251: signed 16-bit, big endian
252: .It u16be
253: unsigned 16-bit, big endian
254: .It s24le
255: signed 24-bit, stored in 4 bytes, little endian
256: .It u24le
257: unsigned 24-bit, stored in 4 bytes, little endian
258: .It s24be
259: signed 24-bit, stored in 4 bytes, big endian
260: .It u24be
261: unsigned 24-bit, stored in 4 bytes, big endian
262: .It s32le
263: signed 32-bit, little endian
264: .It u32le
265: unsigned 32-bit, little endian
266: .It s32be
267: signed 32-bit, big endian
268: .It u32be
269: unsigned 32-bit, big endian
270: .It s24le3
271: signed 24-bit, packed in 3 bytes, little endian
272: .It u24le3
273: unsigned 24-bit, packed in 3 bytes, big endian
274: .It s24be3
275: signed 24-bit, packed in 3 bytes, little endian
276: .It u24be3
277: unsigned 24-bit, packed in 3 bytes, big endian
278: .It s20le3
279: signed 20-bit, packed in 3 bytes, little endian
280: .It u20le3
281: unsigned 20-bit, packed in 3 bytes, big endian
282: .It s20be3
283: signed 20-bit, packed in 3 bytes, little endian
284: .It u20be3
285: unsigned 20-bit, packed in 3 bytes, big endian
286: .It s18le3
287: signed 18-bit, packed in 3 bytes, little endian
288: .It u18le3
289: unsigned 18-bit, packed in 3 bytes, big endian
290: .It s18be3
291: signed 18-bit, packed in 3 bytes, little endian
292: .It u18be3
293: unsigned 18-bit, packed in 3 bytes, big endian
294: .El
295: .Sh LEGACY MODE
296: If neither
297: .Fl i
298: nor
299: .Fl o
1.17 jmc 300: are specified,
1.16 ratchov 301: .Nm
1.17 jmc 302: will run in legacy mode, and won't convert sample formats or sampling rates.
1.16 ratchov 303: In legacy mode, all options except
1.17 jmc 304: .Fl f
305: are ignored, and all other arguments are assumed to be names of files.
1.16 ratchov 306: In legacy mode
307: .Nm
308: reads files sequentially, and writes them to the specified device.
309: If a Sun .au header is detected it is skipped over and not copied to
310: the audio device.
311: .Nm
312: will attempt to play data from Sun .au files as monaural 8-bit ulaw
313: samples with a sampling frequency of 8000 Hz.
314: However,
315: .Nm
316: will not fail if the audio device cannot be configured for these
317: parameters.
318: If a Microsoft .wav header (RIFF) is detected it is interpreted
319: to select the right audio encoding for playback and the data chunk of the
320: file is copied to the audio device.
321: If the device does not support the encoding,
322: .Nm
323: will exit with an error.
1.9 millert 324: .Sh ENVIRONMENT
1.35 ratchov 325: .Bl -tag -width "AUDIODEVICE" -compact
1.22 ratchov 326: .It Ev AUCAT_DEBUG
327: The debug level:
328: may be a value between 0 and 4.
1.24 jmc 329: .It Ev AUDIODEVICE
330: The audio device to use.
1.9 millert 331: .El
1.16 ratchov 332: .Sh EXAMPLES
333: The following will mix and play two stereo streams,
334: the first at 48kHz and the second at 44.1kHz:
335: .Bd -literal -offset indent
336: $ aucat -r 48000 -i file1.raw -r 44100 -i file2.raw
337: .Ed
338: .Pp
339: The following will record channels 2 and 3 into one stereo file and
340: channels 6 and 7 into another stereo file using a 96kHz sampling rate for
341: both:
342: .Bd -literal -offset indent
1.26 ratchov 343: $ aucat -r 96000 -C 2:3 -o file1.raw -C 6:7 -o file2.raw
1.16 ratchov 344: .Ed
345: .Pp
1.35 ratchov 346: The following will start
347: .Nm
1.40 jmc 348: in server mode using default parameters, but will create an
1.35 ratchov 349: additional socket for output to channels 2:3 only (rear speakers
1.39 jmc 350: on most cards):
1.35 ratchov 351: .Bd -literal -offset indent
352: $ aucat -l -s /tmp/aucat.sock -c 2:3 -s /tmp/aucat.sock.rear
353: .Ed
354: .Pp
355: The following will start
356: .Nm
1.39 jmc 357: in server mode creating the default socket with low volume and
358: an additional socket for high volume output:
1.35 ratchov 359: .Bd -literal -offset indent
360: $ aucat -l -v 65 -s /tmp/aucat.sock -v 127 -s /tmp/aucat.sock.max
1.16 ratchov 361: .Ed
1.2 kstailey 362: .Sh SEE ALSO
1.12 jmc 363: .Xr audioctl 1 ,
1.17 jmc 364: .Xr cdio 1 ,
1.9 millert 365: .Xr mixerctl 1 ,
1.2 kstailey 366: .Xr audio 4
1.16 ratchov 367: .Sh BUGS
368: The
1.1 kstailey 369: .Nm
1.16 ratchov 370: utility assumes non-blocking I/O for input and output streams.
371: It will not work reliably on files that may block
372: (ordinary files block, pipes don't).
373: .Pp
374: Resampling is low quality; down-sampling especially should be avoided
375: when recording.
376: .Pp
377: Processing is done using 16-bit arithmetic,
378: thus samples with more than 16 bits are rounded.
1.17 jmc 379: 16 bits (i.e. 97dB dynamic) are largely enough for most applications though.