libasound2-dev and libasound:
apt-get install libasound2-dev
There is the inbuilt sound card for output. I tried out the tone-generator server program that I made a while ago, that puts out in-phase and quadrature sine-waves on the two channels. The sample-rate and block length seems to limit the frequency range I can get at the low end, about 87 Hz or "big F", the F above the low E on a guitar.
Looking at the signals on the oscilloscope, there is a lot of high-frequency "fuzz" once I go above about 2 kHz, and it gets even uglier higher up.
The amixer command is handy to explore and set the mixer level details. It shows output gain can be from -102.39 dB to +4 dB, settable in 0.01 dB steps.
amixer -c 0 contents
lists the three controls in the mixer: playback route, playback switch, and playback volume. This latter is more interesting:
amixer -c 0 cget numid=1
to read info and gain, and
amixer -c 0 -- cset numid=1 400 amixer -c 0 -- cset numid=1 -1000
to set the desired output level, to 4 dB or -10 dB. The trick with the two dashes is to allow negative levels to be accepted as the argument, and not attempted interpreted as options by the system.
There is no on-board input sound device. I got hold of a small and neat-looking USB-based input device, identifying itself as a C-Media Electronics Inc. USB PnP Audio Device. It then appears in the list as card 1 in the set of devices that amixer handles, where the built-in output is identified as card 0.
The command
amixer -c 1 contents
shows the card controls available:
numid=1,iface=MIXER,name='Mic Capture Switch' ; type=BOOLEAN,access=rw------,values=1 : values=on numid=2,iface=MIXER,name='Mic Capture Volume' ; type=INTEGER,access=rw---R--,values=2,min=0,max=62,step=0 : values=46,46 | dBminmax-min=-8.00dB,max=22.50dB
Note that in order to open this with snd_pcm_open() I had to use the devicename "hw:1,0" and not the common "default".
On trying out recording some data at various sample rates, the device wants to use the sample-rates 8000, 11008, 16000, 22048, 32000, 44100, and 48000.