Annotation of src/usr.bin/aucat/aucat.1, Revision 1.55
1.55 ! ratchov 1: .\" $OpenBSD: aucat.1,v 1.54 2009/07/25 08:44:27 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.55 ! ratchov 17: .Dd $Mdocdate: July 25 2009 $
1.1 kstailey 18: .Dt AUCAT 1
1.5 aaron 19: .Os
1.1 kstailey 20: .Sh NAME
21: .Nm aucat
1.47 ratchov 22: .Nd audio server and stream manipulation tool
1.1 kstailey 23: .Sh SYNOPSIS
24: .Nm aucat
1.16 ratchov 25: .Bk -words
1.42 ratchov 26: .Op Fl lnu
1.49 jmc 27: .Op Fl b Ar nframes
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.54 ratchov 38: .Op Fl U Ar unit
1.30 ratchov 39: .Op Fl v Ar volume
1.22 ratchov 40: .Op Fl x Ar policy
1.16 ratchov 41: .Ek
1.1 kstailey 42: .Sh DESCRIPTION
43: The
1.7 aaron 44: .Nm
1.16 ratchov 45: utility can record one input stream
46: and store it on multiple destination files,
47: doing the necessary conversions on the fly.
1.48 ratchov 48: It can play, convert, and mix multiple input files simultaneously,
49: and can also act as an audio server.
1.9 millert 50: .Nm
1.16 ratchov 51: also has a legacy mode that works like previous versions of
52: .Nm ,
53: which does not convert on the fly and supports playback of .au files.
1.17 jmc 54: .Pp
1.16 ratchov 55: The options are as follows:
1.26 ratchov 56: .Bl -tag -width Ds
1.49 jmc 57: .It Fl b Ar nframes
1.26 ratchov 58: The buffer size in frames.
1.49 jmc 59: A frame consists of one sample for each channel in the stream.
60: This is the number of frames that will be buffered before being played
61: and thus controls the playback latency.
1.25 jmc 62: .It Xo
63: .Fl C Ar min : Ns Ar max ,
64: .Fl c Ar min : Ns Ar max
65: .Xc
1.26 ratchov 66: The range of channel numbers on the record or playback stream, respectively.
1.17 jmc 67: The default is 0:1, i.e. stereo.
1.26 ratchov 68: .It Fl e Ar enc
69: Encoding of the playback or recording stream (see below).
1.17 jmc 70: The default is signed, 16-bit, native byte order.
71: .It Fl f Ar device
72: The
73: .Xr audio 4
1.50 ratchov 74: device or
75: .Nm
76: socket to use for playing and/or recording.
1.26 ratchov 77: .It Fl h Ar fmt
78: File format of the playback or record stream (see below).
1.17 jmc 79: The default is auto.
1.16 ratchov 80: .It Fl i Ar file
81: Add this file to the list of files to play.
82: If the option argument is
83: .Sq -
84: then standard input will be used.
1.26 ratchov 85: .It Fl l
1.35 ratchov 86: Listen for incoming connections on Unix domain sockets.
1.39 jmc 87: This allows clients to use
1.26 ratchov 88: .Nm
89: instead of the regular
90: .Xr audio 4
91: device for audio input and output
92: in order to share the physical device with other clients.
1.45 ratchov 93: The default socket name is
94: .Pa default
95: but other names can be used with the
1.35 ratchov 96: .Fl s
97: option.
1.37 ratchov 98: .It Fl m Ar mode
99: Set the server mode.
100: Valid modes are
1.39 jmc 101: .Ar play ,
102: .Ar rec ,
1.37 ratchov 103: and
1.39 jmc 104: .Ar duplex ,
105: for play-only, record-only, and full-duplex, respectively.
1.37 ratchov 106: The default is
1.39 jmc 107: .Ar duplex .
1.42 ratchov 108: .It Fl n
109: Loopback mode.
110: Instead of using an audio device, send input streams
111: to the output, processing them on the fly.
112: This mode is useful to mix, demultiplex, resample or reencode
1.43 jmc 113: audio files offline.
1.16 ratchov 114: .It Fl o Ar file
115: Add this file to the list of files in which to store recorded samples.
116: If the option argument is
117: .Sq -
118: then standard output will be used.
1.26 ratchov 119: .It Fl r Ar rate
120: Sample rate in Hertz of the playback or record stream.
1.17 jmc 121: The default is 44100Hz.
1.40 jmc 122: .It Fl s Ar socket
1.45 ratchov 123: Add the name
1.40 jmc 124: .Ar socket
125: to the list of sockets to listen on.
1.45 ratchov 126: .Ar socket
127: cannot contain '/'.
1.39 jmc 128: Meaningful in server mode only.
1.54 ratchov 129: .It Fl U Ar unit
130: Unit number to use when running in server mode.
131: Each
132: .Nm
133: server instance has an unique unit number,
134: used in
135: .Xr sndio 7
136: device names.
137: The default is 0.
1.16 ratchov 138: .It Fl u
1.21 jmc 139: Normally
140: .Nm
141: tries to automatically determine the optimal parameters for the audio device;
142: if this option is specified,
143: it will instead use the parameters specified by the
1.26 ratchov 144: .Fl Ccer
1.21 jmc 145: options.
1.30 ratchov 146: .It Fl v Ar volume
147: Software volume attenuation of the playback stream.
148: The value must be between 1 and 127,
1.31 jmc 149: corresponding to \-42dB and \-0dB attenuation.
1.33 ratchov 150: In server mode, clients inherit this parameter.
1.34 jmc 151: Reducing the volume in advance reduces a client's dynamic range,
152: but allows client volume to stay independent from the number
1.33 ratchov 153: of clients as long as their number is small enough.
1.34 jmc 154: A good compromise is to use \-4dB attenuation (12 volume units)
155: for each additional client expected
156: (115 if 2 clients are expected, 103 for 3 clients, and so on).
1.26 ratchov 157: .It Fl x Ar policy
1.22 ratchov 158: Action when the output stream cannot accept
1.26 ratchov 159: recorded data fast enough or the input stream
160: cannot provide data to play fast enough.
1.22 ratchov 161: If the policy
162: is
1.23 jmc 163: .Dq ignore
1.26 ratchov 164: (the default) then samples that cannot be written are discarded
165: and samples that cannot be read are replaced by silence.
1.22 ratchov 166: If the policy is
1.23 jmc 167: .Dq sync
1.26 ratchov 168: then recorded samples are discarded, but the same amount of silence will be written
1.22 ratchov 169: once the stream is unblocked, in order to reach the right position in time.
1.26 ratchov 170: Similarly silence is played, but the same amount of samples will be discarded
171: once the stream is unblocked.
1.22 ratchov 172: If the policy is
1.23 jmc 173: .Dq error
174: then the stream is closed permanently.
1.21 jmc 175: .El
176: .Pp
1.32 ratchov 177: If
178: .Nm
179: is sent
1.44 ratchov 180: .Dv SIGHUP ,
181: .Dv SIGINT
182: or
183: .Dv SIGTERM ,
1.32 ratchov 184: it terminates recording to files.
185: If sent
186: .Dv SIGUSR1
187: or
188: .Dv SIGUSR2 ,
189: it increases or decreases debug level, respectively.
190: .Pp
1.35 ratchov 191: Settings for input files
192: .Pq Fl i ,
193: output files
1.39 jmc 194: .Pq Fl o ,
1.35 ratchov 195: and sockets
196: .Pq Fl s
197: can be changed using the
198: .Fl Ccehrvx
1.16 ratchov 199: options.
1.21 jmc 200: The last
1.35 ratchov 201: .Fl Ccehrvx
1.23 jmc 202: options specified before an
1.35 ratchov 203: .Fl i ,
1.39 jmc 204: .Fl o ,
205: or
1.35 ratchov 206: .Fl s
1.41 jmc 207: are applied to the corresponding file.
1.21 jmc 208: .Pp
209: Settings for the audio device
210: can be changed using the
1.26 ratchov 211: .Fl Ccer
1.21 jmc 212: options.
213: They apply to the audio device only if the
214: .Fl u
215: option is given as well.
216: The last
1.26 ratchov 217: .Fl Ccer
1.21 jmc 218: option specified before an
1.16 ratchov 219: .Fl f
1.21 jmc 220: is applied to
221: .Ar device .
222: .Pp
223: If no audio device
224: .Pq Fl f
1.53 ratchov 225: is specified,
226: settings are applied as if
227: the default device is specified as the last argument.
228: If no sockets
229: .Pq Fl s
230: are specified
231: settings are applied as if
232: the default socket is specified as the last argument.
1.14 jmc 233: .Pp
1.20 jmc 234: File formats are specified using the
235: .Fl h
1.26 ratchov 236: option.
1.16 ratchov 237: The following file formats are supported:
238: .Bl -tag -width s32lexxx -offset -indent
239: .It raw
240: Headerless file.
1.17 jmc 241: This format is recommended since it has no limitations.
1.16 ratchov 242: .It wav
243: Microsoft WAVE file format.
244: There are limitations inherent to the file format itself:
245: not all encodings are supported,
246: file sizes are limited to 2GB,
1.17 jmc 247: and the file must support the
1.16 ratchov 248: .Xr lseek 2
1.17 jmc 249: operation (e.g. pipes do not support it).
1.16 ratchov 250: .It auto
251: Try to guess, depending on the file name.
1.9 millert 252: .El
253: .Pp
1.20 jmc 254: Encodings are specified using the
255: .Fl e
1.26 ratchov 256: option.
1.16 ratchov 257: The following encodings are supported:
258: .Pp
259: .Bl -tag -width s32lexxx -offset -indent -compact
260: .It s8
261: signed 8-bit
262: .It u8
263: unsigned 8-bit
264: .It s16le
265: signed 16-bit, little endian
266: .It u16le
267: unsigned 16-bit, little endian
268: .It s16be
269: signed 16-bit, big endian
270: .It u16be
271: unsigned 16-bit, big endian
272: .It s24le
273: signed 24-bit, stored in 4 bytes, little endian
274: .It u24le
275: unsigned 24-bit, stored in 4 bytes, little endian
276: .It s24be
277: signed 24-bit, stored in 4 bytes, big endian
278: .It u24be
279: unsigned 24-bit, stored in 4 bytes, big endian
280: .It s32le
281: signed 32-bit, little endian
282: .It u32le
283: unsigned 32-bit, little endian
284: .It s32be
285: signed 32-bit, big endian
286: .It u32be
287: unsigned 32-bit, big endian
288: .It s24le3
289: signed 24-bit, packed in 3 bytes, little endian
290: .It u24le3
291: unsigned 24-bit, packed in 3 bytes, big endian
292: .It s24be3
293: signed 24-bit, packed in 3 bytes, little endian
294: .It u24be3
295: unsigned 24-bit, packed in 3 bytes, big endian
296: .It s20le3
297: signed 20-bit, packed in 3 bytes, little endian
298: .It u20le3
299: unsigned 20-bit, packed in 3 bytes, big endian
300: .It s20be3
301: signed 20-bit, packed in 3 bytes, little endian
302: .It u20be3
303: unsigned 20-bit, packed in 3 bytes, big endian
304: .It s18le3
305: signed 18-bit, packed in 3 bytes, little endian
306: .It u18le3
307: unsigned 18-bit, packed in 3 bytes, big endian
308: .It s18be3
309: signed 18-bit, packed in 3 bytes, little endian
310: .It u18be3
311: unsigned 18-bit, packed in 3 bytes, big endian
312: .El
1.46 ratchov 313: .Sh SERVER MODE
314: .Nm
315: can be used in server mode
316: .Pq Fl l
317: to overcome hardware limitations and allow applications
318: to run on fixed sample rate devices or on devices
319: supporting only unusual encodings.
320: It is generally not desirable to have multiple
321: instances of
322: .Nm
323: running in server mode,
324: so it is good practice to start it thus:
325: .Bd -literal -offset indent
326: $ pgrep -x aucat || aucat -l
327: .Ed
328: .Pp
329: This also ensures privacy by preventing
330: other users from accessing the audio system.
331: On multi-user machines
332: .Nm
333: should be killed when no longer in use to make audio resources
334: available again to others:
335: .Bd -literal -offset indent
336: $ pkill -x aucat
337: .Ed
338: .Pp
339: Certain applications, such as synthesis software,
340: require a low latency audio setup.
341: To reduce the probability of buffer underruns or overruns,
342: the
343: .Xr renice 8
1.49 jmc 344: command can be used to give a higher priority to the
1.46 ratchov 345: .Nm
1.49 jmc 346: process.
1.46 ratchov 347: Superuser privileges are required.
348: For example:
349: .Bd -literal -offset indent
350: $ aucat -b 3500 -l
351: $ sudo renice -n -20 -p `pgrep -x aucat`
352: .Ed
1.55 ! ratchov 353: .Sh MIDI CONTROL
! 354: While running in server mode
! 355: .Pq Fl l
! 356: .Nm
! 357: exposes a MIDI device with the same name as the default audio
! 358: device.
! 359: It allows MIDI hardware or software to be used to control
! 360: the volume of played streams.
! 361: To each stream is assigned a MIDI channel, and the volume
! 362: is changed using the standard volume controller (number 7).
! 363: Similarly, when the audio application changes its volume,
! 364: the same MIDI controller message is sent out; it can be used
! 365: for instance for monitoring or as feed-back for motorized
! 366: faders.
1.16 ratchov 367: .Sh LEGACY MODE
368: If neither
369: .Fl i
370: nor
371: .Fl o
1.17 jmc 372: are specified,
1.16 ratchov 373: .Nm
1.17 jmc 374: will run in legacy mode, and won't convert sample formats or sampling rates.
1.16 ratchov 375: In legacy mode, all options except
1.17 jmc 376: .Fl f
377: are ignored, and all other arguments are assumed to be names of files.
1.16 ratchov 378: In legacy mode
379: .Nm
380: reads files sequentially, and writes them to the specified device.
381: If a Sun .au header is detected it is skipped over and not copied to
382: the audio device.
383: .Nm
1.52 jakemsr 384: will attempt to parse the format, number of channels and sample rate
385: from Sun .au file headers.
386: However, only alaw and ulaw formats are supported for .au files.
387: Other formats will be interpreted as ulaw.
1.16 ratchov 388: If a Microsoft .wav header (RIFF) is detected it is interpreted
389: to select the right audio encoding for playback and the data chunk of the
390: file is copied to the audio device.
391: If the device does not support the encoding,
392: .Nm
393: will exit with an error.
1.9 millert 394: .Sh ENVIRONMENT
1.35 ratchov 395: .Bl -tag -width "AUDIODEVICE" -compact
1.22 ratchov 396: .It Ev AUCAT_DEBUG
397: The debug level:
398: may be a value between 0 and 4.
1.24 jmc 399: .It Ev AUDIODEVICE
1.50 ratchov 400: Name of the
1.51 jmc 401: .Nm
1.50 ratchov 402: socket to connect to, or path to the
403: .Xr audio 4
404: device to use if the
405: .Fl f
406: option is not specified.
1.9 millert 407: .El
1.16 ratchov 408: .Sh EXAMPLES
409: The following will mix and play two stereo streams,
410: the first at 48kHz and the second at 44.1kHz:
411: .Bd -literal -offset indent
412: $ aucat -r 48000 -i file1.raw -r 44100 -i file2.raw
413: .Ed
414: .Pp
415: The following will record channels 2 and 3 into one stereo file and
416: channels 6 and 7 into another stereo file using a 96kHz sampling rate for
417: both:
418: .Bd -literal -offset indent
1.26 ratchov 419: $ aucat -r 96000 -C 2:3 -o file1.raw -C 6:7 -o file2.raw
1.42 ratchov 420: .Ed
421: .Pp
1.43 jmc 422: The following will split a stereo file into two mono files:
1.42 ratchov 423: .Bd -literal -offset indent
424: $ aucat -n -i stereo.wav -C 0:0 -o left.wav -C 1:1 -o right.wav
1.16 ratchov 425: .Ed
426: .Pp
1.35 ratchov 427: The following will start
428: .Nm
1.40 jmc 429: in server mode using default parameters, but will create an
1.35 ratchov 430: additional socket for output to channels 2:3 only (rear speakers
1.39 jmc 431: on most cards):
1.35 ratchov 432: .Bd -literal -offset indent
1.45 ratchov 433: $ aucat -l -s default -c 2:3 -s rear
1.35 ratchov 434: .Ed
435: .Pp
436: The following will start
437: .Nm
1.39 jmc 438: in server mode creating the default socket with low volume and
439: an additional socket for high volume output:
1.35 ratchov 440: .Bd -literal -offset indent
1.45 ratchov 441: $ aucat -l -v 65 -s default -v 127 -s max
1.16 ratchov 442: .Ed
1.2 kstailey 443: .Sh SEE ALSO
1.12 jmc 444: .Xr audioctl 1 ,
1.17 jmc 445: .Xr cdio 1 ,
1.9 millert 446: .Xr mixerctl 1 ,
1.54 ratchov 447: .Xr audio 4 ,
448: .Xr sndio 7
1.16 ratchov 449: .Sh BUGS
450: The
1.1 kstailey 451: .Nm
1.16 ratchov 452: utility assumes non-blocking I/O for input and output streams.
453: It will not work reliably on files that may block
454: (ordinary files block, pipes don't).
455: .Pp
456: Resampling is low quality; down-sampling especially should be avoided
457: when recording.
458: .Pp
459: Processing is done using 16-bit arithmetic,
460: thus samples with more than 16 bits are rounded.
1.17 jmc 461: 16 bits (i.e. 97dB dynamic) are largely enough for most applications though.