NAudio用法詳解(5)底層庫詳解_waveInOpen

NAudio用法詳解(5)底層庫詳解_waveInOpen

本篇翻譯自以下地址:
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

Return value

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.

Remarks

參考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.

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章