本篇翻译自以下地址:
https://docs.microsoft.com/zh-cn/windows/win32/api/mmeapi/nf-mmeapi-waveinopen
为了便于大家批评指正,原文大部分并未删除。为了简单理解,有些复杂的描述,并未翻译,大部分情况下不影响使用。
方框内的内容为本人额外的补充说明。
上篇中,本人部分翻译了waveOutOpen函数,本篇翻译waveInOpen,这两个函数都来自Winmm.dll,掌握了这两个函数,waveIn类和waveOut类函数学习起来就比较简单了。
The waveInOpen function opens the given waveform-audio input device for recording.
waveInOpen
函数用来在录音时打开给定的波形音频输入设备。
C++
MMRESULT waveInOpen(
LPHWAVEIN phwi,
UINT uDeviceID,
LPCWAVEFORMATEX pwfx,
DWORD_PTR dwCallback,
DWORD_PTR dwInstance,
DWORD fdwOpen
);
参数 | 含义 |
---|---|
phwi | Pointer to a buffer that receives 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. 指向一个缓冲的指针,接收标识打开波形音频输入设备的句柄。使用这个句柄用来在调用其他波形饮片输入函数时,标识这个波形音频输入设备。如果 fdwOpen 参数设置为WAVE_FORMAT_QUERY ,则这个参数可以设置为NULL。 |
uDeviceID | Identifier of the waveform-audio input device to open. It can be either a device identifier or a handle of an open waveform-audio input device. You can use the following flag instead of a device identifier. 参考waveOutOpen |
pwfx | Pointer to a WAVEFORMATEX structure that identifies the desired format for recording waveform-audio data. You can free this structure immediately after waveInOpen returns. 参考waveOutOpen |
dwCallback | Pointer to 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. For more information on the callback function, see waveInProc. 一个指针,指向一个固定的回调函数,一个事件句柄,一个窗口句柄,或者一个线程标识符,用于波形音频录音过程中,处理录音过程中的信息。 类似于waveOutOpen函数中描述的回调机制,在录音过程中,当给定的录音缓冲数据满时,触发回调机制。 |
dwInstance | User-instance data passed to the callback mechanism. This parameter is not used with the window callback mechanism. 参考waveOutOpen |
fdwOpen | Flags for opening the device. The following values are defined. 参考waveOutOpen |
Returns MMSYSERR_NOERROR if successful or an error otherwise. Possible error values include the following.
返回码 | 描述 |
---|---|
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. |
参考waveOutOpen
Use the waveInGetNumDevs function to determine the number of waveform-audio input devices present on the system. The device identifier specified by uDeviceID varies 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.
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.