开发者

How to use WAVEHDR

Where can I find information about what data should be in the lpData buffer for the WAVEHDR structure?

MSDN simply says:

lpData

Pointer to the waveform buffer.

typedef st开发者_运维技巧ruct wavehdr_tag {
    LPSTR               lpData;
    DWORD               dwBufferLength;
    DWORD               dwBytesRecorded;
    DWORD_PTR           dwUser;
    DWORD               dwFlags;
    DWORD               dwLoops;
    struct wavehdr_tag  *lpNext;
    DWORD_PTR           reserved;
} WAVEHDR, *LPWAVEHDR;

Thanks


I found this tutorial by David Overton very helpful.

Basically, when you call waveOutOpen, you pass in a format structure. Here's from his code:

WAVEFORMATEX wfx; /* look this up in your documentation */
wfx.nSamplesPerSec = 44100; /* sample rate */
wfx.wBitsPerSample = 16; /* sample size */
wfx.nChannels = 2; /* channels*/

Then your data in lpData is just 2 bytes per sample (signed short int), left, right, left, etc.


lpData is like an old DOS DMA buffer. So you can write a piece of track on It like a single block loop.

So in C you declare some proper array ...char myarray[porpersize]. and then you point it ->>> myhdrstruc.lpData=&myarray[0]


CCRMA has a decent overview of the wave file format.


It's vague because the data can be in a variety for formats. The format is typically specified by a WAVEFORMATEX.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜