When an application calls waveOutWrite(HWAVEOUT hwo, LPWAVEHDR pwh, UINT cbwh)
on windows, I save a copy of the audio data (pointed to by pwh->lpData) sent to the Audio Card in memory.
Now I want to save the audio data as a WAV format file on the disk, how should I do this?
I have the pointer to the audio data block and the size of the audo data.
The wav format is pretty trivial, and easy to write your own implementation for. Alternatively, you could use a library like libsndfile.
With legacy multimedia API you will use
mmioOpen
,mmioCreateChunk
,mmioWrite
family of functions. Here is a code snippet: WAV saving?. The API allows you to write these RIFF files, however the structure is not so much complex and you can write into the binary file directly.Still WinAPI, though not so well matching your
waveOutWrite
: