none
winmm wavein callback RRS feed

  • Question

  • I am starting on an audio in component. I believe I will nee to get a callback from the waveopen function. But currently I am not. I get a NO_ERR message from the wavestart.

    Any ideas?

    Declare Function waveInOpen Lib "winmm.dll" (ByRef lphWaveIn As Integer, ByVal uDeviceID As UInteger, ByRef lpFormat As WAVEFORMATEXTENSIBLE, ByVal dwCallback As WaveInCallBack, ByVal dwInstance As UInteger, ByVal dwFlags As UInteger) As Integer Declare Function waveInStart Lib "winmm.dll" (ByVal hWaveIn As Integer) As Integer Declare Function waveInStop Lib "winmm.dll" (ByVal hWaveIn As Integer) As Integer Declare Function waveInAddBuffer Lib "winmm.dll" (ByVal hWaveIn As Integer, ByRef lpWaveInHdr As WAVEHDR, ByVal uSize As Integer) As Integer Declare Function waveInReset Lib "winmm.dll" (ByVal hWaveIn As Integer) As Integer Declare Function waveInPrepareHeader Lib "winmm.dll" (ByVal hwi As Integer, ByRef pwh As WAVEHDR, ByVal cbwh As UInteger) As Integer Declare Function waveInGetErrorText Lib "winmm.dll" Alias "waveInGetErrorTextA" (ByVal errorIN As Integer, ByVal lpText As String, ByVal uSize As UInteger) As Integer Declare Function waveInClose Lib "winmm.dll" (ByVal hwi As Integer) As Integer Declare Function waveInUnprepareHeader Lib "winmm.dll" (ByVal hwi As Integer, ByRef pwh As WAVEHDR, ByVal cbwh As UInteger) As Integer Declare Function waveInClose Lib "winmm.dll" (ByVal hwi As IntPtr) As Integer Public Delegate Function WaveInCallback(ByVal hwi As Integer, ByVal uMsg As UInteger, ByVal dwInstance As Integer, ByVal dwParam1 As Integer, ByVal dwParam2 As Integer) As Integer Public CALLBACK_FUNCTION As Integer = &H30000 Dim WFE As AudioProfile.WAVEFORMATEXTENSIBLE Dim WH As AudioProfile.WAVEHDR Dim RAMBufferPtr As String = "BOGUSNAME" Dim RAMBufferSize As Integer = 32767 Dim BufferWaveInIntptr As New List(Of IntPtr) Dim result As Integer Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click Dim N As String = "012390" Dim P As AudioProfile.Pointers P.waveIntPtr = CType(N, IntPtr) BufferWaveInIntptr.Add(P.waveIntPtr) WFE.wFormatTag = 1 WFE.nChannels = 2 WFE.dwBitsPerSample = 24 WFE.nSamplesPerSec = 48000 WFE.nBlockAlign = CUShort(CShort(WFE.nChannels * WFE.dwBitsPerSample / 8)) WFE.nAvgBytesPerSec = WFE.nSamplesPerSec * WFE.nBlockAlign WFE.cbSize = 0 RAMBufferPtr = Marshal.AllocHGlobal(RAMBufferSize) WH.lpData = CType(RAMBufferPtr, IntPtr) WH.dwBufferLength = RAMBufferSize WH.dwBytesRecorded = 0 WH.dwFlags = 0 WH.dwLoops = 0 waveInOpen(BufferWaveInIntptr(0), 0, WFE, myCallBackFunction, 0, CALLBACK_FUNCTION) waveInPrepareHeader(BufferWaveInIntptr(0), WH, CUInt(Marshal.SizeOf(WH))) waveInAddBuffer(BufferWaveInIntptr(0), WH, Marshal.SizeOf(WH)) result = CUInt(AudioProfile.waveInStart(BufferWaveInIntptr(0))) End Sub Private Const BUFFER_SIZE As Int32 = 128 Private RawWaveData(BUFFER_SIZE) As Byte Public Delegate Sub DisplayDataDelegate(dwParam1) Private myCallBackFunction As New AudioProfile.WaveInCallBack(AddressOf MyWaveCallBackProcedure) Private Function MyWaveCallBackProcedure(ByVal hwi As IntPtr, ByVal uMsg As Int32, ByVal dwInstance As Int32, ByVal dwParam1 As Int32, ByVal dwParam2 As Int32) As Int32 Msgbox(dwparam1) End Function

    Thanks for helping!!






    • Edited by -tE Tuesday, March 26, 2019 2:23 AM
    Monday, March 25, 2019 9:31 PM

All replies

  • Hi,

    see the following link,compare your return value.

    waveInStart

    waveInopen

    Best Regards,

    Alex


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Tuesday, March 26, 2019 2:47 AM
  • Hi,

    see the following link,compare your return value.

    waveInStart

    waveInopen

    Best Regards,

    Alex


    Thanks Alex,

    I am certain I am overlooking this, but what are you considering is wrong?  The handle?  I tried using just the soundcard ID, but that errors.   I do get a callback some,  but it only generates one integer and is the same each time.  I am not using a MsgBox actually, but have a listbox being invoked to give me the data.  I am guessing that it's not the incoming data,  but what the pointer ID is (I think).

    Thanks.

    Tuesday, March 26, 2019 5:02 AM
  • You can see the classes WaveInBuffer, WaveInRecorder

    from http://visualbasictutoriales.blogspot.com/p/chat-videoconferencia.html

    They work fine (MM_WIM_DATA is generated)

    Tuesday, March 26, 2019 10:17 AM