Example recording can be found in list 4 here:
http://www.linuxjournal.com/article/6735?page=0,2
To accommodate for my setup, I had to:
- Change the hardware from "default" to "plughw:0,0" in snd_pcm_open().
- I also replaced the write() with an fwrite() to output to a file.
To install the relevant headers, I had to install the following package:
sudo apt-get install libasound2-dev
Finally, to do the compile, don't forget to link to the ALSA library using the -l option:
gcc record.c -lasound
The example code performs the capture at 44100Hz, signed 16 bit, 2 channels, and output to simple raw format without any file headers. To verify the recording, I had to specify all the parameters using aplay:
aplay -f s16_le -r 44100 -c 2 test.out
No comments:
Post a Comment