1. Audio Device Files in Linux
/Dev/console: The device file related to the speaker.
/Dev/DSP: The device file related to the DSP on the sound card device. It provides digital sampling and digital recording functions. The sound card device converts analog and digital signals through DSP. Writing data to the device activates the digital-to-analog converter on the sound card to play the audio. Reading data from the device activates Analog-to-analog conversion on the Sound Card for recording.
/Dev/Audio: similar to/dev/DSP. The encoding method is Mu-Law.
/Dev/mixer: The software interface of the mixer in the sound card. It is used to combine or overlay multiple sound signals. The programming of the mixer includes how to set the gain and how to switch between different audio sources.
/Dev/sequencer: it is used to support the wave table synthesizer in The Sound Card and is mainly used in computer music software.
2. Instance
Example 1: Enable speaker
# Include <stdio. h> <br/> # include <stdlib. h> <br/> # include <unistd. h> <br/> # include <sys/types. h> <br/> # include <sys/STAT. h> <br/> # include <fcntl. h> <br/> # include <sys/IOCTL. h> <br/> # include <Linux/KD. h> </P> <p> # define speaker_device "/dev/console" </P> <p> int main (INT argc, char * argv []) <br/>{< br/> int FD; <br/> int freq; </P> <p> If (argc! = 2) <br/>{< br/> printf ("Usage: % s frequence/N", argv [0]); <br/> return 1; <br/>}</P> <p> freq = atoi (argv [1]); <br/> If (freq <= 0 | freq> 10000) <br/> {<br/> printf ("the frequence must be in the range from 0 to 10000. /n "); <br/> return 1; <br/>}</P> <p> FD = open (speaker_device, o_wronly ); </P> <p> If (FD =-1) <br/> {<br/> perror ("connot open device. /n "); <br/> return 1; <br/>}</P> <p> int I; <br/> int CNT; <br/> for (I = 0; I <1000; ++ I) <br/>{< br/> int set_freq = 1190000/freq; <br/> IOCTL (FD, kiocsound, set_freq); <br/> usleep (200); <br/> IOCTL (FD, kiocsound, 0 ); <br/> usleep (100); <br/>}< br/> return 0; <br/>}< br/>