xref: /netbsd-src/share/man/man4/audio.4 (revision bdc22b2e01993381dcefeff2bc9b56ca75a4235c)
1.\"	$NetBSD: audio.4,v 1.86 2018/05/28 00:18:05 nat Exp $
2.\"
3.\" Copyright (c) 1996 The NetBSD Foundation, Inc.
4.\" All rights reserved.
5.\"
6.\" This code is derived from software contributed to The NetBSD Foundation
7.\" by John T. Kohl.
8.\"
9.\" Redistribution and use in source and binary forms, with or without
10.\" modification, are permitted provided that the following conditions
11.\" are met:
12.\" 1. Redistributions of source code must retain the above copyright
13.\"    notice, this list of conditions and the following disclaimer.
14.\" 2. Redistributions in binary form must reproduce the above copyright
15.\"    notice, this list of conditions and the following disclaimer in the
16.\"    documentation and/or other materials provided with the distribution.
17.\"
18.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
19.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
20.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
21.\" PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
22.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28.\" POSSIBILITY OF SUCH DAMAGE.
29.\"
30.Dd May 15, 2018
31.Dt AUDIO 4
32.Os
33.Sh NAME
34.Nm audio
35.Nd device-independent audio driver layer
36.Sh SYNOPSIS
37.In sys/audioio.h
38.Sh DESCRIPTION
39The
40.Nm
41driver provides support for various audio peripherals.
42It provides a uniform programming interface layer above different
43underlying audio hardware drivers.
44The audio layer provides full-duplex operation if the
45underlying hardware configuration supports it.
46.Pp
47There are four device files available for audio operation:
48.Pa /dev/audio ,
49.Pa /dev/sound ,
50.Pa /dev/audioctl ,
51and
52.Pa /dev/mixer .
53.Pp
54.Pa /dev/audio
55and
56.Pa /dev/sound
57are used for recording or playback of digital samples.
58.Pp
59.Pa /dev/mixer
60is used to manipulate volume, recording source, or other audio mixer
61functions.
62.Pp
63.Pa /dev/audioctl
64accepts the same
65.Xr ioctl 2
66operations as
67.Pa /dev/sound ,
68but no other operations.
69.Pp
70.Pa /dev/sound
71and
72.Pa /dev/audio
73can be opened at
74.Em any
75time and audio sources of different precision and playback
76parameters i.e frequency will be mixed and played back simultaneously.
77.Pp
78.Pa /dev/audioctl
79can be used to manipulate the audio device
80while it is in use.
81.Sh SAMPLING DEVICES
82When
83.Pa /dev/audio
84is opened, it automatically directs the underlying driver to manipulate
85monaural 8-bit mu-law samples.
86In addition, if it is opened read-only
87(write-only) the device is set to half-duplex record (play) mode with
88recording (playing) unpaused and playing (recording) paused.
89When
90.Pa /dev/sound
91is opened, it maintains the previous audio sample mode and
92record/playback mode most recently set on
93.Pa /dev/sound
94by any open channel.
95In all other respects
96.Pa /dev/audio
97and
98.Pa /dev/sound
99are identical.
100.Sh VIRTUAL CHANNELS
101Any process may open a sampling device at a given time.
102Any number of devices per process and file descriptors may be shared between
103processes.
104.Pp
105Virtual channels are converted to a common format, signed linear encoding,
106frequency channels and precision.
107These can be modified to taste by the following
108.Xr sysctl 8
109variables:
110.Bl -tag -width "hw.driverN.precision" -compact -offset indent
111.It Li hw. Ns Ar driverN Ns Li .precision
112.It Li hw. Ns Ar driverN Ns Li .frequency
113.It Li hw. Ns Ar driverN Ns Li .channels
114.It Li hw. Ns Ar driverN Ns Li .latency
115.It Li hw. Ns Ar driverN Ns Li .multiuser
116.El
117.Pp
118Where
119.Ar driverN
120corresponds to the underlying audio device driver and device number.
121E.g. in the case of an
122.\" XXX: there's no hdafg(4) to xref to
123.Xr hdaudio 4
124supported device the variables would be:
125.Li hw.hdafg0.channels ,
126.Li hw.hdafg0.precision ,
127.Li hw.hdafg0.frequency .
128.Pp
129For best results, values close to the underlying hardware should be chosen.
130These variables may only be changed when the sampling device is not in use.
131.Pp
132The
133.Li hw. Ns Ar driverN Ns Li .latency
134.Xr sysctl 8
135variable controls the latency of the in-kernel mixer by varying the hardware
136blocksize.
137It accepts a value in milliseconds(ms), fractional values are not allowed.
138A value of zero will default to 150ms.
139.Pp
140If a static blocksize is enforced by the underlying hardware driver this value
141cannot be changed.
142.Pp
143For audio applications that do not specify a preferred blocksize when configuring
144the audio device, this will be the latency these applications have.
145.Pp
146For audio applications that
147.Xr mmap 2
148the audio device for play back the resultant latency is a third (1/3) of the value
149of the
150.Li hw. Ns Ar driverN Ns Li .latency
151variable.
152.Pp
153The
154.Li hw. Ns Ar driverN Ns Li .multiuser
155.Xr sysctl 8
156variable determines if multiple users are allowed to access the sampling
157device.
158.Pp
159By default it is set to false.
160This means that the sampling device may be only used by
161.Em one
162user at a time.
163Other users (except root) attempting to open the sampling device will be
164denied.
165.Pp
166If set to true, all users may access the sampling device at any time.
167.Pp
168Each virtual channel has a corresponding mixer:
169.Bl -tag -width "vchan.dacN" -compact -offset indent
170.It Li vchan.dac Ns Ar N
171Output volume
172.It Li vchan.mic Ns Ar N
173Recording volume
174.El
175.Pp
176Where
177.Ar N
178is the virtual channel number.
179E.g.\&
180.Li vchan.dac0
181controlling playback volume and
182.Li vchan.mic0
183controlling recording volume for the first virtual channel.
184.Pp
185On a half-duplex device, writes while recording is in progress will be
186immediately discarded.
187Similarly, reads while playback is in progress
188will be filled with silence but delayed to return at the current
189sampling rate.
190If both playback and recording are requested on a half-duplex
191device, playback mode takes precedence and recordings will get silence.
192.Pp
193On a full-duplex device, reads and writes may operate
194concurrently without interference.
195If a full-duplex capable audio device is opened for both reading and writing
196it will start in half-duplex play mode; full-duplex mode has to be set
197explicitly.
198.Pp
199On either type of device, if the playback mode is paused then silence is
200played instead of the provided samples, and if recording is paused then
201the process blocks in
202.Xr read 2
203until recording is unpaused.
204.Pp
205If a writing process does not call
206.Xr write 2
207frequently enough to provide samples at the pace the hardware
208consumes them silence is inserted.
209If the
210.Dv AUMODE_PLAY_ALL
211mode is not set the writing process must
212provide enough data via
213subsequent write calls to
214.Dq catch up
215in time to the current audio
216block before any more process-provided samples will be played.
217If a reading process does not call
218.Xr read 2
219frequently enough, it will simply miss samples.
220.Pp
221The audio device is normally accessed with
222.Xr read 2
223or
224.Xr write 2
225calls, but it can also be mapped into user memory with
226.Xr mmap 2
227Once the device has been mapped it can no longer be accessed
228by read or write; all access is by reading and writing to
229the mapped memory.
230The device appears as a block of memory
231of size
232.Va buffersize
233(as available via
234.Dv AUDIO_GETINFO
235or
236.Dv AUDIO_GETBUFINFO ) .
237The device driver will continuously move data from this buffer
238from/to the audio hardware, wrapping around at the end of the buffer.
239To find out where the hardware is currently accessing data in the buffer the
240.Dv AUDIO_GETIOFFS
241and
242.Dv AUDIO_GETOOFFS
243calls can be used.
244The playing and recording buffers are distinct and must be
245mapped separately if both are to be used.
246Only encodings that are not emulated (i.e. where
247.Dv AUDIO_ENCODINGFLAG_EMULATED
248is not set) work properly for a mapped device.
249.Pp
250The audio device, like most devices, can be used in
251.Xr select 2 ,
252can be set in non-blocking mode and can be set (with a
253.Dv FIOASYNC
254ioctl) to send a
255.Dv SIGIO
256when I/O is possible.
257The mixer device can be set to generate a
258.Dv SIGIO
259whenever a mixer value is changed.
260.Pp
261The following
262.Xr ioctl 2
263commands are supported on the sample devices:
264.Bl -tag -width indent
265.It Dv AUDIO_GETCHAN (int)
266This command will return the audio channel in use.
267.It Dv AUDIO_SETCHAN (int)
268This command will select the audio channel for subsequent ioctl calls.
269.It Dv AUDIO_FLUSH
270This command stops all playback and recording, clears all queued
271buffers, resets error counters, and restarts recording and playback as
272appropriate for the current sampling mode.
273.It Dv AUDIO_RERROR (int)
274This command fetches the count of dropped input samples into its integer
275argument.
276There is no information regarding when in the sample stream
277they were dropped.
278.It Dv AUDIO_WSEEK (u_long)
279This command fetches the count of samples that are queued ahead of the
280first sample in the most recent sample block written into its integer argument.
281.It Dv AUDIO_DRAIN
282This command suspends the calling process until all queued playback
283samples have been played by the hardware.
284.It Dv AUDIO_GETDEV (audio_device_t)
285This command fetches the current hardware device information into the
286.Vt audio_device_t
287argument.
288.Bd -literal
289typedef struct audio_device {
290        char name[MAX_AUDIO_DEV_LEN];
291        char version[MAX_AUDIO_DEV_LEN];
292        char config[MAX_AUDIO_DEV_LEN];
293} audio_device_t;
294.Ed
295.It Dv AUDIO_GETFD (int)
296The command returns the current setting of the full duplex mode.
297.It Dv AUDIO_GETENC (audio_encoding_t)
298This command is used iteratively to fetch sample encoding names and
299format ids into the input/output audio_encoding_t argument.
300.Bd -literal
301typedef struct audio_encoding {
302	int index;      /* input: nth encoding */
303	char name[MAX_AUDIO_DEV_LEN]; /* name of encoding */
304	int encoding;   /* value for encoding parameter */
305	int precision;  /* value for precision parameter */
306	int flags;
307#define AUDIO_ENCODINGFLAG_EMULATED 1 /* software emulation mode */
308} audio_encoding_t;
309.Ed
310.Pp
311To query
312all the supported encodings, start with an index field of 0 and
313continue with successive encodings (1, 2, ...) until the command returns
314an error.
315.It Dv AUDIO_SETFD (int)
316This command sets the device into full-duplex operation if its integer
317argument has a non-zero value, or into half-duplex operation if it
318contains a zero value.
319If the device does not support full-duplex
320operation, attempting to set full-duplex mode returns an error.
321.It Dv AUDIO_GETPROPS (int)
322This command gets a bit set of hardware properties.
323If the hardware
324has a certain property the corresponding bit is set, otherwise it is not.
325The properties can have the following values:
326.Pp
327.Bl -tag -width AUDIO_PROP_INDEPENDENT -compact
328.It Dv AUDIO_PROP_FULLDUPLEX
329the device admits full duplex operation.
330.It Dv AUDIO_PROP_MMAP
331the device can be used with
332.Xr mmap 2 .
333.It Dv AUDIO_PROP_INDEPENDENT
334the device can set the playing and recording encoding parameters
335independently.
336.It Dv AUDIO_PROP_PLAYBACK
337the device is capable of audio playback.
338.It Dv AUDIO_PROP_CAPTURE
339the device is capable of audio capture.
340.El
341.It Dv AUDIO_GETIOFFS (audio_offset_t)
342.It Dv AUDIO_GETOOFFS (audio_offset_t)
343This command fetches the current offset in the input(output) buffer where
344the audio hardware's DMA engine will be putting(getting) data.
345It mostly useful when the device
346buffer is available in user space via the
347.Xr mmap 2
348call.
349The information is returned in the
350.Vt audio_offset_t
351structure.
352.Bd -literal
353typedef struct audio_offset {
354	u_int	samples;   /* Total number of bytes transferred */
355	u_int	deltablks; /* Blocks transferred since last checked */
356	u_int	offset;    /* Physical transfer offset in buffer */
357} audio_offset_t;
358.Ed
359.It Dv AUDIO_GETINFO (audio_info_t)
360.It Dv AUDIO_GETBUFINFO (audio_info_t)
361.It Dv AUDIO_SETINFO (audio_info_t)
362Get or set audio information as encoded in the audio_info structure.
363.Bd -literal
364typedef struct audio_info {
365	struct	audio_prinfo play;   /* info for play (output) side */
366	struct	audio_prinfo record; /* info for record (input) side */
367        u_int	monitor_gain;			/* input to output mix */
368	/* BSD extensions */
369	u_int	blocksize;	/* H/W read/write block size */
370	u_int	hiwat;		/* output high water mark */
371	u_int	lowat;		/* output low water mark */
372	u_int	_ispare1;
373	u_int	mode;		/* current device mode */
374#define AUMODE_PLAY	0x01
375#define AUMODE_RECORD	0x02
376#define AUMODE_PLAY_ALL 0x04	/* do not do real-time correction */
377} audio_info_t;
378.Ed
379.Pp
380When setting the current state with
381.Dv AUDIO_SETINFO ,
382the audio_info structure should first be initialized with
383.Li AUDIO_INITINFO(&info)
384and then the particular values to be changed should be set.
385This allows the audio driver to only set those things that you wish
386to change and eliminates the need to query the device with
387.Dv AUDIO_GETINFO
388or
389.Dv AUDIO_GETBUFINFO
390first.
391.Pp
392The
393.Va mode
394field should be set to
395.Dv AUMODE_PLAY ,
396.Dv AUMODE_RECORD ,
397.Dv AUMODE_PLAY_ALL ,
398or a bitwise OR combination of the three.
399Only full-duplex audio devices support
400simultaneous record and playback.
401.Pp
402.Va hiwat
403and
404.Va lowat
405are used to control write behavior.
406Writes to the audio devices will queue up blocks until the high-water
407mark is reached, at which point any more write calls will block
408until the queue is drained to the low-water mark.
409.Va hiwat
410and
411.Va lowat
412set those high- and low-water marks (in audio blocks).
413The default for
414.Va hiwat
415is the maximum value and for
416.Va lowat
41775% of
418.Va hiwat .
419.Pp
420.Va blocksize
421sets the current audio blocksize.
422The generic audio driver layer and the hardware driver have the
423opportunity to adjust this block size to get it within
424implementation-required limits.
425Upon return from an
426.Dv AUDIO_SETINFO
427call, the actual blocksize set is returned in this field.
428Normally the
429.Va blocksize
430is calculated to correspond to 50ms of sound and it is recalculated
431when the encoding parameter changes, but if the
432.Va blocksize
433is set explicitly this value becomes sticky, i.e. it remains
434even when the encoding is changed.
435The stickiness can be cleared by reopening the device or setting the
436.Va blocksize
437to 0.
438.Bd -literal
439struct audio_prinfo {
440	u_int	sample_rate;	/* sample rate in samples/s */
441	u_int	channels;	/* number of channels, usually 1 or 2 */
442	u_int	precision;	/* number of bits/sample */
443	u_int	encoding;	/* data encoding (AUDIO_ENCODING_* below) */
444	u_int	gain;		/* volume level */
445	u_int	port;		/* selected I/O port */
446	u_long	seek;		/* BSD extension */
447	u_int	avail_ports;	/* available I/O ports */
448	u_int	buffer_size;	/* total size audio buffer */
449	u_int	_ispare[1];
450	/* Current state of device: */
451	u_int	samples;	/* number of samples */
452	u_int	eof;		/* End Of File (zero-size writes) counter */
453	u_char	pause;		/* non-zero if paused, zero to resume */
454	u_char	error;		/* non-zero if underflow/overflow occurred */
455	u_char	waiting;	/* non-zero if another process hangs in open */
456	u_char	balance;	/* stereo channel balance */
457	u_char	cspare[2];
458	u_char	open;		/* non-zero if currently open */
459	u_char	active;		/* non-zero if I/O is currently active */
460};
461.Ed
462.Pp
463Note:  many hardware audio drivers require identical playback and
464recording sample rates, sample encodings, and channel counts.
465The playing information is always set last and will prevail on such hardware.
466If the hardware can handle different settings the
467.Dv AUDIO_PROP_INDEPENDENT
468property is set.
469.Pp
470The encoding parameter can have the following values:
471.Pp
472.Bl -tag -width AUDIO_ENCODING_SLINEAR_BE -compact
473.It Dv AUDIO_ENCODING_ULAW
474mu-law encoding, 8 bits/sample
475.It Dv AUDIO_ENCODING_ALAW
476A-law encoding, 8 bits/sample
477.It Dv AUDIO_ENCODING_SLINEAR
478two's complement signed linear encoding with the platform byte order
479.It Dv AUDIO_ENCODING_ULINEAR
480unsigned linear encoding
481with the platform byte order
482.It Dv AUDIO_ENCODING_ADPCM
483ADPCM encoding, 8 bits/sample
484.It Dv AUDIO_ENCODING_SLINEAR_LE
485two's complement signed linear encoding with little endian byte order
486.It Dv AUDIO_ENCODING_SLINEAR_BE
487two's complement signed linear encoding with big endian byte order
488.It Dv AUDIO_ENCODING_ULINEAR_LE
489unsigned linear encoding with little endian byte order
490.It Dv AUDIO_ENCODING_ULINEAR_BE
491unsigned linear encoding with big endian byte order
492.It Dv AUDIO_ENCODING_AC3
493Dolby Digital AC3
494.El
495.Pp
496The
497.Va gain ,
498.Va port
499and
500.Va balance
501settings provide simple shortcuts to the richer mixer
502interface described below and are not obtained by
503.Dv AUDIO_GETBUFINFO .
504The gain should be in the range
505.Bq Dv AUDIO_MIN_GAIN , Dv AUDIO_MAX_GAIN
506and the balance in the range
507.Bq Dv AUDIO_LEFT_BALANCE , Dv AUDIO_RIGHT_BALANCE
508with the normal setting at
509.Dv AUDIO_MID_BALANCE .
510.Pp
511The input port should be a combination of:
512.Pp
513.Bl -tag -width AUDIO_MICROPHONE -compact
514.It Dv AUDIO_MICROPHONE
515to select microphone input.
516.It Dv AUDIO_LINE_IN
517to select line input.
518.It Dv AUDIO_CD
519to select CD input.
520.El
521.Pp
522The output port should be a combination of:
523.Pp
524.Bl -tag -width AUDIO_HEADPHONE -compact
525.It Dv AUDIO_SPEAKER
526to select speaker output.
527.It Dv AUDIO_HEADPHONE
528to select headphone output.
529.It Dv AUDIO_LINE_OUT
530to select line output.
531.El
532.Pp
533The available ports can be found in
534.Va avail_ports
535.Dv ( AUDIO_GETBUFINFO
536only).
537.Pp
538.Va buffer_size
539is the total size of the audio buffer.
540The buffer size divided by the
541.Va blocksize
542gives the maximum value for
543.Va hiwat .
544Currently the
545.Va buffer_size
546can only be read and not set.
547.Pp
548The
549.Va seek
550and
551.Va samples
552fields are only used by
553.Dv AUDIO_GETINFO
554and
555.Dv AUDIO_GETBUFINFO .
556.Va seek
557represents the count of
558samples pending;
559.Va samples
560represents the total number of bytes recorded or played, less those
561that were dropped due to inadequate consumption/production rates.
562.Pp
563.Va pause
564returns the current pause/unpause state for recording or playback.
565For
566.Dv AUDIO_SETINFO ,
567if the pause value is specified it will either pause
568or unpause the particular direction.
569.El
570.Sh MIXER DEVICE
571The mixer device,
572.Pa /dev/mixer ,
573may be manipulated with
574.Xr ioctl 2
575but does not support
576.Xr read 2
577or
578.Xr write 2 .
579It supports the following
580.Xr ioctl 2
581commands:
582.Bl -tag -width indent
583.It Dv AUDIO_GETDEV (audio_device_t)
584This command is the same as described above for the sampling devices.
585.It Dv AUDIO_MIXER_READ (mixer_ctrl_t)
586.It Dv AUDIO_MIXER_WRITE (mixer_ctrl_t)
587These commands read the current mixer state or set new mixer state for
588the specified device
589.Va dev .
590.Va type
591identifies which type of value is supplied in the
592.Vt mixer_ctrl_t
593argument.
594.Bd -literal
595#define AUDIO_MIXER_CLASS  0
596#define AUDIO_MIXER_ENUM   1
597#define AUDIO_MIXER_SET    2
598#define AUDIO_MIXER_VALUE  3
599typedef struct mixer_ctrl {
600	int dev;			/* input: nth device */
601	int type;
602	union {
603		int ord;		/* enum */
604		int mask;		/* set */
605		mixer_level_t value;	/* value */
606	} un;
607} mixer_ctrl_t;
608
609#define AUDIO_MIN_GAIN  0
610#define AUDIO_MAX_GAIN  255
611typedef struct mixer_level {
612        int num_channels;
613        u_char level[8];               /* [num_channels] */
614} mixer_level_t;
615#define AUDIO_MIXER_LEVEL_MONO  0
616#define AUDIO_MIXER_LEVEL_LEFT  0
617#define AUDIO_MIXER_LEVEL_RIGHT 1
618.Ed
619.Pp
620For a mixer value, the
621.Va value
622field specifies both the number of channels and the values for each
623channel.
624If the channel count does not match the current channel count, the
625attempt to change the setting may fail (depending on the hardware
626device driver implementation).
627For an enumeration value, the
628.Va ord
629field should be set to one of the possible values as returned by a prior
630.Dv AUDIO_MIXER_DEVINFO
631command.
632The type
633.Dv AUDIO_MIXER_CLASS
634is only used for classifying particular mixer device
635types and is not used for
636.Dv AUDIO_MIXER_READ
637or
638.Dv AUDIO_MIXER_WRITE .
639.It Dv AUDIO_MIXER_DEVINFO (mixer_devinfo_t)
640This command is used iteratively to fetch audio mixer device information
641into the input/output
642.Vt mixer_devinfo_t
643argument.
644To query all the supported devices, start with an index field of
6450 and continue with successive devices (1, 2, ...) until the
646command returns an error.
647.Bd -literal
648typedef struct mixer_devinfo {
649	int index;		/* input: nth mixer device */
650	audio_mixer_name_t label;
651	int type;
652	int mixer_class;
653	int next, prev;
654#define AUDIO_MIXER_LAST	-1
655	union {
656		struct audio_mixer_enum {
657			int num_mem;
658			struct {
659				audio_mixer_name_t label;
660				int ord;
661			} member[32];
662		} e;
663		struct audio_mixer_set {
664			int num_mem;
665			struct {
666				audio_mixer_name_t label;
667				int mask;
668			} member[32];
669		} s;
670		struct audio_mixer_value {
671			audio_mixer_name_t units;
672			int num_channels;
673			int delta;
674		} v;
675	} un;
676} mixer_devinfo_t;
677.Ed
678.Pp
679The
680.Va label
681field identifies the name of this particular mixer control.
682The
683.Va index
684field may be used as the
685.Va dev
686field in
687.Dv AUDIO_MIXER_READ
688and
689.Dv AUDIO_MIXER_WRITE
690commands.
691The
692.Va type
693field identifies the type of this mixer control.
694Enumeration types are typically used for on/off style controls (e.g. a
695mute control) or for input/output device selection (e.g. select
696recording input source from CD, line in, or microphone).
697Set types are similar to enumeration types but any combination
698of the mask bits can be used.
699.Pp
700The
701.Va mixer_class
702field identifies what class of control this is.
703The
704.Pq arbitrary
705value set by the hardware driver may be determined by examining the
706.Va mixer_class
707field of the class itself,
708a mixer of type
709.Dv AUDIO_MIXER_CLASS .
710For example, a mixer controlling the input gain on the line in circuit
711would have a
712.Va mixer_class
713that matches an input class device with the name
714.Dq inputs
715.Dv ( AudioCinputs ) ,
716and would have a
717.Va label
718of
719.Dq line
720.Dv ( AudioNline ) .
721Mixer controls which control audio circuitry for a particular audio
722source (e.g. line-in, CD in, DAC output) are collected under the input class,
723while those which control all audio sources (e.g. master volume,
724equalization controls) are under the output class.
725Hardware devices capable of recording typically also have a record class,
726for controls that only affect recording,
727and also a monitor class.
728.Pp
729The
730.Va next
731and
732.Va prev
733may be used by the hardware device driver to provide hints for the next
734and previous devices in a related set (for example, the line in level
735control would have the line in mute as its
736.Dq next
737value).
738If there is no relevant next or previous value,
739.Dv AUDIO_MIXER_LAST
740is specified.
741.Pp
742For
743.Dv AUDIO_MIXER_ENUM
744mixer control types,
745the enumeration values and their corresponding names are filled in.
746For example, a mute control would return appropriate values paired with
747.Dv AudioNon
748and
749.Dv AudioNoff .
750For
751.Dv AUDIO_MIXER_VALUE
752and
753.Dv AUDIO_MIXER_SET
754mixer control types, the channel count is
755returned; the units name specifies what the level controls (typical
756values are
757.Dv AudioNvolume ,
758.Dv AudioNtreble ,
759.Dv AudioNbass ) .
760.\" For AUDIO_MIXER_SET mixer control types, what is what?
761.El
762.Pp
763By convention, all the mixer devices can be distinguished from other
764mixer controls because they use a name from one of the
765.Dv AudioC*
766string values.
767.Sh FILES
768.Bl -tag -width /dev/audioctl -compact
769.It Pa /dev/audio
770.It Pa /dev/audioctl
771.It Pa /dev/sound
772.It Pa /dev/mixer
773.El
774.Sh SEE ALSO
775.Xr audioctl 1 ,
776.Xr mixerctl 1 ,
777.Xr ioctl 2 ,
778.Xr ossaudio 3 ,
779.Xr midi 4 ,
780.Xr radio 4 ,
781.Xr sysctl 8
782.Ss ISA bus
783.Xr aria 4 ,
784.Xr ess 4 ,
785.Xr gus 4 ,
786.Xr guspnp 4 ,
787.Xr pas 4 ,
788.Xr sb 4 ,
789.Xr wss 4 ,
790.Xr ym 4
791.Ss PCI bus
792.Xr auacer 4 ,
793.Xr auich 4 ,
794.Xr auixp 4 ,
795.Xr autri 4 ,
796.Xr auvia 4 ,
797.Xr azalia 4 ,
798.Xr clcs 4 ,
799.Xr clct 4 ,
800.Xr cmpci 4 ,
801.Xr eap 4 ,
802.Xr emuxki 4 ,
803.Xr esa 4 ,
804.Xr esm 4 ,
805.Xr eso 4 ,
806.Xr fms 4 ,
807.Xr neo 4 ,
808.Xr sv 4 ,
809.Xr yds 4
810.Ss TURBOchannel
811.Xr bba 4
812.Ss USB
813.Xr uaudio 4
814.Ss The NetBSD audio specification
815.Xr audio_system 9
816.Sh HISTORY
817Support for virtual channels and mixing first appeared in
818.Nx 8.0 .
819