Difference between revisions of "Sound"

From Hackepedia
Jump to navigationJump to search
(sound on OpenBSD)
 
m (formatting)
Line 5: Line 5:
 
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.
 
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
+
auich0 at pci0 dev 6 function 0 "NVIDIA nForce3 250 AC97" rev    
audio0 at auich0
+
0xa1: irq 11, nForce3 AC97
auich0: measured ac97 link rate at 47995 Hz, will use 48000 Hz
+
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.
 
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.
Line 13: Line 14:
 
Recording is done the following way:
 
Recording is done the following way:
  
(audioctl record.encoding=slinear_le record.channels=2 record.precision=16 ; \
+
(audioctl record.encoding=slinear_le record.channels=2 \
cat /dev/sound ) > blah.raw
+
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:
 
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
+
sox -r 48000 -w -s -c 2 blah.raw blah.wav

Revision as of 01:57, 23 October 2006

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