Annotation of wikisrc/guide/audio.mdwn, revision 1.1

1.1     ! jdf         1: # Audio
        !             2: 
        !             3: This chapter is a short introduction to the usage of audio devices on NetBSD (who wants a dumb computer, anyway?).
        !             4: 
        !             5: ## Basic hardware elements
        !             6: 
        !             7: In order to make audio work on your system you must know what audio card is installed. Sadly it is often not enough to know the brand and model of the card, because many cards use chipsets manufactured from third parties. Therefore knowing the chipset installed on the audio card can sometimes be useful. The NetBSD kernel can recognize many chipsets and a quick look at `dmesg` is enough most of the time.
        !             8: 
        !             9: Therefore, type the following command:
        !            10: 
        !            11:     # dmesg | less
        !            12: 
        !            13: and look for the audio card and chipset. If you're lucky you won't need to do anything because NetBSD automatically detects and configures many audio cards.
        !            14: If you want to explicitly look for detected audio devices, you should watch out for strings like `audio` or `sound`. This might give you a clue about audio devices you don't know the name of.
        !            15: 
        !            16:     # dmesg | grep audio
        !            17:        # dmesg | grep sound
        !            18: 
        !            19: Sometimes audio doesn't work because the card is not supported or because you need to do some work in order for the card to be detected by NetBSD. Many audio cards are nowadays very cheap, and it is worth considering buying a different card, but before doing this you can try some simple steps to make the card work with NetBSD.
        !            20: 
        !            21: ## Supported audio cards
        !            22: 
        !            23: The number of supported sound cards is ever increasing. The main source for supported audio devices are the manpages. You should have a look at the drivers listed in the *SEE ALSO* section of [audio(4)](http://netbsd.gw.com/cgi-bin/man-cgi?audio+4+NetBSD-current).
        !            24: 
        !            25: ## BIOS settings
        !            26: 
        !            27: This section is useful only to the owners of i386 PCs; on other architectures (e.g. Amiga) there are no such features. The most important thing to determine in order to use the audio card with NetBSD is the type of bus supported by the card.
        !            28: 
        !            29: The most common interfaces are PCI, PCI Express and USB.
        !            30: 
        !            31: ### Note
        !            32: 
        !            33: On many systems everything works fine even if this option is enabled. This is highly system dependent.
        !            34: 
        !            35: ## Configuring the audio device
        !            36: 
        !            37: During the installation of NetBSD the devices are created in the `/dev` directory. We are primarily interested in:
        !            38: 
        !            39:  * `/dev/audio`  
        !            40:  * `/dev/sound`  
        !            41:  * `/dev/mixer`
        !            42: 
        !            43: If they are not present they can be created like this:
        !            44: 
        !            45:     # cd /dev
        !            46:     # ./MAKEDEV all
        !            47: 
        !            48: This command creates all devices, including the audio devices.
        !            49: 
        !            50: The audio card is now probably ready to be used without further work.
        !            51: 
        !            52: You can make a quick test whether output works by sending data to the device (`/dev/sound` or `/dev/audio`). You can send anything to it (e.g., take `/dev/urandom`), maybe a file, maybe even something useful (which might be indicated by the `.au` extension). Be sure to turn your speakers quiet, as it will result in noise!
        !            53: 
        !            54:     # cat /dev/urandom > /dev/audio
        !            55: 
        !            56: or
        !            57:     # cat /dev/urandom > /dev/sound
        !            58: 
        !            59: If you hear something it means that the card is supported by NetBSD and was recognized and configured by the kernel at boot; otherwise you must configure the kernel settings for the audio device installed on the system (assuming the card/chipset is supported.)
        !            60: 
        !            61: ## Multiple audio devices
        !            62: 
        !            63: Audio devices are enumerated, starting at 0. If you have multiple audio cards, you will want to switch between the audio devices. By default, `/dev/sound` and `/dev/audio` are symlinks pointing to `/dev/sound0` and `/dev/audio0` resp.
        !            64: Many applications provide an option to choose the audio device. But if you want to switch the default audio device, you have to change these symlinks. Assuming you want to use the second audio device (determining the numbers as described [[earlier|guide/audio#basic-hardware-elements]]), delete these two symlinks and replace them by the appropriate ones:
        !            65: 
        !            66:     # rm /dev/sound
        !            67:     # rm /dev/audio
        !            68:     # ln -s /dev/sound /dev/sound0
        !            69:     # ln -s /dev/audio /dev/audio0
        !            70: 
        !            71: ## Configuring the kernel audio devices
        !            72: 
        !            73: NetBSD supports a wide range of audio cards and the GENERIC kernel already enables and configures most of them. For older systems, it might be necessary to manually set up the IRC and DMA for non-PnP ISA cards.
        !            74: 
        !            75: ### Note
        !            76: 
        !            77: When you create a custom kernel it is better to work on a copy of the GENERIC file, as described in [[Compiling the kernel|guide/kernel]].
        !            78: 
        !            79: If you still have problems you can try enabling all the devices, because some audio cards can be made to work only by emulating another card.
        !            80: 
        !            81: Many chipset make use of the SoundBlaster and OPL compatibility, but a great number of them work with the WSS emulation.
        !            82: 
        !            83: OPL is a MIDI synthesizer produced by Yamaha; there are many OPL variants (e.g. OPL2, OPL3SA, OPL3SA2, etc.). Many audio cards rely on this component or on a compatible one. For example, the chips produced by Crystal (and amongst them the very common CS423x) all have this chipset, and that's why they work with NetBSD.
        !            84: 
        !            85: WSS is not a microchip; it is the acronym of Windows Sound System. WSS is the name of the NetBSD kernel driver which supports the audio system of Microsoft Windows. Many audio cards work with Windows because they adhere to this standard (WSS) and the same holds for NetBSD.
        !            86: 
        !            87: Of the many audio cards that I tested with NetBSD, a good number work only if `opl*` and `wss*` are enabled in the kernel.
        !            88: 
        !            89: When everything works you can disable in the kernel configuration file the devices that you don't need.
        !            90: 
        !            91: ## Advanced commands
        !            92: 
        !            93: NetBSD comes with a number of commands that deal with audio devices. They are:
        !            94: 
        !            95:  * [audioctl(1)](http://netbsd.gw.com/cgi-bin/man-cgi?audioctl+1+NetBSD-5.0.1+i386) -- is used for setting options of the audio system driver.
        !            96:  * [mixerctl(1)](http://netbsd.gw.com/cgi-bin/man-cgi?mixerctl+1+NetBSD-5.0.1+i386) -- is used for controlling mixing variables, e.g., volume, balance and mute.
        !            97:  * [audioplay(1)](http://netbsd.gw.com/cgi-bin/man-cgi?audioplay+1+NetBSD-5.0.1+i386) -- is used for playing audio files.
        !            98:  * [audiorecord(1)](http://netbsd.gw.com/cgi-bin/man-cgi?audiorecord+1+NetBSD-5.0.1+i386) -- is used for recording audio files.
        !            99: 
        !           100: 
        !           101: ### [audioctl(1)](http://netbsd.gw.com/cgi-bin/man-cgi?audioctl+1+NetBSD-5.0.1+i386)
        !           102: 
        !           103: [audioctl(1)](http://netbsd.gw.com/cgi-bin/man-cgi?audioctl+1+NetBSD-5.0.1+i386) made its appearance in NetBSD 1.3 and 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:
        !           104: 
        !           105:     # audioctl -a | less
        !           106: 
        !           107: For example, to listen to CD quality music you can use the following command.
        !           108: 
        !           109:     # audioctl -w play=44100,2,16,slinear_le
        !           110: 
        !           111: This command sets the frequency to 44100Hz, 2 audio channels, 16 bit, slinear\_le encoding.
        !           112: 
        !           113: You can see the supported encodings with:
        !           114: 
        !           115:     # audioctl encodings
        !           116: 
        !           117: This command displays the list of all the encodings supported by the audio card on your system.
        !           118: 
        !           119: ### [mixerctl(1)](http://netbsd.gw.com/cgi-bin/man-cgi?mixerctl+1+NetBSD-5.0.1+i386)
        !           120: 
        !           121: This command is used to configure the audio mixing and has an interface similar to that of [audioctl(1)](http://netbsd.gw.com/cgi-bin/man-cgi?audioctl+1+NetBSD-5.0.1+i386).
        !           122: 
        !           123: ### [audioplay(1)](http://netbsd.gw.com/cgi-bin/man-cgi?audioplay+1+NetBSD-5.0.1+i386)
        !           124: 
        !           125: 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.)
        !           126: 
        !           127: ### [audiorecord(1)](http://netbsd.gw.com/cgi-bin/man-cgi?audiorecord+1+NetBSD-5.0.1+i386)
        !           128: 
        !           129: Not unsurprisingly this command is used to record audio files.
        !           130: 

CVSweb for NetBSD wikisrc <wikimaster@NetBSD.org> software: FreeBSD-CVSweb