Sound

From Hackepedia
Revision as of 00:57, 23 October 2006 by Pbug (talk | contribs) (formatting)
Jump to navigationJump to search

Sound on UNIX has improved tremendously over the last ten years. Especially for Free UNIXes.

In OpenBSD the interface to the sound card are /dev/sound, /dev/audio, /dev/audioctl, /dev/mixer.

Manipulating these are done with the audioctl and mixerctl commands. At kernel configuration time the dmesg may look like this with the auich(4) card.

auich0 at pci0 dev 6 function 0 "NVIDIA nForce3 250 AC97" rev     
0xa1: irq 11, nForce3 AC97
audio0 at auich0
auich0: measured ac97 link rate at 47995 Hz, will use 48000 Hz

Playing mp3's can be done with mpg123 or mplayer, with mplayer I usually use the -srate 48000 option to resample the rate to the hardfixed 48000 Hz of this particular card.

Recording is done the following way:

(audioctl record.encoding=slinear_le record.channels=2  \ 
record.precision=16 ; \
cat /dev/sound ) > blah.raw

This writes a raw file of PCM data but without the headers, I found that sox can attach a header, like so:

sox -r 48000 -w -s -c 2 blah.raw blah.wav