Smart Device Functions:
Type a page name and press Enter. You'll jump to the page if it exists, or you can create it if it doesn't.
To create a page in a module other than winmm, prefix the name with the module name and a period.
[DllImport("winmm.dll", SetLastError = true, CharSet = CharSet.Auto)]
Declare Function waveOutPrepareHeader Lib "winmm.dll" (TODO) As TODO
Alternative Managed API:
Do you know one? Please contribute it!
Tips & Tricks:
The same WAVEHDR structure used with waveOutPrepareHeader() is also used with
the waveOutWrite() and waveOutUnPrepareHeader() functions. The latter is called
after the audio playback has been stopped with a call to waveOutReset(); The
audio driver will asynchronously set the WHDR_DONE bit in WAVEHDR.dwflags when
it has released the audio data block.
This means that the WAVEHDR struct passed to the waveOutWrite() function must be
allocated in unmanaged memory so it will survive after the call to waveOutWrite().
What I do is preallocate a block of unmanaged memory in my class's Open() method:
waveHdrPtr = Marshal.AllocHGlobal(Marshal.SizeOf(waveHdr));
Then in the output method I use this:
waveHdr.lpData = wavedata; // audio buffer
Now we are ready to write:
if ((MMRESULT = waveOutWrite(waveDevice, waveHdrPtr, Marshal.SizeOf(waveHdr))) != MMSYSERR_NOERROR)
When we are done listening to this playback:
while ((waveHdr.dwFlags & WHDR_DONE) == 0) // wait for it
When the WHDR_DONE bit sets we can call the waveOutUnPrepareHeader() function to release
the resources previously set up:
if ((MMRESULT = waveOutUnprepareHeader(waveDevice, waveHdrPtr, Marshal.SizeOf(waveHdr))) != MMSYSERR_NOERROR)
I release the unmanaged memory allocated in the Open() method in the class's Close method:
Please add some!
Please edit this page!
Do you have...