version 1.93, 2011/11/15 09:07:45 |
version 1.94, 2011/12/09 14:36:42 |
|
|
.Dt AUCAT 1 |
.Dt AUCAT 1 |
.Os |
.Os |
.Sh NAME |
.Sh NAME |
.Nm aucat |
.Nm aucat , |
|
.Nm sndiod |
.Nd audio/MIDI server and stream manipulation tool |
.Nd audio/MIDI server and stream manipulation tool |
.Sh SYNOPSIS |
.Sh SYNOPSIS |
.Nm aucat |
.Nm aucat |
.Bk -words |
.Bk -words |
.Op Fl dlMn |
.Op Fl dn |
.Op Fl a Ar flag |
|
.Op Fl b Ar nframes |
.Op Fl b Ar nframes |
.Op Fl C Ar min : Ns Ar max |
.Op Fl C Ar min : Ns Ar max |
.Op Fl c Ar min : Ns Ar max |
.Op Fl c Ar min : Ns Ar max |
|
|
.Op Fl h Ar fmt |
.Op Fl h Ar fmt |
.Op Fl i Ar file |
.Op Fl i Ar file |
.Op Fl j Ar flag |
.Op Fl j Ar flag |
.Op Fl L Ar addr |
|
.Op Fl m Ar mode |
.Op Fl m Ar mode |
.Op Fl o Ar file |
.Op Fl o Ar file |
.Op Fl q Ar port |
.Op Fl q Ar port |
.Op Fl r Ar rate |
.Op Fl r Ar rate |
|
.Op Fl t Ar mode |
|
.Op Fl v Ar volume |
|
.Op Fl w Ar flag |
|
.Op Fl x Ar policy |
|
.Op Fl z Ar nframes |
|
.Ek |
|
.Nm sndiod |
|
.Bk -words |
|
.Op Fl dM |
|
.Op Fl a Ar flag |
|
.Op Fl b Ar nframes |
|
.Op Fl C Ar min : Ns Ar max |
|
.Op Fl c Ar min : Ns Ar max |
|
.Op Fl e Ar enc |
|
.Op Fl f Ar device |
|
.Op Fl j Ar flag |
|
.Op Fl L Ar addr |
|
.Op Fl m Ar mode |
|
.Op Fl q Ar port |
|
.Op Fl r Ar rate |
.Op Fl s Ar name |
.Op Fl s Ar name |
.Op Fl t Ar mode |
.Op Fl t Ar mode |
.Op Fl U Ar unit |
.Op Fl U Ar unit |
|
|
.Nm |
.Nm |
is an audio utility which can simultaneously play and record |
is an audio utility which can simultaneously play and record |
any number of audio |
any number of audio |
.Em streams |
.Em streams , |
on any number of audio devices, |
|
possibly controlled through MIDI. |
possibly controlled through MIDI. |
It can also act as an audio server, in which case streams |
|
correspond to client connections rather than plain files. |
|
.Pp |
|
Audio devices are independent. |
|
A list of streams is attached to each audio device, |
|
as well as an optional list of MIDI ports to control the device. |
|
A typical invocation of |
A typical invocation of |
.Nm |
.Nm |
consists in providing streams to play and record, |
consists in providing streams to play and record, |
and possibly the audio device to use, if the default is not desired. |
and possibly the audio device to use. |
.Pp |
.Pp |
This also applies to server mode, except that streams are created |
The |
|
.Nm sndiod |
|
daemon acts as an audio server. |
|
Its functionality is identical to |
|
.Nm aucat , |
|
except that streams are created |
dynamically when clients connect to the server. |
dynamically when clients connect to the server. |
Thus, instead of actual streams (paths to plain files), |
Thus, instead of actual streams (paths to plain files), |
templates for client streams (sub-device names) must be provided. |
templates for client streams (sub-device names) must be provided. |
|
Multiple independent audio devices are supported, |
|
each has its own list of streams and MIDI control ports. |
.Pp |
.Pp |
The options are as follows: |
The options are as follows: |
.Bl -tag -width Ds |
.Bl -tag -width Ds |
.It Fl a Ar flag |
.It Fl a Ar flag |
Control whether |
Control whether |
.Nm |
.Nm sndiod |
opens the audio device only when needed or keeps it open all the time. |
opens the audio device only when needed or keeps it open all the time. |
This applies to MIDI ports controlling the device as well. |
This applies to MIDI ports controlling the device as well. |
If the flag is |
If the flag is |
|
|
The default is 0:1, i.e. stereo. |
The default is 0:1, i.e. stereo. |
.It Fl d |
.It Fl d |
Increase log verbosity. |
Increase log verbosity. |
.Nm |
.Nm sndiod |
logs on |
logs on |
.Em stderr |
.Em stderr |
until it daemonizes. |
until it daemonizes. |
|
|
The default is |
The default is |
.Ar on . |
.Ar on . |
.It Fl L Ar addr |
.It Fl L Ar addr |
Specify a local network address to listen on in server mode. |
Specify a local network address |
.Nm |
.Nm sndiod |
|
should listen; |
|
.Nm sndiod |
will listen on TCP port 11025+n, where n is the unit number |
will listen on TCP port 11025+n, where n is the unit number |
specified with |
specified with |
.Fl U . |
.Fl U . |
Without this option, |
Without this option, |
.Nm |
.Nm sndiod |
listens on the |
listens on the |
.Ux Ns -domain |
.Ux Ns -domain |
socket only, and is not reachable from any network. |
socket only, and is not reachable from any network. |
If the option argument is |
If the option argument is |
.Sq - |
.Sq - |
then |
then |
.Nm |
.Nm sndiod |
will accept connections from any address. |
will accept connections from any address. |
.It Fl l |
|
Detach and become a daemon. |
|
.It Fl M |
.It Fl M |
Create a MIDI thru box |
Create a MIDI thru box |
.Pq i.e. MIDI-only pseudo device . |
.Pq i.e. MIDI-only pseudo device . |
|
|
.Fl m Ar midi |
.Fl m Ar midi |
.Pc |
.Pc |
can be attached to it. |
can be attached to it. |
If sub-devices are exposed |
Exposed sub-devices by |
.Pq Fl s |
.Nm sndiod |
they behave like software MIDI ports, |
behave like software MIDI ports, |
allowing any MIDI-capable application to send MIDI messages to |
allowing any MIDI-capable application to send MIDI messages to |
MIDI hardware or to another application in a uniform way. |
MIDI hardware or to another application in a uniform way. |
.It Fl m Ar mode |
.It Fl m Ar mode |
|
|
.Pq Fl i |
.Pq Fl i |
and one output |
and one output |
.Pq Fl o . |
.Pq Fl o . |
It doesn't support MIDI control |
|
.Pq Fl q |
|
and can't expose sub-devices |
|
.Pq Fl s . |
|
.It Fl o Ar file |
.It Fl o Ar file |
Add this file to the list of recording streams. |
Add this file to the list of recording streams. |
If the option argument is |
If the option argument is |
|
|
.It Fl s Ar name |
.It Fl s Ar name |
Add |
Add |
.Ar name |
.Ar name |
to the list of sub-devices to expose in server mode. |
to the list of sub-devices to expose. |
This allows clients to use |
This allows clients to use |
.Nm |
.Nm sndiod |
instead of the physical audio device for audio input and output |
instead of the physical audio device for audio input and output |
in order to share the physical device with other clients. |
in order to share the physical device with other clients. |
Defining multiple sub-devices allows splitting a physical audio device |
Defining multiple sub-devices allows splitting a physical audio device |
|
|
.It Fl U Ar unit |
.It Fl U Ar unit |
Unit number to use when running in server mode. |
Unit number to use when running in server mode. |
Each |
Each |
.Nm |
.Nm sndiod |
server instance has an unique unit number, |
server instance has an unique unit number, |
used in |
used in |
.Xr sndio 7 |
.Xr sndio 7 |
device names. |
device names. |
The default is 0. |
The default is 0. |
The unit number must be set before any server-specific |
The unit number must be set before any |
options are used |
.Fl L |
.Pq Fl Ls . |
is used. |
.It Fl v Ar volume |
.It Fl v Ar volume |
Software volume attenuation of the playback stream. |
Software volume attenuation of the playback stream. |
The value must be between 1 and 127, |
The value must be between 1 and 127, |
|
|
.It Fl w Ar flag |
.It Fl w Ar flag |
Control |
Control |
.Nm |
.Nm |
|
and |
|
.Nm sndiod |
behaviour when the maximum volume of the hardware is reached |
behaviour when the maximum volume of the hardware is reached |
and a new stream is connected. |
and a new stream is connected. |
This happens only when stream volumes |
This happens only when stream volumes |
|
|
must follow the definition of the device |
must follow the definition of the device |
.Pq Fl fMn |
.Pq Fl fMn |
to which they are attached. |
to which they are attached. |
Global parameters |
|
.Pq Fl dl |
|
are position-independent. |
|
.Pp |
.Pp |
If no audio devices |
If no audio devices |
.Pq Fl fMn |
.Pq Fl fMn |
are specified, |
are specified, |
settings are applied as if |
settings are applied as if |
the default device is specified. |
the default device is specified. |
If no streams |
If no |
.Pq Fl ios |
.Nm sndiod |
|
sub-devices |
|
.Pq Fl s |
are specified for a device, a default server sub-device is |
are specified for a device, a default server sub-device is |
created attached to it, meaning that |
created attached to it. |
.Nm |
|
behaves as an audio server. |
|
If a device |
If a device |
.Pq Fl fMn |
.Pq Fl fMn |
is defined twice, both definitions are merged: |
is defined twice, both definitions are merged: |
|
|
of both definitions are created. |
of both definitions are created. |
The default |
The default |
.Xr sndio 7 |
.Xr sndio 7 |
device is |
device used by |
.Pa snd/0 |
.Nm sndiod |
.Pq also known as Pa snd/0.default . |
is |
|
.Pa rsnd/0 , |
|
and the default sub-device exposed by |
|
.Nm sndiod |
|
is |
|
.Pa snd/0 . |
.Pp |
.Pp |
If |
If |
.Nm |
.Nm sndiod |
|
or |
|
.Nm aucat |
is sent |
is sent |
.Dv SIGHUP , |
.Dv SIGHUP , |
.Dv SIGINT |
.Dv SIGINT |
|
|
unsigned 18-bit, packed in 3 bytes, big endian |
unsigned 18-bit, packed in 3 bytes, big endian |
.El |
.El |
.Sh SERVER MODE |
.Sh SERVER MODE |
If at least one sub-device |
.Nm sndiod |
.Pq Fl s |
can be used |
is exposed by |
|
.Nm , |
|
including the case when no stream options are given, |
|
then |
|
.Nm |
|
can be used as a server |
|
to overcome hardware limitations and allow applications |
to overcome hardware limitations and allow applications |
to run on fixed sample rate devices or on devices |
to run on fixed sample rate devices or on devices |
supporting only unusual encodings. |
supporting only unusual encodings. |
|
|
.Pq Fl q |
.Pq Fl q |
and allows audio device properties to be controlled |
and allows audio device properties to be controlled |
through MIDI. |
through MIDI. |
If running in server mode |
Additionally, |
.Nm |
.Nm sndiod |
creates a MIDI port with the same name as the default audio |
creates a MIDI port with the same name as the exposed audio |
device to which MIDI programs can connect. |
sub-device to which MIDI programs can connect. |
.Pp |
.Pp |
A MIDI channel is assigned to each stream, and the volume |
A MIDI channel is assigned to each stream, and the volume |
is changed using the standard volume controller (number 7). |
is changed using the standard volume controller (number 7). |
|
|
and recording must start. |
and recording must start. |
If the requested position is beyond the end of file, |
If the requested position is beyond the end of file, |
the stream is temporarly disabled until a valid position is requested. |
the stream is temporarly disabled until a valid position is requested. |
This message is ignored by client streams (server mode). |
This message is ignored by audio |
The given time position is sent to MIDI ports as an MTC |
.Nm sndiod |
|
clients, but the given time position is sent to MIDI ports as an MTC |
.Dq "full frame" |
.Dq "full frame" |
message forcing all MTC-slaves to relocate to the given |
message forcing all MTC-slaves to relocate to the given |
position (see below). |
position (see below). |
.It start |
.It start |
Put all streams in starting mode. |
Put all streams in starting mode. |
In this mode, |
In this mode, |
.Nm |
.Nm sndiod |
|
or |
|
.Nm aucat |
waits for all streams to become ready |
waits for all streams to become ready |
to start, and then starts them synchronously. |
to start, and then starts them synchronously. |
Once started, new streams can be created (server mode) |
Once started, new streams can be created |
|
.Pq Nm sndiod |
but they will be blocked |
but they will be blocked |
until the next stop-to-start transition. |
until the next stop-to-start transition. |
.It stop |
.It stop |
Put all streams in stopped mode (the default). |
Put all streams in stopped mode (the default). |
In this mode, any stream attempting to start playback or recording |
In this mode, any stream attempting to start playback or recording |
is paused. |
is paused. |
Files are stopped and rewound back to the starting position, |
Files |
while client streams (server mode) that are already |
.Pq Nm aucat |
|
are stopped and rewound back to the starting position, |
|
while client streams |
|
.Pq Nm sndiod |
|
that are already |
started are not affected until they stop and try to start again. |
started are not affected until they stop and try to start again. |
.El |
.El |
.Pp |
.Pp |
Streams created with the |
Streams created with the |
.Fl t |
.Fl t |
option export the server clock using MTC, allowing non-audio |
option export the |
|
.Nm sndiod |
|
device clock using MTC, allowing non-audio |
software or hardware to be synchronized to the audio stream. |
software or hardware to be synchronized to the audio stream. |
Maximum accuracy is achieved when the number of blocks per |
Maximum accuracy is achieved when the number of blocks per |
second is equal to one of the standard MTC clock rates (96, 100 and 120Hz). |
second is equal to one of the standard MTC clock rates (96, 100 and 120Hz). |
|
|
and a MIDI-controlled |
and a MIDI-controlled |
.Va snd/0.mmc : |
.Va snd/0.mmc : |
.Bd -literal -offset indent |
.Bd -literal -offset indent |
$ aucat -l -r 48000 -z 400 -s default -t slave -s mmc |
$ sndiod -r 48000 -z 400 -s default -t slave -s mmc |
.Ed |
.Ed |
.Pp |
.Pp |
Streams connected to |
Streams connected to |
|
|
-o right.wav |
-o right.wav |
.Ed |
.Ed |
.Pp |
.Pp |
Start |
Start server using default parameters, creating an |
.Nm |
|
in server mode using default parameters, creating an |
|
additional sub-device for output to channels 2:3 only (rear speakers |
additional sub-device for output to channels 2:3 only (rear speakers |
on most cards), exposing the |
on most cards), exposing the |
.Pa snd/0 |
.Pa snd/0 |
|
|
.Pa snd/0.rear |
.Pa snd/0.rear |
devices: |
devices: |
.Bd -literal -offset indent |
.Bd -literal -offset indent |
$ aucat -l -s default -c 2:3 -s rear |
$ sndiod -s default -c 2:3 -s rear |
.Ed |
.Ed |
.Pp |
.Pp |
Start |
Start server creating the default sub-device with low volume and |
.Nm |
|
in server mode, creating the default sub-device with low volume and |
|
an additional sub-device for high volume output, exposing the |
an additional sub-device for high volume output, exposing the |
.Pa snd/0 |
.Pa snd/0 |
and |
and |
.Pa snd/0.max |
.Pa snd/0.max |
devices: |
devices: |
.Bd -literal -offset indent |
.Bd -literal -offset indent |
$ aucat -l -v 65 -s default -v 127 -s max |
$ sndiod -v 65 -s default -v 127 -s max |
.Ed |
.Ed |
.Pp |
.Pp |
Start |
Start server configuring the audio device to use |
.Nm |
|
in server mode, configuring the audio device to use |
|
a 48kHz sample frequency, 240-frame block size, |
a 48kHz sample frequency, 240-frame block size, |
and 2-block buffers. |
and 2-block buffers. |
The corresponding latency is 10ms, which is |
The corresponding latency is 10ms, which is |
the time it takes the sound to propagate 3.5 meters. |
the time it takes the sound to propagate 3.5 meters. |
.Bd -literal -offset indent |
.Bd -literal -offset indent |
$ aucat -l -r 48000 -b 480 -z 240 |
$ sndiod -r 48000 -b 480 -z 240 |
.Ed |
.Ed |
.Sh SEE ALSO |
.Sh SEE ALSO |
.Xr audioctl 1 , |
.Xr audioctl 1 , |
|
|
It will not work reliably on files that may block |
It will not work reliably on files that may block |
(ordinary files block, pipes don't). |
(ordinary files block, pipes don't). |
To avoid audio underruns/overruns or MIDI jitter caused by file I/O, |
To avoid audio underruns/overruns or MIDI jitter caused by file I/O, |
it's recommended to use two |
it's recommended to use two processes: a |
|
.Nm sndiod |
|
server handling audio and MIDI I/O and a |
.Nm |
.Nm |
processes: a server handling audio and MIDI I/O and a client handling |
client handling disk I/O. |
disk I/O. |
|
.Pp |
.Pp |
Resampling is low quality; down-sampling especially should be avoided |
Resampling is low quality; down-sampling especially should be avoided |
when recording. |
when recording. |
|
|
.Pp |
.Pp |
If |
If |
.Fl a Ar off |
.Fl a Ar off |
is used in server mode, |
is used, |
.Nm |
.Nm sndiod |
creates sub-devices to expose first |
creates sub-devices to expose first |
and then opens the audio hardware on demand. |
and then opens the audio hardware on demand. |
Technically, this allows |
Technically, this allows |
.Nm |
.Nm sndiod |
to attempt to use one of the sub-devices it exposes as an audio device, |
to attempt to use one of the sub-devices it exposes as an audio device, |
creating a deadlock. |
creating a deadlock. |
To avoid this, |
To avoid this, |