Chapter 11. Audio

Table of Contents

11.1. Configuring the audio device
11.2. Advanced commands
11.2.1. audioctl(1)
11.2.2. mixerctl(1)
11.2.3. audioplay(1)
11.2.4. audiorecord(1)

11.1. Configuring the audio device

audiocfg(1) can be used to list, test and set default audio devices.

All available audio devices can be listed with audiocfg list:

$ audiocfg list
0: [*] audio0 @ ausoc0: SUN50I Audio Ca, 2 playback channels
  • The first field (0) is the index that can be used with other audiocfg(1) commands

  • The second field ([*]) indicates if the audio device is currently the default ([*]) or not ([ ])

  • The third field (audio0) is the audio(4) device

  • The fourth field (ausoc0) is the hardware parent device

  • The fifth field (SUN50I Audio Ca) is the name of the device

  • The sixth field (2 in 2 playback channels) list the number of audio channels

audiocfg test index plays a tone of 2 seconds for each channel of the index device:

$ audiocfg test 0
0: [*] audio0 @ ausoc0: SUN50I Audio Ca, 2 playback channels
  testing channel 0... done
  testing channel 1... done

If more than an audio device is available audiocfg default index set it as the default one. Please note that unlike other audiocfg(1) commands audiocfg default needs to be run as root.

11.2. Advanced commands

NetBSD comes with a number of commands that deal with audio devices. They are:

11.2.1. audioctl(1)

audioctl(1) is used to manually set some variables regarding audio I/O, like the frequencies for playing and recording. The available parameters can be displayed with the following command:

# audioctl -a | more

For example, to listen to CD quality music you can use the following command.

# audioctl -w play=44100,2,16,slinear_le

This command sets the frequency to 44100Hz, 2 audio channels, 16 bit, slinear_le encoding.

You can see the supported encodings with:

# audioctl encodings

This command displays the list of all the encodings supported by the audio card on your system.

11.2.2. mixerctl(1)

This command is used to configure the audio mixing and has an interface similar to that of audioctl(1).

11.2.3. audioplay(1)

With this command you can play audio files in simple formats like ULAW and WAV. For more sophisticated needs you might want to install one of the many programs available in the package system which let you play audio files in different formats (e.g. MP3, etc.)

11.2.4. audiorecord(1)

Allows recording audio.