## 16.2 Setting Up the Sound Card ***Contributed by Moses Moore. *** ### 16.2.1 Locating the Correct Device Before you begin, you should know the model of the card you have, the chip it uses, and whether it is a PCI or ISA card. DragonFly supports a wide variety of both PCI and ISA cards. Check the [pcm(4)](http://leaf.dragonflybsd.org/cgi/web-man?command#pcm§ion4) manual page for a more complete list. To use your sound device, you will need to load the proper device driver. This may be accomplished in one of two ways. The easiest way is to simply load a kernel module for your sound card with [kldload(8)](http://leaf.dragonflybsd.org/cgi/web-man?command#kldload§ion8) which can either be done from the command line: # kldload snd_emu10k1.ko or by adding the appropriate line to the file `/boot/loader.conf` like this: snd_emu10k1_load="YES" These examples are for a Creative SoundBlaster Live! sound card. Other available loadable sound modules are listed in `/boot/defaults/loader.conf`. Alternatively, you may statically compile in support for your sound card in your kernel. The sections below provide the information you need to add support for your hardware in this manner. For more information about recompiling your kernel, please see [Kernel Configuration](kernelconfig.html). #### 16.2.1.1 Creative, Advance, and ESS Sound Cards If you have one of the above cards, you will need to add: device pcm to your kernel configuration file. If you have a PnP ISA card, you will also need to add: device sbc For a non-PnP ISA card, add: device pcm device sbc0 at isa? port 0x220 irq 5 drq 1 flags 0x15 to your kernel configuration file. The settings shown above are the defaults. You may need to change the IRQ or the other settings to match your card. See the [sbc(4)](http://leaf.dragonflybsd.org/cgi/web-man?command#sbc§ion4) manual page for more information. #### 16.2.1.2 Gravis UltraSound Cards For a PnP ISA card, you will need to add: device pcm device gusc to your kernel configuration file. If you have a non-PnP ISA card, you will need to add: device pcm device gus0 at isa? port 0x220 irq 5 drq 1 flags 0x13 to your kernel configuration file. You may need to change the IRQ or the other settings to match your card. See the [gusc(4)](http://leaf.dragonflybsd.org/cgi/web-man?command#gusc§ion4) manual page for more information. #### 16.2.1.3 Crystal Sound Cards For Crystal cards, you will need to add: device pcm device csa to your kernel configuration file. #### 16.2.1.4 Generic Support For PnP ISA or PCI cards, you will need to add: device pcm to your kernel configuration file. If you have a non-PnP ISA sound card that does not have a bridge driver, you will need to add: device pcm0 at isa? irq 10 drq 1 flags 0x0 to your kernel configuration file. You may need to change the IRQ or the other settings to match your card. #### 16.2.1.5 Onboard Sound Some systems with built-in motherboard sound devices may require the following device in your kernel configuration: device pnpbios ### 16.2.2 Creating and Testing the Device Nodes After you reboot, log in and check for the device in the `/var/run/dmesg.boot` file, as shown below: # grep pcm /var/run/dmesg.boot pcm0: on sbc0 The output from your system may look different. If no `pcm` devices show up, something went wrong earlier. If that happens, go through your kernel configuration file again and make sure you chose the correct device. Common problems are listed in [Sound Setup](sound-setup.html). If the previous command returned `pcm0`, you will have to run the following as `root`: # cd /dev # sh MAKEDEV snd0 If the command returned `pcm1`, follow the same steps as shown above, replacing `snd0` with `snd1`. **Note:** The above commands will ***not*** create a `/dev/snd` device! `MAKEDEV` will create a group of device nodes, including: [[!table data=""" | Device | Description `/dev/audio` | SparcĀ® compatible audio device `/dev/dsp` | Digitized voice device `/dev/dspW` | Like `/dev/dsp`, but 16 bits per sample `/dev/midi` | Raw midi access device `/dev/mixer` | Control port mixer device `/dev/music` | Level 2 sequencer interface `/dev/sequencer` | Sequencer device `/dev/pss` | Programmable device interface | """]] If all goes well, you should now have a functioning sound card. If your CD-ROM or DVD-ROM drive is properly coupled to your sound card, you can put a CD in the drive and play it with [cdcontrol(1)](http://leaf.dragonflybsd.org/cgi/web-man?command#cdcontrol§ion1): % cdcontrol -f /dev/acd0c play 1 Various applications, such as [audio/xmms](http://pkgsrc.se/audio/xmms) offer a better interface. You may want to install an application such as [audio/mpg123](http://pkgsrc.se/audio/mpg123) to listen to MP3 audio files. #### 16.2.2.1 Common Problems [[!table data=""" | Error | Solution ***`unsupported subdevice XX`*** | One or more of the device nodes was not created correctly. Repeat the steps above. ***`sb_dspwr(XX) timed out`*** | The I/O port is not set correctly. ***`bad irq XX`*** | The IRQ is set incorrectly. Make sure that the set IRQ and the sound IRQ are the same. ***`xxx: gus pcm not attached, out of memory`*** | There is not enough available memory to use the device. ***`xxx: can't open /dev/dsp!`*** | Check with `fstat | grep dsp` if another application is holding the device open. Noteworthy troublemakers are **esound** and **KDE** 's sound support. | """]] ### 16.2.3 Utilizing Multiple Sound Sources ***Contributed by Munish Chopra.*** It is often desirable to have multiple sources of sound that are able to play simultaneously, such as when **esound** or **artsd** do not support sharing of the sound device with a certain application. DragonFly lets you do this through 'virtual' sound channels, which can be set with the [sysctl(8)](http://leaf.dragonflybsd.org/cgi/web-man?command#sysctl§ion8) facility. Virtual channels allow you to multiplex your sound card's playback channels by mixing sound in the kernel. To set the number of virtual channels, there are two sysctl knobs which, if you are the `root` user, can be set like this: # sysctl hw.snd.pcm0.vchans=4 # sysctl hw.snd.maxautovchans=4 The above example allocates four virtual channels, which is a practical number for everyday use. `hw.snd.pcm0.vchans` is the number of virtual channels `pcm0` has, and is configurable once a device has been attached. `hw.snd.maxautovchans` is the number of virtual channels a new audio device is given when it is attached using [kldload(8)](http://leaf.dragonflybsd.org/cgi/web-man?command#kldload§ion8). Since the `pcm` module can be loaded independently of the hardware drivers, `hw.snd.maxautovchans` can store how many virtual channels any devices which are attached later will be given. As DragonFly doesn't support devfs you will have to point your applications at `/dev/dsp0`.`x`, where `x` is 0 to 3 if `hw.snd.pcm.0.vchans` is set to 4 as in the above example. CategoryHandbook CategoryHandbook-multimedia