/* pcm_sin.c * This extra small demo sends a sine wave to your speakers. * sudo apt-get install libasound2 * sudo apt-get install libsound2-dev * get this file from web or * cp /afs/umbc.edu/users/s/q/squire/pub/download/pcm_sin.c . * gcc pcm_sin.c -l asound * a.out # you should hear a sine wave */ #include "alsa/asoundlib.h" #include static char *device = "default"; /* playback device */ snd_output_t *output = NULL; unsigned char buffer[64*1024]; /* some sound data */ int nbuf; int main(void) { int err; int nrepeat = 2; unsigned int i; double x, y; double volume=1.0; /* range 0.0 to 1.0 max loud */ snd_pcm_t *handle; snd_pcm_sframes_t frames; nbuf=sizeof(buffer); for(i=0; i 0 && frames < (long)nbuf) printf("Short write (expected %li, wrote %li)\n", (long)sizeof(buffer), frames); } snd_pcm_close(handle); return 0; } /* end pcm_sin.c */