[clean-list] Callback Function
=?iso-8859-1?q?Alexsandro=20Soares?=
a_s_soares@yahoo.com.br
Mon, 23 Feb 2004 16:03:05 -0300 (ART)
Hello all,
I'm working with the Win32 Waveform Audio API in order
to capture sound from microphone. This API can be
accessed from winmm.lib.
I need to set up a callback function to receive
Windows Low Level WAVE API messages regarding digital
audio recording (such as MM_WIM_DATA, MM_WIM_OPEN, and
MM_WIM_CLOSE).. Something like this C code:
---------------------------------- Begin
--------------------------------------------------
DWORD WINAPI waveInProc(LPVOID arg)
{
MSG msg;
while (GetMessage(&msg, 0, 0, 0) == 1)
{
switch (msg.message)
{
case MM_WIM_DATA:
{
if (((WAVEHDR *)msg.lParam)->dwBytesRecorded)
{
if (!WriteFile(WaveFileHandle, ((WAVEHDR
*)msg.lParam)->lpData, ((WAVEHDR
*)msg.lParam)->dwBytesRecorded, &msg.time, 0) ||
msg.time != ((WAVEHDR
*)msg.lParam)->dwBytesRecorded)
{
/* display an error message about there being a
problem writing the audio data to disk */
}
}
/* Are we still recording? */
if (InRecord)
{
/* Yes. Now we need to requeue this buffer so the
driver can use it for another block of audio data.
*/
waveInAddBuffer(WaveInHandle, (WAVEHDR
*)msg.lParam, sizeof(WAVEHDR));
}
continue;
}
case MM_WIM_OPEN:
{
/* Keep waiting for more messages */
continue;
}
case MM_WIM_CLOSE:
{
break;
}
}
}
return(0);
}
------------------------------------------- End
------------------------------------------
The function that uses this callback is
MMRESULT waveInOpen(
LPHWAVEIN phwi,
UINT uDeviceID,
LPWAVEFORMATEX pwfx,
DWORD dwCallback, <----- Address of
WaveInProc goes hier
DWORD dwCallbackInstance,
DWORD fdwOpen
);
I canīt figure out a way to set up this callback in
Clean. Does anyone have any suggestion?
Cheers,
Alex
______________________________________________________________________
Yahoo! Mail - O melhor e-mail do Brasil! Abra sua conta agora:
http://br.yahoo.com/info/mail.html