tiistai 17. elokuuta 2010

Surround sound with FreeBSD 8.x and snd_hda

The snd_hda driver is really a sweet piece of software. It allows FreeBSD to utilize many HDA-compatible sound chips. Most new motherboards have HDA compatible integrated sound.

Although to get more than two channels to play one has to make some minor adjustment to system settings.

Do this as root:
# kldload snd_hda
# sysctl dev.pcm.0.play.vchanformat=s16le:5.1

The above command sets the hda codec's first playback device to use 5.1 speaker setting as output. If you have 7.1 setup, use s16le:7.1 instead. Etc. Use brain.

If you need multiple applications to access sound simultaneously:
# sysctl dev.pcm.0.play.vchans=3

Normally one would connect green, yellow and black connectors to the speaker system as front, center/lfe and rear respectively. However, some hda chip's default configuration use the gray output plug as for rear speakers.

To test your surround setup:
1. Install VLC or MPlayer from ports or packages
2. Download the AC3 version of "Surround sound test" from http://www.lynnemusic.com/surround.html
3. Make your media player use OSS as sound output backend. RTFM if you must.
4. Play the "Surround sound test" file to see wether you get the samples out of the right speakers
5. Adjust plugs accordingly

Okay, some ppl might argue that configuring snd_hda to use correct output pins would be better than just adjusting plugs, but that's just a waste of time. In the long run it is better to cope with the codec's default configuration. Only attempt your codec's reconfiguration if some of the output pins are not associated etc.

I've tried this approach and managed to get VLC play the "Surround sound test" AC3 file with all samples in the correct channels. In my case, I had to relocate the black plug (rear speakers) to grey plug. Live and learn.

If your media player application does not support the official OSS multichannel playback the the app sucks balls. I heartily recommend VLC.

To make your configuration permanent, edit /etc/rc.local and add the above commands there. Works like a charm.

PS. rtfm$ man snd_hda

EDIT: I've tested the following players to support multichannel OSS playback:
- multimedia/vlc
- multimedia/mplayer
* with: -ao oss -channels 6

Ei kommentteja:

Lähetä kommentti