Important:
This is retired content. This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This content may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.
A version of this page is also available for
4/8/2010

This function opens a specified waveform input device for recording.

Syntax

MMRESULT waveInOpen(
  LPHWAVEIN 
phwi, 
  UINT 
uDeviceID, 
  LPCWAVEFORMATEX 
pwfx, 
  DWORD 
dwCallback, 
  DWORD 
dwInstance, 
  DWORD 
fdwOpen 
); 

Parameters

phwi

Address filled with a handle identifying the open waveform-audio input device. Use this handle to identify the device when calling other waveform-audio input functions. This parameter can be NULL if WAVE_FORMAT_QUERY is specified for fdwOpen.

uDeviceID

Device identifier of the waveform-audio input device to open. You can use the following flag instead of a device identifier.

Value Description

WAVE_MAPPER

The function selects a waveform-audio input device capable of recording in the specified format.

pwfx

Pointer to a WAVEFORMATEXstructure that identifies the desired format for recording waveform-audio data. You can free this structure immediately after waveInOpenreturns.

dwCallback

Specifies the address of a fixed callback function, an event handle, a handle to a window, or the identifier of a thread to be called during waveform-audio recording to process messages related to the progress of recording. If no callback function is required, this value can be zero.

dwInstance

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

fdwOpen

Flags for opening the device. The following values are defined.

Value Description

CALLBACK_EVENT

The dwCallbackparameter is an event handle.

CALLBACK_FUNCTION

The dwCallbackparameter is a callback procedure address.

CALLBACK_NULL

No callback mechanism. This is the default setting.

CALLBACK_THREAD

The dwCallbackparameter is a thread identifier.

CALLBACK_WINDOW

The dwCallbackparameter is a window handle.

WAVE_FORMAT_DIRECT

If this flag is specified, the ACM driver does not perform conversions on the audio data.

WAVE_FORMAT_QUERY

The function queries the device to determine whether it supports the specified format, but it does not open the device.

WAVE_MAPPED

The uDeviceIDparameter specifies a waveform-audio device to be mapped to by the wave mapper.

Return Value

One of the values described in the following table is returned.

Value Description

MMSYSERR_NOERROR

Success.

MMSYSERR_ALLOCATED

Specified resource is already allocated.

MMSYSERR_BADDEVICEID

Specified device identifier is out of range.

MMSYSERR_NODRIVER

No device driver is present.

MMSYSERR_NOMEM

Unable to allocate or lock memory.

WAVERR_BADFORMAT

Attempted to open with an unsupported waveform-audio format.

Remarks

Use the waveInGetNumDevsfunction to determine the number of waveform-audio input devices present on the system. The device identifier specified by uDeviceIDvaries from zero to one less than the number of devices present. The WAVE_MAPPER constant can also be used as a device identifier.

If you choose to have a window or thread receive callback information, the following messages are sent to the window procedure or thread to indicate the progress of waveform-audio input: MM_WIM_OPEN, MM_WIM_CLOSE, and MM_WIM_DATA.

When waveInOpenopens an input stream, it places that stream in the stopped state. Capture will only begin after you have called waveInStart, this lets the driver know that your application is ready to begin capturing sound. If you have given the driver a buffer, through a prior call to waveInAddBuffer, then sound capture will begin immediately after the call to waveInStart. If the driver does not already have a buffer before the call to waveInStart, then sound capture will begin immediately after you provide it one using waveInAddBuffer.

If you choose to have a function receive callback information, the following messages are sent to the function to indicate the progress of waveform-audio input: WIM_OPEN, WIM_CLOSE, and WIM_DATA.

Requirements

Header mmsystem.h
Library coredll.lib
Windows Embedded CE Windows CE 2.0 and later
Windows Mobile Windows Mobile Version 5.0 and later

See Also