MMRESULT waveInOpen(lphWaveIn, uDeviceID, lpFormat, dwCallback, dwCallbackInstance, dwFlags) | |||
LPHWAVEIN lphWaveIn; | |||
UINT uDeviceID; | |||
LPWAVEFORMAT lpFormat; | |||
DWORD dwCallback; | |||
DWORD dwCallbackInstance; | |||
DWORD dwFlags; |
The waveInOpen function opens a specified waveform input device for recording.
lphWaveIn
Specifies a far pointer to a HWAVEIN handle. This location is filled with a handle identifying the opened waveform input device. Use this handle to identify the device when calling other waveform input functions. This parameter may be NULL if the WAVE_FORMAT_QUERY flag is specified for dwFlags.
uDeviceID
Identifies the waveform input device to open. Use a valid device ID or the WAVE_MAPPER flag.
If this flag is specified, the function selects a waveform input device capable of recording in the given format.
lpFormat
Specifies a pointer to a WAVEFORMAT data structure that identifies the desired format for recording waveform data.
dwCallback
Specifies the address of a callback function or a handle to a window called during waveform recording to process messages related to the progress of recording.
dwCallbackInstance
Specifies user instance data passed to the callback. This parameter is not used with window callbacks.
dwFlags
Specifies flags for opening the device.
Value | Meaning |
WAVE_FORMAT_QUERY | ||
If this flag is specified, the device will be queried to determine if it supports the given format but will not actually be opened. | ||
WAVE_ALLOWSYNC | ||
If this flag is not specified, then the device will fail to open if it is a synchronous device. | ||
CALLBACK_WINDOW | ||
If this flag is specified, dwCallback is assumed to be a window handle. | ||
CALLBACK_FUNCTION | ||
If this flag is specified, dwCallback is assumed to be a callback procedure address. |
Returns zero if the function was successful. Otherwise, it returns an error number. Possible error returns are:
Value | Meaning |
MMSYSERR_BADDEVICEID | Specified device ID is out of range. |
MMSYSERR_ALLOCATED | Specified resource is already allocated. |
MMSYSERR_NOMEM | Unable to allocate or lock memory. |
WAVERR_BADFORMAT | Attempted to open with an unsupported wave format. |
Use waveInGetNumDevs to determine the number of waveform input devices present in the system. The device ID specified by uDeviceID varies from zero to one less than the number of devices present. The WAVE_MAPPER constant may also be used as a device id.
If a window is chosen to receive callback information, the following messages are sent to the window procedure function to indicate the progress of waveform input: MM_WIM_OPEN, MM_WIM_CLOSE, and MM_WIM_DATA.
If a function is chosen to receive callback information, the following messages are sent to the function to indicate the progress of waveform input: WIM_OPEN, WIM_CLOSE, WIM_DATA. The callback function must reside in a DLL. You do not have to use MakeProcInstance to get a procedure-instance address for the callback function.
void CALLBACK WaveInFunc(hWaveIn, wMsg, dwInstance,
dwParam1, dwParam2)
HWAVEIN hWaveIn;
UINT wMsg;
DWORD dwInstance;
DWORD dwParam1;
DWORD dwParam2;
WaveInFunc is a placeholder for the application-supplied function name. The actual name must be exported by including it in an EXPORTS statement in the DLL's module-definition file.
hWaveIn
Specifies a handle to the waveform device associated with the callback.
wMsg
Specifies a waveform input device.
dwInstance
Specifies the user instance data specified with waveInOpen.
dwParam1
Specifies a parameter for the message.
dwParam2
Specifies a parameter for the message.
Because the callback is accessed at interrupt time, it must reside in a DLL and its code segment must be specified as FIXED in the module-definition file for the DLL. Any data that the callback accesses must be in a FIXED data segment as well. The callback may not make any system calls except for PostMessage, timeGetSystemTime,timeGetTime, timeSetEvent, timeKillEvent,midiOutShortMsg, midiOutLongMsg, and OutputDebugStr.
waveInClose