On 18 Jul 2011, at 20:17, kmpir...@ece.upatras.gr wrote:

> I'm looking for a way to modify the alsa recording example found here 
> http://www.linuxjournal.com/article/6735?page=0,2 and shown below (or use any 
> other sample program you may suggest), in order to produce a wav file rather 
> than send the buffer contents to the standard output. I want to do something 
> very specific, so using the arecord utility is not an option for me. Any help?

converting a raw stream into a wav file is simply a question of putting a 44 
byte wav header on at the begining of the file.  This gives the sampling 
frequency (44.1kHz), number of channels (2) and bytes per sample (2, or 
possibly bits, I forget exactly); it also gives the duration for the recording 
which you won't know until you have finished.

What I did many years ago to do this was to seek to 44 bytes (on an empty 
output file) and record the raw data and then when I had finished, seek back to 
the beginning and write the header.

The header format is well-documented and well-known: Google will find it easily.

jch
------------------------------------------------------------------------------
Magic Quadrant for Content-Aware Data Loss Prevention
Research study explores the data loss prevention market. Includes in-depth
analysis on the changes within the DLP market, and the criteria used to
evaluate the strengths and weaknesses of these DLP solutions.
http://www.accelacomm.com/jaw/sfnl/114/51385063/
_______________________________________________
Alsa-user mailing list
Alsa-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/alsa-user

Reply via email to