Question Get the microphone input level

Infect3d

New member
Joined
Jul 29, 2009
Messages
4
Programming Experience
1-3
Hello,

for an application I need to get the microphone input level and "display" it with a ProgressBar.
Can someone help me? It's two days I try to solve this problem :(.

Thanks.
 
Hello,

thanks for the link, now I have this code:

VB.NET:
Private m_mixerId As Integer = 0
    Private hmx As IntPtr

    Const CALLBACK_WINDOW As Integer = &H10000
    Const MIXER_OBJECTF_MIXER As Integer = &H0
    Const MM_MIXM_CONTROL_CHANGE As Integer = &H3D1

    <DllImport("winmm.dll")> _
        Private Shared Function mixerOpen(ByRef phmx As IntPtr, <MarshalAs(UnmanagedType.U4)> ByVal uMxId As Integer, ByVal dwCallback As IntPtr, ByVal dwInstance As IntPtr, <MarshalAs(UnmanagedType.U4)> ByVal fdwOpen As Integer) As <MarshalAs(UnmanagedType.U4)> Integer
    End Function

    <DllImport("winmm.dll")> _
        Private Shared Function mixerClose(ByVal hmx As IntPtr) As <MarshalAs(UnmanagedType.U4)> Integer
    End Function

    Public Function GetInputLevel() As Integer
        Try
            If hmx <> IntPtr.Zero Then
                mixerClose(hmx)
            End If

            'If m_mixerId >= 0 Then
             Dim result As Integer = mixerOpen(hmx, m_mixerId, Main.Handle, IntPtr.Zero, CALLBACK_WINDOW Or MIXER_OBJECTF_MIXER)
            Return result
            'End If
        Catch ex As Exception

        End Try
    End Function

But the result is every time 0.
I've also try to change the mixer id but nothing :(
What's wrong? Maybe the handle (where Main.Handle)?

Thanks.
 
Back
Top