Annotation of src/usr.bin/aucat/aucat.1, Revision 1.43
1.43 ! jmc 1: .\" $OpenBSD: aucat.1,v 1.42 2009/01/10 20:02:28 ratchov 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.43 ! jmc 17: .Dd $Mdocdate: January 10 2009 $
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.42 ratchov 26: .Op Fl lnu
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.42 ratchov 105: .It Fl n
106: Loopback mode.
107: Instead of using an audio device, send input streams
108: to the output, processing them on the fly.
109: This mode is useful to mix, demultiplex, resample or reencode
1.43 ! jmc 110: audio files offline.
1.16 ratchov 111: .It Fl o Ar file
112: Add this file to the list of files in which to store recorded samples.
113: If the option argument is
114: .Sq -
115: then standard output will be used.
1.26 ratchov 116: .It Fl r Ar rate
117: Sample rate in Hertz of the playback or record stream.
1.17 jmc 118: The default is 44100Hz.
1.40 jmc 119: .It Fl s Ar socket
120: Add the path
121: .Ar socket
122: to the list of sockets to listen on.
1.39 jmc 123: Meaningful in server mode only.
1.16 ratchov 124: .It Fl u
1.21 jmc 125: Normally
126: .Nm
127: tries to automatically determine the optimal parameters for the audio device;
128: if this option is specified,
129: it will instead use the parameters specified by the
1.26 ratchov 130: .Fl Ccer
1.21 jmc 131: options.
1.30 ratchov 132: .It Fl v Ar volume
133: Software volume attenuation of the playback stream.
134: The value must be between 1 and 127,
1.31 jmc 135: corresponding to \-42dB and \-0dB attenuation.
1.33 ratchov 136: In server mode, clients inherit this parameter.
1.34 jmc 137: Reducing the volume in advance reduces a client's dynamic range,
138: but allows client volume to stay independent from the number
1.33 ratchov 139: of clients as long as their number is small enough.
1.34 jmc 140: A good compromise is to use \-4dB attenuation (12 volume units)
141: for each additional client expected
142: (115 if 2 clients are expected, 103 for 3 clients, and so on).
1.26 ratchov 143: .It Fl x Ar policy
1.22 ratchov 144: Action when the output stream cannot accept
1.26 ratchov 145: recorded data fast enough or the input stream
146: cannot provide data to play fast enough.
1.22 ratchov 147: If the policy
148: is
1.23 jmc 149: .Dq ignore
1.26 ratchov 150: (the default) then samples that cannot be written are discarded
151: and samples that cannot be read are replaced by silence.
1.22 ratchov 152: If the policy is
1.23 jmc 153: .Dq sync
1.26 ratchov 154: then recorded samples are discarded, but the same amount of silence will be written
1.22 ratchov 155: once the stream is unblocked, in order to reach the right position in time.
1.26 ratchov 156: Similarly silence is played, but the same amount of samples will be discarded
157: once the stream is unblocked.
1.22 ratchov 158: If the policy is
1.23 jmc 159: .Dq error
160: then the stream is closed permanently.
1.21 jmc 161: .El
162: .Pp
1.32 ratchov 163: If
164: .Nm
165: is sent
166: .Dv SIGINT ,
167: it terminates recording to files.
168: If sent
169: .Dv SIGUSR1
170: or
171: .Dv SIGUSR2 ,
172: it increases or decreases debug level, respectively.
173: .Pp
1.35 ratchov 174: Settings for input files
175: .Pq Fl i ,
176: output files
1.39 jmc 177: .Pq Fl o ,
1.35 ratchov 178: and sockets
179: .Pq Fl s
180: can be changed using the
181: .Fl Ccehrvx
1.16 ratchov 182: options.
1.21 jmc 183: The last
1.35 ratchov 184: .Fl Ccehrvx
1.23 jmc 185: options specified before an
1.35 ratchov 186: .Fl i ,
1.39 jmc 187: .Fl o ,
188: or
1.35 ratchov 189: .Fl s
1.41 jmc 190: are applied to the corresponding file.
1.21 jmc 191: .Pp
192: Settings for the audio device
193: can be changed using the
1.26 ratchov 194: .Fl Ccer
1.21 jmc 195: options.
196: They apply to the audio device only if the
197: .Fl u
198: option is given as well.
199: The last
1.26 ratchov 200: .Fl Ccer
1.21 jmc 201: option specified before an
1.16 ratchov 202: .Fl f
1.21 jmc 203: is applied to
204: .Ar device .
205: .Pp
206: If no audio device
207: .Pq Fl f
208: is specified but
209: .Fl u
210: is given anyway,
211: any
1.26 ratchov 212: .Fl Ccer
1.21 jmc 213: options specified before
1.41 jmc 214: .Fl ios
215: options are applied both to the corresponding file
1.21 jmc 216: and the default audio device;
217: if they are specified after
1.41 jmc 218: .Fl ios
1.21 jmc 219: options,
220: they will be applied only to the default audio device.
1.14 jmc 221: .Pp
1.20 jmc 222: File formats are specified using the
223: .Fl h
1.26 ratchov 224: option.
1.16 ratchov 225: The following file formats are supported:
226: .Bl -tag -width s32lexxx -offset -indent
227: .It raw
228: Headerless file.
1.17 jmc 229: This format is recommended since it has no limitations.
1.16 ratchov 230: .It wav
231: Microsoft WAVE file format.
232: There are limitations inherent to the file format itself:
233: not all encodings are supported,
234: file sizes are limited to 2GB,
1.17 jmc 235: and the file must support the
1.16 ratchov 236: .Xr lseek 2
1.17 jmc 237: operation (e.g. pipes do not support it).
1.16 ratchov 238: .It auto
239: Try to guess, depending on the file name.
1.9 millert 240: .El
241: .Pp
1.20 jmc 242: Encodings are specified using the
243: .Fl e
1.26 ratchov 244: option.
1.16 ratchov 245: The following encodings are supported:
246: .Pp
247: .Bl -tag -width s32lexxx -offset -indent -compact
248: .It s8
249: signed 8-bit
250: .It u8
251: unsigned 8-bit
252: .It s16le
253: signed 16-bit, little endian
254: .It u16le
255: unsigned 16-bit, little endian
256: .It s16be
257: signed 16-bit, big endian
258: .It u16be
259: unsigned 16-bit, big endian
260: .It s24le
261: signed 24-bit, stored in 4 bytes, little endian
262: .It u24le
263: unsigned 24-bit, stored in 4 bytes, little endian
264: .It s24be
265: signed 24-bit, stored in 4 bytes, big endian
266: .It u24be
267: unsigned 24-bit, stored in 4 bytes, big endian
268: .It s32le
269: signed 32-bit, little endian
270: .It u32le
271: unsigned 32-bit, little endian
272: .It s32be
273: signed 32-bit, big endian
274: .It u32be
275: unsigned 32-bit, big endian
276: .It s24le3
277: signed 24-bit, packed in 3 bytes, little endian
278: .It u24le3
279: unsigned 24-bit, packed in 3 bytes, big endian
280: .It s24be3
281: signed 24-bit, packed in 3 bytes, little endian
282: .It u24be3
283: unsigned 24-bit, packed in 3 bytes, big endian
284: .It s20le3
285: signed 20-bit, packed in 3 bytes, little endian
286: .It u20le3
287: unsigned 20-bit, packed in 3 bytes, big endian
288: .It s20be3
289: signed 20-bit, packed in 3 bytes, little endian
290: .It u20be3
291: unsigned 20-bit, packed in 3 bytes, big endian
292: .It s18le3
293: signed 18-bit, packed in 3 bytes, little endian
294: .It u18le3
295: unsigned 18-bit, packed in 3 bytes, big endian
296: .It s18be3
297: signed 18-bit, packed in 3 bytes, little endian
298: .It u18be3
299: unsigned 18-bit, packed in 3 bytes, big endian
300: .El
301: .Sh LEGACY MODE
302: If neither
303: .Fl i
304: nor
305: .Fl o
1.17 jmc 306: are specified,
1.16 ratchov 307: .Nm
1.17 jmc 308: will run in legacy mode, and won't convert sample formats or sampling rates.
1.16 ratchov 309: In legacy mode, all options except
1.17 jmc 310: .Fl f
311: are ignored, and all other arguments are assumed to be names of files.
1.16 ratchov 312: In legacy mode
313: .Nm
314: reads files sequentially, and writes them to the specified device.
315: If a Sun .au header is detected it is skipped over and not copied to
316: the audio device.
317: .Nm
318: will attempt to play data from Sun .au files as monaural 8-bit ulaw
319: samples with a sampling frequency of 8000 Hz.
320: However,
321: .Nm
322: will not fail if the audio device cannot be configured for these
323: parameters.
324: If a Microsoft .wav header (RIFF) is detected it is interpreted
325: to select the right audio encoding for playback and the data chunk of the
326: file is copied to the audio device.
327: If the device does not support the encoding,
328: .Nm
329: will exit with an error.
1.9 millert 330: .Sh ENVIRONMENT
1.35 ratchov 331: .Bl -tag -width "AUDIODEVICE" -compact
1.22 ratchov 332: .It Ev AUCAT_DEBUG
333: The debug level:
334: may be a value between 0 and 4.
1.24 jmc 335: .It Ev AUDIODEVICE
336: The audio device to use.
1.9 millert 337: .El
1.16 ratchov 338: .Sh EXAMPLES
339: The following will mix and play two stereo streams,
340: the first at 48kHz and the second at 44.1kHz:
341: .Bd -literal -offset indent
342: $ aucat -r 48000 -i file1.raw -r 44100 -i file2.raw
343: .Ed
344: .Pp
345: The following will record channels 2 and 3 into one stereo file and
346: channels 6 and 7 into another stereo file using a 96kHz sampling rate for
347: both:
348: .Bd -literal -offset indent
1.26 ratchov 349: $ aucat -r 96000 -C 2:3 -o file1.raw -C 6:7 -o file2.raw
1.42 ratchov 350: .Ed
351: .Pp
1.43 ! jmc 352: The following will split a stereo file into two mono files:
1.42 ratchov 353: .Bd -literal -offset indent
354: $ aucat -n -i stereo.wav -C 0:0 -o left.wav -C 1:1 -o right.wav
1.16 ratchov 355: .Ed
356: .Pp
1.35 ratchov 357: The following will start
358: .Nm
1.40 jmc 359: in server mode using default parameters, but will create an
1.35 ratchov 360: additional socket for output to channels 2:3 only (rear speakers
1.39 jmc 361: on most cards):
1.35 ratchov 362: .Bd -literal -offset indent
363: $ aucat -l -s /tmp/aucat.sock -c 2:3 -s /tmp/aucat.sock.rear
364: .Ed
365: .Pp
366: The following will start
367: .Nm
1.39 jmc 368: in server mode creating the default socket with low volume and
369: an additional socket for high volume output:
1.35 ratchov 370: .Bd -literal -offset indent
371: $ aucat -l -v 65 -s /tmp/aucat.sock -v 127 -s /tmp/aucat.sock.max
1.16 ratchov 372: .Ed
1.2 kstailey 373: .Sh SEE ALSO
1.12 jmc 374: .Xr audioctl 1 ,
1.17 jmc 375: .Xr cdio 1 ,
1.9 millert 376: .Xr mixerctl 1 ,
1.2 kstailey 377: .Xr audio 4
1.16 ratchov 378: .Sh BUGS
379: The
1.1 kstailey 380: .Nm
1.16 ratchov 381: utility assumes non-blocking I/O for input and output streams.
382: It will not work reliably on files that may block
383: (ordinary files block, pipes don't).
384: .Pp
385: Resampling is low quality; down-sampling especially should be avoided
386: when recording.
387: .Pp
388: Processing is done using 16-bit arithmetic,
389: thus samples with more than 16 bits are rounded.
1.17 jmc 390: 16 bits (i.e. 97dB dynamic) are largely enough for most applications though.