I'm interested in 'how to play a tone in linux' recently, because I want to link math and music together. I want to use system calls to do that because that way I don't have to use a music file like
ALSA is a kernel driver that provides support for numerous sound cards. It is usually used by low-level applications that want to interact with the sound system quite directly.
With ALSA you can access a buffer, and put samples into it, that will be played by the sound device. This is done with PCM (Pulse-code modulation). With ALSA you have a lot to configure (as seen here). You want to configure the amount of channels (mono, stereo, etc.), size of the samples (8 bit, 16 bit, etc.), the rate (8000 Hz, 16000 Hz, 44100 Hz, etc.). You write those samples to the PCM device with
snd_pcm_writei, for example.
The definitions of the ALSA library are located in
alsa/asoundlib.h. If you're using GCC, then you can link with the ALSA library with
Not all music players would use these low-level interactions. Much software is build on top of ALSA to give more generic interfaces to the sound system (platform independent even). Examples of sound servers include JACK and PulseAudio. The advantage of these sound servers is that they are usually easier to set-up and use, but do not give the fine control you would have with ALSA.