NAME
aucat
—
audio/MIDI stream manipulation
tool
SYNOPSIS
aucat |
[-dMn ]
[-C min:max]
[-c min:max]
[-e enc]
[-f device]
[-h fmt]
[-i file]
[-j flag]
[-o file]
[-q port]
[-r rate]
[-t mode]
[-v volume]
[-w flag]
[-x policy] |
DESCRIPTION
The aucat
utility can play, record, mix,
and convert audio files. During playback, aucat
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:
- Change the sound encoding.
- Route the sound from one channel to another, join stereo or split mono.
- Control the per-file playback volume.
- Monitor the sound being played, allowing the playback mix to be recorded.
Finally, aucat
can accept MIDI messages
usable for:
- Volume control.
- Start, stop and relocate playback and recording.
The options are as follows:
-C
min:max,-c
min:max- The range of stream channel numbers for recording and playback directions,
respectively. The default is
0:1
, i.e. stereo. -d
- Increase log verbosity.
-e
enc- Encoding of the playback or recording stream (see below). The default is signed, 16-bit, native byte order.
-f
device- Use this sndio(7) audio device. Preceding per-device options apply
to this device. Streams (
-io
) and control MIDI ports (-q
) that are applied after will be attached to this device. Device mode and parameters are determined from streams attached to it. -h
fmt- File format of the playback or record stream (see below). The default is
auto
. -i
file- Add this file to the list of streams to play. If the option argument is ‘-’ then standard input will be used.
-j
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
off
then stream channels are routed to the corresponding device channel, possibly discarding channels not present in the device. If the flag ison
, 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 ison
. -M
- Create a MIDI thru box (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
(
-q
) and MIDI files can be attached to it. -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 (
-i
) and one output (-o
). -o
file- Add this file to the list of recording streams. If the option argument is ‘-’ then standard output will be used.
-q
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
(
-t
). -r
rate- Sample rate in Hertz of the stream. The default is
48000
. -t
mode- Select the way streams are controlled by MIDI Machine Control (MMC)
messages. If the mode is
off
(the default), then streams are not affected by MMC messages. If the mode isslave
, then streams are started synchronously by MMC start messages. -v
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.
-w
flag- Control
aucat
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-v
option. If the flag ison
, then the master volume (corresponding to the mix of all playback streams) is automatically adjusted to avoid clipping. Usingoff
makes sense when all streams are recorded or produced with properly lowered volumes. The default ison
. -x
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
ignore
(the default) then samples that cannot be written are discarded and samples that cannot be read are replaced by silence. If the policy issync
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 iserror
then the stream is closed permanently.If a stream is created with the
-t
option, theignore
action is disabled for any stream connected to it to ensure proper synchronization.
On the command line, per-device parameters must precede the device
definition (-fMn
), and per-stream parameters
(-Ccehjmrtvx
) must precede the stream definition
(-io
). MIDI ports (-q
) and
stream definitions (-io
) must follow the definition
of the device (-fMn
) to which they are attached.
If no audio devices (-fMn
) are specified,
settings are applied as if the default device is specified.
If aucat
is sent
SIGHUP
, SIGINT
or
SIGTERM
, it terminates recording to files.
File formats are specified using the -h
option. The following file formats are supported:
- raw
- Headerless file. This format is recommended since it has no limitations.
- 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 lseek(2) operation (e.g. pipes do not support it).
- auto
- Try to guess, depending on the file name.
Encodings are specified using the -e
option. The following encodings are supported:
- s8
- signed 8-bit
- u8
- unsigned 8-bit
- s16le
- signed 16-bit, little endian
- u16le
- unsigned 16-bit, little endian
- s16be
- signed 16-bit, big endian
- u16be
- unsigned 16-bit, big endian
- s24le
- signed 24-bit, stored in 4 bytes, little endian
- u24le
- unsigned 24-bit, stored in 4 bytes, little endian
- s24be
- signed 24-bit, stored in 4 bytes, big endian
- u24be
- unsigned 24-bit, stored in 4 bytes, big endian
- s32le
- signed 32-bit, little endian
- u32le
- unsigned 32-bit, little endian
- s32be
- signed 32-bit, big endian
- u32be
- unsigned 32-bit, big endian
- s24le3
- signed 24-bit, packed in 3 bytes, little endian
- u24le3
- unsigned 24-bit, packed in 3 bytes, big endian
- s24be3
- signed 24-bit, packed in 3 bytes, little endian
- u24be3
- unsigned 24-bit, packed in 3 bytes, big endian
- s20le3
- signed 20-bit, packed in 3 bytes, little endian
- u20le3
- unsigned 20-bit, packed in 3 bytes, big endian
- s20be3
- signed 20-bit, packed in 3 bytes, little endian
- u20be3
- unsigned 20-bit, packed in 3 bytes, big endian
- s18le3
- signed 18-bit, packed in 3 bytes, little endian
- u18le3
- unsigned 18-bit, packed in 3 bytes, big endian
- s18be3
- signed 18-bit, packed in 3 bytes, little endian
- u18be3
- unsigned 18-bit, packed in 3 bytes, big endian
MIDI CONTROL
aucat
can be controlled through MIDI
(-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.
The master volume can be changed using the standard master volume system exclusive message.
Streams created with the -t
option are
controlled by the following MMC messages:
- 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.
- start
- Files are started.
- stop
- Files are stopped and rewound back to the starting position.
MIDI control is intended to be used together with sndiod(1). For instance, the following command will create two devices: the default snd/0 and a MMC-controlled one snd/0.mmc:
$ sndiod -r 48000 -z 400 -s default -t slave -s mmc
Programs using snd/0 behave normally, while programs using snd/0.mmc wait for the MMC start signal and start synchronously. Then, the following command will play a file on the snd/0.mmc audio device, giving full control to MIDI software or hardware connected to the midithru/0 MIDI port:
$ aucat -f snd/0.mmc -t slave -q midithru/0 -i file.wav
At this stage, aucat
will start, stop and
relocate automatically following all user actions in the MIDI sequencer,
assuming it's configured to transmit MMC on
midithru/0. Furthermore, the MIDI sequencer could be
configured to use the snd/0 port as MTC clock source,
assured to be synchronous to playback of
file.wav.
EXAMPLES
Mix and play two stereo streams, the first at 48kHz and the second at 44.1kHz:
$ aucat -r 48000 -i file1.raw -r 44100 -i file2.raw
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:
$ aucat -j off -r 96000 -C 2:3 -o file1.raw -C 6:7 -o file2.raw
Split a stereo file into two mono files:
$ aucat -n -j off -i stereo.wav -C 0:0 -o left.wav -C 1:1 \ -o right.wav
SEE ALSO
audioctl(1), cdio(1), mixerctl(1), sndiod(1), audio(4), sndio(7)
BUGS
Resampling is low quality; down-sampling especially should be avoided when recording.
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.