waveInOpen

Syntax

WORD waveInOpen(lphWaveIn, wDeviceID, lpFormat, dwCallback, dwCallbackInstance, dwFlags)

This function opens a specified waveform input device for recording.

Parameters

LPHWAVEIN 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.

WORD wDeviceID

Identifies the waveform input device to open. Use a valid device ID or the following flag:

WAVE_MAPPER

If this flag is specified, the function selects a waveform input device capable of recording in the given format.

LPWAVEFORMAT lpFormat

Specifies a pointer to a WAVEFORMAT data structure that identifies the desired format for recording waveform data.

DWORD 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.

DWORD dwCallbackInstance

Specifies user instance data passed to the callback. This parameter is not used with window callbacks.

DWORD dwFlags

Specifies flags for opening the device.

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.

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.

Return Value

Returns zero if the function was successful. Otherwise, it returns an error number. Possible error returns are:

MMSYSERR_NODRIVER

The driver was not installed.

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.

Comments

Use waveInGetNumDevs to determine the number of waveform input devices present in the system. The device ID specified by wDeviceID varies from zero to one less than the number of devices present.

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, 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.

Callback

void FAR PASCAL WaveInFunc(hWaveIn, wMsg, dwInstance, dwParam1, 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.

Parameters

HWAVEIN hWaveIn

Specifies a handle to the waveform device associated with the callback.

WORD wMsg

Specifies a waveform input device.

DWORD dwInstance

Specifies the user instance data specified with waveInOpen.

DWORD dwParam1

Specifies a parameter for the message.

DWORD dwParam2

Specifies a parameter for the message.

Comments

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.

See Also

waveInClose