none
Microfone usando api windows RRS feed

  • Pergunta

  • Boa noite, bom estou usando api windows para gravar audio do microfone, o audio grava normalmente ... porem o chiado e tremendo, gostaria de saber se seria por conta da api ou meu audio mesmo... já testei em dois 2x pcs diferentes ...

    'api

      'API de audio windows Microfone, DllImport frame mais alto.
        <DllImport("winmm")>
        Private Shared Function mciSendString(ByVal lpstrCommand As String, ByVal lpstrReturnString As String,
                                             ByVal uReturnLength As Integer, ByVal hwndCallback As Integer) As Integer
        End Function
    
        'API Get Driver Audio
        <DllImport("winmm.dll", SetLastError:=True)>
        Private Shared Function waveInGetNumDevs() As UInteger
        End Function
    
        <DllImport("winmm.dll", SetLastError:=True, CharSet:=CharSet.Auto)>
        Private Shared Function waveInGetDevCaps(ByVal hwo As UInteger, ByRef pwoc As WAVEOUTCAPS, ByVal cbwoc As UInteger) As UInteger
        End Function
    
        <StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Auto)>
        Private Structure WAVEOUTCAPS
            Public wMid As UShort
            Public wPid As UShort
            Public vDriverVersion As UInteger
            <MarshalAs(UnmanagedType.ByValTStr, SizeConst:=64)>
            Public szPname As String
            Public dwFormats As UInteger
            Public wChannels As UShort
            Public wReserved1 As UShort
            Public dwSupport As UInteger
        End Structure

    'modo gravado

       'Gravar
            mciSendString("open new Type waveaudio Alias recsound", Nothing, ID, ID)
            mciSendString("record recsound", Nothing, ID, ID)
            Dim SaveFileAudio As String = (Path.GetTempPath & "x.wav")
            Await Task.Delay(500) 'tempo para gravar
            'Parar
            mciSendString("save recsound " & SaveFileAudio, Nothing, ID, ID)
            mciSendString("close recsound", Nothing, ID, ID)

      
    terça-feira, 16 de abril de 2019 00:11

Todas as Respostas