1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
|
.\" $OpenBSD: aucat.1,v 1.101 2012/04/25 07:18:45 jmc Exp $
.\"
.\" Copyright (c) 2006 Alexandre Ratchov <alex@caoua.org>
.\"
.\" Permission to use, copy, modify, and distribute this software for any
.\" purpose with or without fee is hereby granted, provided that the above
.\" copyright notice and this permission notice appear in all copies.
.\"
.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
.Dd $Mdocdate: April 25 2012 $
.Dt AUCAT 1
.Os
.Sh NAME
.Nm aucat ,
.Nm sndiod
.Nd audio/MIDI server and stream manipulation tool
.Sh SYNOPSIS
.Nm aucat
.Bk -words
.Op Fl dn
.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 h Ar fmt
.Op Fl i Ar file
.Op Fl j Ar flag
.Op Fl m Ar mode
.Op Fl o Ar file
.Op Fl q Ar port
.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 t Ar mode
.Op Fl U Ar unit
.Op Fl v Ar volume
.Op Fl w Ar flag
.Op Fl x Ar policy
.Op Fl z Ar nframes
.Ek
.Sh DESCRIPTION
The
.Nm sndiod
daemon is an intermediate layer between
audio or MIDI programs and the hardware.
It performs the necessary audio processing to
allow any program to work on any supported hardware.
By default,
.Nm sndiod
accepts connections from programs
running on the same system only;
it initializes only when programs are using its services,
allowing
.Nm sndiod
to consume a negligible amount of system resources the rest of the time.
Systems with no audio hardware can use
.Nm sndiod
to keep hot-pluggable devices usable by default at
virtually no cost.
.Pp
.Nm sndiod
operates as follows: it exposes at least one
.Em sub-device
that any number of audio programs can connect to and use as if it were
audio hardware.
During playback,
.Nm sndiod
receives audio data concurrently from all programs, mixes it and sends
the result to the hardware device.
Similarly, during recording it duplicates audio data recorded
from the device and sends it to all programs.
Since audio data flows through the
.Nm sndiod
process, it has the opportunity to process audio data on the fly:
.Pp
.Bl -bullet -offset indent -compact
.It
Change the sound encoding to overcome incompatibilities between
software and hardware.
.It
Route the sound from one channel to another,
join stereo or split mono.
.It
Control the per-application playback volume as well as the
master volume.
.It
Monitor the sound being played, allowing one program to record
what other programs play.
.El
.Pp
Processing is configured on a per sub-device basis, meaning that
the sound of all programs connected to the same sub-device will be
processed according to the same configuration.
Multiple sub-devices can be defined, allowing multiple configurations
to coexist.
The user selects the configuration a given program will use
by selecting the sub-device the program uses.
.Pp
.Nm sndiod
can expose a MIDI port that can be used as a MIDI thru box
(aka a
.Dq hub
for MIDI messages),
allowing any program to send MIDI messages to
MIDI hardware or to another program in a uniform way.
Hardware ports can be subscribed to such MIDI thru boxes,
allowing multiple programs to share the MIDI port.
.Pp
Finally,
.Nm sndiod
exposes a control MIDI port usable for:
.Pp
.Bl -bullet -offset indent -compact
.It
Volume control.
.It
Common clock source for audio and MIDI programs.
.It
Start, stop and relocate groups of audio programs.
.El
.Pp
The
.Nm
utility can play, record, mix, and convert regular audio files.
It has the same processing capabilities as
.Nm sndiod .
Both operate the same way, except that the former processes audio data stored
in files, while the latter processes audio data provided or consumed by
programs.
Instead of a list of sub-devices,
.Nm
is given a list of files to play or record.
.Pp
The options are as follows:
.Bl -tag -width Ds
.It Fl a Ar flag
Control whether
.Nm sndiod
opens the audio device only when needed or keeps it open all the time.
This applies to MIDI ports controlling the device as well.
If the flag is
.Va on
then the device is kept open all the time, ensuring no other program can
steal it.
If the flag is
.Va off ,
then it's automatically closed, allowing other programs to have direct
access to the device, or the device to be disconnected.
The default is
.Va off ,
except for the default device.
.It Fl b Ar nframes
The buffer size of the audio device in frames.
A frame consists of one sample for each channel in the stream.
This is the number of frames that will be buffered before being played
and thus controls the playback latency.
The default is 7680 or twice the block size
.Pq Fl z ,
if the block size is set.
.It Xo
.Fl C Ar min : Ns Ar max ,
.Fl c Ar min : Ns Ar max
.Xc
The range of stream channel numbers for recording and playback directions,
respectively.
The default is 0:1, i.e. stereo.
.It Fl d
Increase log verbosity.
.Nm sndiod
logs on
.Em stderr
until it daemonizes.
.It Fl e Ar enc
Encoding of the playback or recording stream (see below).
The default is signed, 16-bit, native byte order.
.It Fl f Ar device
Add this
.Xr sndio 7
audio device to devices used for playing and/or recording.
Preceding per-device options
.Pq Fl abwz
apply to this device.
Streams
.Pq Fl ios
and control MIDI ports
.Pq Fl q
that are applied after will be attached to this device.
Device mode and parameters are determined from streams
attached to it.
.It Fl h Ar fmt
File format of the playback or record stream (see below).
The default is auto.
.It Fl i Ar file
Add this file to the list of streams to play.
If the option argument is
.Sq -
then standard input will be used.
.It Fl j Ar 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
.Va off
then stream channels are routed to the corresponding
device channel, possibly discarding channels not present in the device.
If the flag is
.Va on ,
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 is
.Ar on .
.It Fl L Ar addr
Specify a local network address
.Nm sndiod
should listen;
.Nm sndiod
will listen on TCP port 11025+n, where n is the unit number
specified with
.Fl U .
Without this option,
.Nm sndiod
listens on the
.Ux Ns -domain
socket only, and is not reachable from any network.
If the option argument is
.Sq -
then
.Nm sndiod
will accept connections from any address.
.It Fl M
Create a MIDI thru box
.Pq 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
.Pq Fl q
and MIDI files
.Po
.Fl io
preceded by
.Fl m Ar midi
.Pc
can be attached to it.
Exposed sub-devices by
.Nm sndiod
behave like software MIDI ports,
allowing any MIDI-capable application to send MIDI messages to
MIDI hardware or to another application in a uniform way.
.It Fl m Ar mode
Set the stream mode.
Valid modes are
.Ar play ,
.Ar rec ,
.Ar mon ,
and
.Ar midi ,
corresponding to playback, recording, monitoring and MIDI control.
A monitoring stream is a fake recording stream corresponding to
the mix of all playback streams.
Multiple modes can be specified, separated by commas,
but the same stream cannot be used for both recording and monitoring.
The default is
.Ar play , Ns Ar rec , Ns Ar midi
(i.e. full-duplex with MIDI control enabled).
.It Fl 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
.Pq Fl i
and one output
.Pq Fl o .
.It Fl o Ar file
Add this file to the list of recording streams.
If the option argument is
.Sq -
then standard output will be used.
.It Fl q Ar port
Expose the audio device clock on this
.Xr sndio 7
MIDI port and allow audio device properties to be controlled
through MIDI.
This includes per-stream volumes and the ability to
synchronously start, stop and relocate streams created in
MIDI Machine
Control (MMC) slave mode
.Pq Fl t .
.It Fl r Ar rate
Sample rate in Hertz of the stream.
The default is 48000.
.It Fl s Ar name
Add
.Ar name
to the list of sub-devices to expose.
This allows clients to use
.Nm sndiod
instead of the physical audio device for audio input and output
in order to share the physical device with other clients.
Defining multiple sub-devices allows splitting a physical audio device
into logical devices having different properties (e.g. channel ranges).
The given
.Ar name
corresponds to the
.Dq option
part of the
.Xr sndio 7
device name string.
.It Fl t Ar mode
Select the way streams are controlled by MIDI Machine Control (MMC)
messages.
If the mode is
.Va off
(the default), then streams are not affected by MMC messages.
If the mode is
.Va slave ,
then streams are started synchronously by MMC start messages;
additionally, the server clock is exposed as MIDI Time Code (MTC)
messages allowing MTC-capable software or hardware to be synchronized
to audio streams.
.It Fl U Ar unit
Unit number to use when running in server mode.
Each
.Nm sndiod
server instance has an unique unit number,
used in
.Xr sndio 7
device names.
The default is 0.
The unit number must be set before any
.Fl L
is used.
.It Fl v Ar 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.
In server mode, clients inherit this parameter.
Reducing the volume in advance allows a client's volume to stay independent
from the number of clients as long as their number is small enough.
18 volume units (i.e. \-6dB attenuation) allows the number
of playback streams to be doubled.
The default is 127 i.e. no attenuation.
.It Fl w Ar flag
Control
.Nm
and
.Nm sndiod
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
.Fl v
option.
If the flag is
.Va on ,
then the master volume (corresponding to the mix of all playback streams)
is automatically adjusted to avoid clipping.
Using
.Va off
makes sense when all streams are recorded or produced with properly lowered
volumes.
The default is
.Va on .
.It Fl x Ar 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
.Dq ignore
(the default) then samples that cannot be written are discarded
and samples that cannot be read are replaced by silence.
If the policy is
.Dq sync
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 is
.Dq error
then the stream is closed permanently.
.Pp
If a stream is created with the
.Fl t
option,
the
.Dq ignore
action is disabled for any stream connected to it
to ensure proper synchronization.
.It Fl z Ar nframes
The audio device block size in frames.
This is the number of frames between audio clock ticks,
i.e. the clock resolution.
If a stream is created with the
.Fl t
option,
and MTC is used for synchronization, the clock
resolution must be 96, 100 or 120 ticks per second for maximum
accuracy.
For instance, 100 ticks per second at 48000Hz corresponds
to a 480 frame block size.
The default is 960 or half of the buffer size
.Pq Fl b ,
if the buffer size is set.
.El
.Pp
On the command line,
per-device parameters
.Pq Fl abwz
must precede the device definition
.Pq Fl fMn ,
and per-stream parameters
.Pq Fl Ccehjmrtvx
must precede the stream definition
.Pq Fl ios .
MIDI ports
.Pq Fl q
and stream definitions
.Pq Fl ios
must follow the definition of the device
.Pq Fl fMn
to which they are attached.
.Pp
If no audio devices
.Pq Fl fMn
are specified,
settings are applied as if
the default device is specified.
If no
.Nm sndiod
sub-devices
.Pq Fl s
are specified for a device, a default server sub-device is
created attached to it.
If a device
.Pq Fl fMn
is defined twice, both definitions are merged:
parameters of the first one are used but streams
.Pq Fl ios
and MIDI control ports
.Pq Fl q
of both definitions are created.
The default
.Xr sndio 7
device used by
.Nm sndiod
is
.Pa rsnd/0 ,
and the default sub-device exposed by
.Nm sndiod
is
.Pa snd/0 .
.Pp
If
.Nm sndiod
or
.Nm aucat
is sent
.Dv SIGHUP ,
.Dv SIGINT
or
.Dv SIGTERM ,
it terminates recording to files.
.Pp
File formats are specified using the
.Fl h
option.
The following file formats are supported:
.Bl -tag -width s32lexxx -offset indent
.It raw
Headerless file.
This format is recommended since it has no limitations.
.It 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
.Xr lseek 2
operation (e.g. pipes do not support it).
.It auto
Try to guess, depending on the file name.
.El
.Pp
Encodings are specified using the
.Fl e
option.
The following encodings are supported:
.Pp
.Bl -tag -width s32lexxx -offset indent -compact
.It s8
signed 8-bit
.It u8
unsigned 8-bit
.It s16le
signed 16-bit, little endian
.It u16le
unsigned 16-bit, little endian
.It s16be
signed 16-bit, big endian
.It u16be
unsigned 16-bit, big endian
.It s24le
signed 24-bit, stored in 4 bytes, little endian
.It u24le
unsigned 24-bit, stored in 4 bytes, little endian
.It s24be
signed 24-bit, stored in 4 bytes, big endian
.It u24be
unsigned 24-bit, stored in 4 bytes, big endian
.It s32le
signed 32-bit, little endian
.It u32le
unsigned 32-bit, little endian
.It s32be
signed 32-bit, big endian
.It u32be
unsigned 32-bit, big endian
.It s24le3
signed 24-bit, packed in 3 bytes, little endian
.It u24le3
unsigned 24-bit, packed in 3 bytes, big endian
.It s24be3
signed 24-bit, packed in 3 bytes, little endian
.It u24be3
unsigned 24-bit, packed in 3 bytes, big endian
.It s20le3
signed 20-bit, packed in 3 bytes, little endian
.It u20le3
unsigned 20-bit, packed in 3 bytes, big endian
.It s20be3
signed 20-bit, packed in 3 bytes, little endian
.It u20be3
unsigned 20-bit, packed in 3 bytes, big endian
.It s18le3
signed 18-bit, packed in 3 bytes, little endian
.It u18le3
unsigned 18-bit, packed in 3 bytes, big endian
.It s18be3
signed 18-bit, packed in 3 bytes, little endian
.It u18be3
unsigned 18-bit, packed in 3 bytes, big endian
.El
.Sh SERVER MODE
.Nm sndiod
can be used
to overcome hardware limitations and allow applications
to run on fixed sample rate devices or on devices
supporting only unusual encodings.
.Pp
Certain applications, such as synthesis software,
require a low latency audio setup.
To reduce the probability of buffer underruns or overruns, especially
on busy machines, the server can be started by the super-user, in which
case it will run with higher priority.
Any user will still be able to connect to it,
but for privacy reasons only one user may have
connections to it at a given time.
.Sh MIDI CONTROL
.Nm
can expose the audio device clock on registered
MIDI ports
.Pq Fl q
and allows audio device properties to be controlled
through MIDI.
Additionally,
.Nm sndiod
creates a MIDI port with the same name as the exposed audio
sub-device to which MIDI programs can connect.
.Pp
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.
.Pp
The master volume can be changed using the standard master volume
system exclusive message.
.Pp
Streams created with the
.Fl t
option are controlled by the following MMC messages:
.Bl -tag -width relocateXXX -offset indent
.It relocate
Streams are relocated to the requested time position
relative to the beginning of the stream, at which playback
and recording must start.
If the requested position is beyond the end of file,
the stream is temporarly disabled until a valid position is requested.
This message is ignored by audio
.Nm sndiod
clients, but the given time position is sent to MIDI ports as an MTC
.Dq "full frame"
message forcing all MTC-slaves to relocate to the given
position (see below).
.It start
Put all streams in starting mode.
In this mode,
.Nm sndiod
or
.Nm aucat
waits for all streams to become ready
to start, and then starts them synchronously.
Once started, new streams can be created
.Pq Nm sndiod
but they will be blocked
until the next stop-to-start transition.
.It stop
Put all streams in stopped mode (the default).
In this mode, any stream attempting to start playback or recording
is paused.
Files
.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.
.El
.Pp
Streams created with the
.Fl t
option export the
.Nm sndiod
device clock using MTC, allowing non-audio
software or hardware to be synchronized to the audio stream.
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).
The following sample rates
.Pq Fl r
and block sizes
.Pq Fl z
are recommended:
.Pp
.Bl -bullet -offset indent -compact
.It
44100Hz, 441 frames (MTC rate is 100Hz)
.It
48000Hz, 400 frames (MTC rate is 120Hz)
.It
48000Hz, 480 frames (MTC rate is 100Hz)
.It
48000Hz, 500 frames (MTC rate is 96Hz)
.El
.Pp
For instance, the following command will create two devices:
the default
.Va snd/0
and a MIDI-controlled
.Va snd/0.mmc :
.Bd -literal -offset indent
$ sndiod -r 48000 -z 400 -s default -t slave -s mmc
.Ed
.Pp
Streams connected to
.Va snd/0
behave normally, while streams connected to
.Va snd/0.mmc
wait for the MMC start signal and start synchronously.
Regardless of which device a stream is connected to,
its playback volume knob is exposed.
.Pp
For instance, the following command will play a file on the
.Va snd/0.mmc
audio device, and give full control to MIDI software or hardware
connected to the
.Va snd/0.thru
MIDI port:
.Bd -literal -offset indent
$ aucat -f snd/0.mmc -t slave -q midithru/0 -i file.wav
.Ed
.Pp
At this stage,
.Nm
will start, stop and relocate automatically following all user
actions in the MIDI sequencer.
Note that the sequencer must use
.Va snd/0
as the MTC source, i.e. the audio server, not the audio player.
.Sh ENVIRONMENT
.Bl -tag -width "AUCAT_COOKIE" -compact
.It Ev AUCAT_COOKIE
File containing user's session cookie.
.It Ev AUDIODEVICE
.Xr sndio 7
audio device to use if the
.Fl f
option is not specified.
.El
.Sh EXAMPLES
Mix and play two stereo streams,
the first at 48kHz and the second at 44.1kHz:
.Bd -literal -offset indent
$ aucat -r 48000 -i file1.raw -r 44100 -i file2.raw
.Ed
.Pp
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:
.Bd -literal -offset indent
$ aucat -j off -r 96000 -C 2:3 -o file1.raw -C 6:7 -o file2.raw
.Ed
.Pp
Split a stereo file into two mono files:
.Bd -literal -offset indent
$ aucat -n -j off -i stereo.wav -C 0:0 -o left.wav -C 1:1 \e
-o right.wav
.Ed
.Pp
Start server using default parameters, creating an
additional sub-device for output to channels 2:3 only (rear speakers
on most cards), exposing the
.Pa snd/0
and
.Pa snd/0.rear
devices:
.Bd -literal -offset indent
$ sndiod -s default -c 2:3 -s rear
.Ed
.Pp
Start server creating the default sub-device with low volume and
an additional sub-device for high volume output, exposing the
.Pa snd/0
and
.Pa snd/0.max
devices:
.Bd -literal -offset indent
$ sndiod -v 65 -s default -v 127 -s max
.Ed
.Pp
Start server configuring the audio device to use
a 48kHz sample frequency, 240-frame block size,
and 2-block buffers.
The corresponding latency is 10ms, which is
the time it takes the sound to propagate 3.5 meters.
.Bd -literal -offset indent
$ sndiod -r 48000 -b 480 -z 240
.Ed
.Sh SEE ALSO
.Xr audioctl 1 ,
.Xr cdio 1 ,
.Xr mixerctl 1 ,
.Xr audio 4 ,
.Xr sndio 7
.Sh BUGS
The
.Nm
utility assumes non-blocking I/O for input and output streams.
It will not work reliably on files that may block
(ordinary files block, pipes don't).
To avoid audio underruns/overruns or MIDI jitter caused by file I/O,
it's recommended to use two processes: a
.Nm sndiod
server handling audio and MIDI I/O and a
.Nm
client handling disk I/O.
.Pp
Resampling is low quality; down-sampling especially should be avoided
when recording.
.Pp
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.
.Pp
If
.Fl a Ar off
is used,
.Nm sndiod
creates sub-devices to expose first
and then opens the audio hardware on demand.
Technically, this allows
.Nm sndiod
to attempt to use one of the sub-devices it exposes as an audio device,
creating a deadlock.
To avoid this,
.Fl a Ar off
is disabled for the default audio device, but nothing prevents the user
from shooting himself in the foot by creating a similar deadlock.
.Pp
The ability to merge multiple inputs is provided to allow multiple
applications producing MIDI data to keep their connection open while
idling; it does not replace a fully featured MIDI merger.
|