Solved

Audio level meter using Mixer API calls

Posted on 1997-05-13
11
1,760 Views
Last Modified: 2012-06-21
I have to build an audio level meter. "VU-Meter"

Could somebody pass me an example code on how to take a peek at current wave audio level using mixerGetLineInfo, mixeGetLineControls & mixerGetControlDetails.

Correct me if I'm wrong, but I think audio card passes this information to you so that you can use Mixer API's to read the actual current "VU-meter" value and you don't have to calculate it yourself.

But the question is: How can I do it?

0
Comment
Question by:shurme
  • 6
  • 4
11 Comments
 
LVL 5

Expert Comment

by:y96andha
ID: 1426235
What do you mean by that? That you want to read the volume settings, or that you want to create a VU-meter? The later would probably require you to sample the audio stream and calculate the audiolevel yourself.
0
 

Author Comment

by:shurme
ID: 1426236
Edited text of question
0
 

Author Comment

by:shurme
ID: 1426237
Adjusted points to 150
0
 
LVL 5

Expert Comment

by:y96andha
ID: 1426238
I am not sure about new cards, but older cards didn't pass back any information of that kind.
0
 

Author Comment

by:shurme
ID: 1426239
Can you tell me then what eg. these kind of constants are for?
Public Const MIXERCONTROL_CONTROLTYPE_PEAKMETER = (MIXERCONTROL_CONTROLTYPE_SIGNEDMETER + 1)
Public Const MIXERCONTROL_CONTROLTYPE_DECIBELS = (MIXERCONTROL_CT_CLASS_NUMBER Or MIXERCONTROL_CT_UNITS_DECIBELS)
Public Const MIXERCONTROL_CONTROLTYPE_SIGNEDMETER = (MIXERCONTROL_CT_CLASS_METER Or MIXERCONTROL_CT_SC_METER_POLLED Or MIXERCONTROL_CT_UNITS_SIGNED)

To me they sound like the "real thing", but as having very little experience on using API, I can't figure out how and what structures should be used and how to fill them to get the correct results.

0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

Expert Comment

by:wahle
ID: 1426240
here are two API's to get volume. although i don't know how to use them. They would probably be pretty easy, if you knew the udeviceid, if you even need that in the first place.
Declare Function waveOutGetVolume Lib "MMSYSTEM" (ByVal udeviceid As Integer, lpdwvolume As Long) As Integer
Declare Function waveOutSetVolume Lib "MMSYSTEM" (ByVal udeviceid As Integer, ByVal dwVolume As Long) As Integer

0
 

Author Comment

by:shurme
ID: 1426241
Thanks for the answer, but I don't need to adjust/read the volume - I'm looking for info on how to read the actual peak level of audio stream, so that I can use the values on my own "VU-meter".

0
 

Author Comment

by:shurme
ID: 1426242
Adjusted points to 200
0
 
LVL 5

Accepted Solution

by:
y96andha earned 200 total points
ID: 1426243
Save these two files to disk and load them in a VB project. I think (hope, cause it took me quite some time to make it work) that you will understand how to do it if you look at these source codes.

Please comment with any questions you might have, or send e-mail to andreas.hansson@mbox303.swipnet.se.


-------------------------------------------------------------------------
VERSION 4.00
Begin VB.Form Form1
   Caption         =   "Form1"
   ClientHeight    =   8115
   ClientLeft      =   585
   ClientTop       =   720
   ClientWidth     =   9990
   Height          =   8520
   Left            =   525
   LinkTopic       =   "Form1"
   ScaleHeight     =   8115
   ScaleWidth      =   9990
   Top             =   375
   Width           =   10110
   Begin VB.CommandButton Command1
      Caption         =   "Update"
      Height          =   255
      Left            =   8280
      TabIndex        =   0
      Top             =   120
      Width           =   1215
   End
End
Attribute VB_Name = "Form1"
Attribute VB_Creatable = False
Attribute VB_Exposed = False

'
Private Sub Command1_Click()
Cls
Dim ml As MIXERLINE
Dim mcs As MIXERCAPS
Dim mlc As MIXERLINECONTROLS
Dim mc As MIXERCONTROL
Dim mcd As MIXERCONTROLDETAILS
Dim buf(4096) As Byte
mcsize = LenB(mc) '17 * 4 + MIXER_SHORT_NAME_CHARS + MIXER_LONG_NAME_CHARS

Dim status As Long
For i = 0 To mixerGetNumDevs - 1
    status = mixerGetDevCaps(i, mcs, LenB(mcs))
'    Print "mixerGetDevCaps"; status
    Print "mixer "; s(mcs.szPname)
    For j = 0 To mcs.cDestinations - 1
        ml.cbStruct = LenB(ml)
        ml.dwDestination = j
        ml.dwSource = 0
        status = mixerGetLineInfo(i, ml, MIXER_GETLINEINFOF_DESTINATION)
'        Print "  mixerGetLineInfo "; status
        Print "  destination line "; s(ml.szShortName); " = '"; s(ml.szName); "', controls: "; ml.cControls; ", connections: "; ml.cConnections
        mlc.cbStruct = LenB(mlc)
        mlc.dwLineID = ml.dwLineID
        mlc.cControls = ml.cControls
        mlc.cbmxctrl = LenB(mc)
        mlc.pamxctrl = String(LenB(mc) * ml.cControls, 0)
        status = mixerGetLineControls(i, mlc, MIXER_GETLINECONTROLSF_ALL)
 '       Print "  mixerGetLineControls "; status
        For k = 0 To ml.cControls - 1
            mc.dwControlID = tolong(Mid$(mlc.pamxctrl, k * mcsize + 1 + 4))
            mc.dwControlType = tolong(Mid$(mlc.pamxctrl, k * mcsize + 1 + 2 * 4))
            mc.szShortName = Mid$(mlc.pamxctrl, k * mcsize + 1 + 5 * 4, MIXER_SHORT_NAME_CHARS)
            mc.szName = Mid$(mlc.pamxctrl, k * mcsize + 1 + 5 * 4 + MIXER_SHORT_NAME_CHARS, MIXER_LONG_NAME_CHARS)
'            Print mc.szShortName
 '           Print mc.szName
'            Print hex$(mc.dwControlID)
 '           Print hex$(mc.dwControlType)
            Print "    control "; s(mc.szShortName); " = '"; s(mc.szName); "', ";
           
            Print "parsed type=[";
           
            If mc.fdwControl & MIXERCONTROL_CONTROLF_UNIFORM Then
                Print "Uniform ";
            End If
           
            Select Case (mc.dwControlType And MIXERCONTROL_CT_CLASS_MASK)
            Case MIXERCONTROL_CT_CLASS_CUSTOM
                Print "Custom ";
            Case MIXERCONTROL_CT_CLASS_FADER
                Print "Fader ";
            Case MIXERCONTROL_CT_CLASS_LIST
                Print "List ";
            Case MIXERCONTROL_CT_CLASS_METER
                Print "Meter ";
            Case MIXERCONTROL_CT_CLASS_NUMBER
                Print "Number ";
            Case MIXERCONTROL_CT_CLASS_SLIDER
                Print "Slider ";
            Case MIXERCONTROL_CT_CLASS_SWITCH
                Print "Switch ";
            Case MIXERCONTROL_CT_CLASS_TIME
                Print "Time ";
            Case Else
                Print "Unknown ("; hex$(mc.dwControlType And MIXERCONTROL_CT_CLASS_MASK); ") "
            End Select
           
            Select Case mc.dwControlType
            Case MIXERCONTROL_CONTROLTYPE_MIXER
                Print "Mixer ";
            Case MIXERCONTROL_CONTROLTYPE_MUX
                Print "Mux ";
            Case MIXERCONTROL_CONTROLTYPE_PEAKMETER
                Print "PeakMeter ";
                mcd.cbStruct = Len(mcd)
                mcd.dwControlID = mc.dwControlID
                If mc.fdwControl & MIXERCONTROL_CONTROLF_UNIFORM Then
                    mcd.cChannels = 1
                Else
                    mcd.cChannels = ml.cChannels
                End If
                mcd.cbDetails = 4
                mcd.item = 0
                mcd.paDetails = String(4 * mcd.cChannels, 0)
                status = mixerGetControlDetails(i, mcd, MIXER_GETCONTROLDETAILSF_VALUE)
                For m = 1 To mcd.cChannels
                    Print "peak["; m; "]="; tolong(Mid$(mcd.paDetails, m * 4 - 3)); " ";
                Next m
            Case MIXERCONTROL_CONTROLTYPE_ONOFF
                Print "OnOff ";
            Case MIXERCONTROL_CONTROLTYPE_MUTE
                Print "Mute ";
            Case MIXERCONTROL_CONTROLTYPE_MONO
                Print "Mono ";
            Case MIXERCONTROL_CONTROLTYPE_LOUDNESS
                Print "Loudness ";
            Case MIXERCONTROL_CONTROLTYPE_STEREOENH
                Print "StereoEnh ";
            Case MIXERCONTROL_CONTROLTYPE_VOLUME
                Print "Volume ";
            Case MIXERCONTROL_CONTROLTYPE_BASS
                Print "Bass ";
            Case MIXERCONTROL_CONTROLTYPE_TREBLE
                Print "Treble ";
            Case MIXERCONTROL_CONTROLTYPE_EQUALIZER
                Print "Equalizer ";
            Case MIXERCONTROL_CONTROLTYPE_PAN
                Print "Pan ";
            Case MIXERCONTROL_CONTROLTYPE_QSOUNDPAN
                Print "QSoundPan ";
            End Select
           
           
            Print "]"
           
        Next k
       
        For l = 0 To ml.cConnections - 1
            ml.dwSource = l
            status = mixerGetLineInfo(i, ml, MIXER_GETLINEINFOF_SOURCE)
'            Print "    mixerGetLineInfo "; status
            Print "    source line "; s(ml.szShortName); " = '"; s(ml.szName); "', channels: "; ml.cChannels; ", controls: "; ml.cControls
           
            mlc.cbStruct = Len(mlc)
            mlc.dwLineID = ml.dwLineID
            mlc.cControls = ml.cControls
            mlc.cbmxctrl = LenB(mc)
            mlc.pamxctrl = String(LenB(mc) * ml.cControls, 0)
            status = mixerGetLineControls(i, mlc, MIXER_GETLINECONTROLSF_ALL)
'            Print "    mixerGetLineControls "; status
            For k = 0 To ml.cControls - 1
                mc.dwControlID = tolong(Mid$(mlc.pamxctrl, k * mcsize + 1 + 4))
                mc.dwControlType = tolong(Mid$(mlc.pamxctrl, k * mcsize + 1 + 2 * 4))
                mc.fdwControl = tolong(Mid$(mlc.pamxctrl, k * mcsize + 1 + 3 * 4))
                mc.szShortName = Mid$(mlc.pamxctrl, k * mcsize + 1 + 5 * 4, MIXER_SHORT_NAME_CHARS)
                mc.szName = Mid$(mlc.pamxctrl, k * mcsize + 1 + 5 * 4 + MIXER_SHORT_NAME_CHARS, MIXER_LONG_NAME_CHARS)
    '            Print mc.szShortName
     '           Print mc.szName
    '            Print hex$(mc.dwControlID)
     '           Print hex$(mc.dwControlType)
                Print "      control "; s(mc.szShortName); " = '"; s(mc.szName); "', ";
               
                Print "parsed type=[";
               
                If mc.fdwControl & MIXERCONTROL_CONTROLF_UNIFORM Then
                    Print "Uniform ";
                End If

               
                Select Case (mc.dwControlType And MIXERCONTROL_CT_CLASS_MASK)
                Case MIXERCONTROL_CT_CLASS_CUSTOM
                    Print "Custom ";
                Case MIXERCONTROL_CT_CLASS_FADER
                    Print "Fader ";
                Case MIXERCONTROL_CT_CLASS_LIST
                    Print "List ";
                Case MIXERCONTROL_CT_CLASS_METER
                    Print "Meter ";
                Case MIXERCONTROL_CT_CLASS_NUMBER
                    Print "Number ";
                Case MIXERCONTROL_CT_CLASS_SLIDER
                    Print "Slider ";
                Case MIXERCONTROL_CT_CLASS_SWITCH
                    Print "Switch ";
                Case MIXERCONTROL_CT_CLASS_TIME
                    Print "Time ";
                Case Else
                    Print "Unknown ("; hex$(mc.dwControlType And MIXERCONTROL_CT_CLASS_MASK); ") "
                End Select
               
                Select Case mc.dwControlType
                Case MIXERCONTROL_CONTROLTYPE_MIXER
                    Print "Mixer ";
                Case MIXERCONTROL_CONTROLTYPE_MUX
                    Print "Mux ";
                Case MIXERCONTROL_CONTROLTYPE_PEAKMETER
                    Print "PeakMeter ";
                    mcd.cbStruct = Len(mcd)
                    mcd.dwControlID = mc.dwControlID
                    If mc.fdwControl & MIXERCONTROL_CONTROLF_UNIFORM Then
                        mcd.cChannels = 1
                    Else
                        mcd.cChannels = ml.cChannels
                    End If
                    mcd.cbDetails = 4
                    mcd.item = 0
                    mcd.paDetails = String(4 * mcd.cChannels, 0)
                    status = mixerGetControlDetails(i, mcd, MIXER_GETCONTROLDETAILSF_VALUE)
                    For m = 1 To mcd.cChannels
                        Print "peak["; m; "]="; tolong(Mid$(mcd.paDetails, m * 4 - 3)); " ";
                    Next m
                Case MIXERCONTROL_CONTROLTYPE_ONOFF
                    Print "OnOff ";
                Case MIXERCONTROL_CONTROLTYPE_MUTE
                    Print "Mute ";
                Case MIXERCONTROL_CONTROLTYPE_MONO
                    Print "Mono ";
                Case MIXERCONTROL_CONTROLTYPE_LOUDNESS
                    Print "Loudness ";
                Case MIXERCONTROL_CONTROLTYPE_STEREOENH
                    Print "StereoEnh ";
                Case MIXERCONTROL_CONTROLTYPE_VOLUME
                    Print "Volume ";
                Case MIXERCONTROL_CONTROLTYPE_BASS
                    Print "Bass ";
                Case MIXERCONTROL_CONTROLTYPE_TREBLE
                    Print "Treble ";
                Case MIXERCONTROL_CONTROLTYPE_EQUALIZER
                    Print "Equalizer ";
                Case MIXERCONTROL_CONTROLTYPE_PAN
                    Print "Pan ";
                Case MIXERCONTROL_CONTROLTYPE_QSOUNDPAN
                    Print "QSoundPan ";
                End Select
           
           
                Print "]"
           
            Next k
        Next l
    Next j
Next i
End Sub
-------------------------------------------------------------------------
Attribute VB_Name = "Module1"
Public Const MIXER_LONG_NAME_CHARS = 64
Public Const MIXER_SHORT_NAME_CHARS = 16
Public Const MAXPNAMELEN = 32  '  max product name length (including NULL)
Declare Function waveOutGetNumDevs Lib "winmm.dll" () As Long
Declare Function mixerOpen Lib "winmm.dll" (phmx As Long, ByVal uMxId As Long, ByVal dwCallback As Long, ByVal dwInstance As Long, ByVal fdwOpen As Long) As Long
Declare Function mixerClose Lib "winmm.dll" (ByVal hmx As Long) As Long
Declare Function mixerGetControlDetails Lib "winmm.dll" Alias "mixerGetControlDetailsA" (ByVal hmxobj As Long, pmxcd As MIXERCONTROLDETAILS, ByVal fdwDetails As Long) As Long
Declare Function mixerGetLineControls Lib "winmm.dll" Alias "mixerGetLineControlsA" (ByVal hmxobj As Long, pmxlc As MIXERLINECONTROLS, ByVal fdwControls As Long) As Long
Declare Function mixerGetDevCaps Lib "winmm.dll" Alias "mixerGetDevCapsA" (ByVal uMxId As Long, pmxcaps As MIXERCAPS, ByVal cbmxcaps As Long) As Long
Declare Function mixerGetID Lib "winmm.dll" (ByVal hmxobj As Long, pumxID As Long, ByVal fdwId As Long) As Long
Declare Function mixerGetLineInfo Lib "winmm.dll" Alias "mixerGetLineInfoA" (ByVal hmxobj As Long, pmxl As MIXERLINE, ByVal fdwInfo As Long) As Long
Declare Function mixerGetNumDevs Lib "winmm.dll" () As Long
Type MIXERCAPS
        wMid As Integer                   '  manufacturer id
        wPid As Integer                   '  product id
        vDriverVersion As Long            '  version of the driver
        szPname As String * MAXPNAMELEN   '  product name
        fdwSupport As Long             '  misc. support bits
        cDestinations As Long          '  count of destinations
End Type
Type MIXERCONTROL
        cbStruct As Long           '  size in Byte of MIXERCONTROL
        dwControlID As Long        '  unique control id for mixer device
        dwControlType As Long      '  MIXERCONTROL_CONTROLTYPE_xxx
        fdwControl As Long         '  MIXERCONTROL_CONTROLF_xxx
        cMultipleItems As Long     '  if MIXERCONTROL_CONTROLF_MULTIPLE set
        szShortName As String * MIXER_SHORT_NAME_CHARS
        szName As String * MIXER_LONG_NAME_CHARS
        Bounds1 As Long
        Bounds2 As Long
        Bounds3 As Long
        Bounds4 As Long
        Bounds5 As Long
        Bounds6 As Long
        Metrics1 As Long
        Metrics2 As Long
        Metrics3 As Long
        Metrics4 As Long
        Metrics5 As Long
        Metrics6 As Long
End Type
Type MIXERCONTROLDETAILS
        cbStruct As Long       '  size in Byte of MIXERCONTROLDETAILS
        dwControlID As Long    '  control id to get/set details on
        cChannels As Long      '  number of channels in paDetails array
        item As Long                           ' hwndOwner or cMultipleItems
        cbDetails As Long      '  size of _one_ details_XX struct
        paDetails As String 'Long      '  pointer to array of details_XX structs
End Type
Type MIXERCONTROLDETAILS_BOOLEAN
        fValue As Long
End Type
Type MIXERCONTROLDETAILS_LISTTEXT
        dwParam1 As Long
        dwParam2 As Long
        szName As String * MIXER_LONG_NAME_CHARS
End Type
Type MIXERCONTROLDETAILS_SIGNED
        lValue As Long
End Type
Type Target    ' for use in MIXERLINE and others (embedded structure)
       
        dwType As Long                 '  MIXERLINE_TARGETTYPE_xxxx
        dwDeviceID As Long             '  target device ID of device type
        wMid As Integer                   '  of target device
        wPid As Integer                   '       "
        vDriverVersion As Long            '       "
        szPname As String * MAXPNAMELEN
End Type
Type MIXERCONTROLDETAILS_UNSIGNED
        dwValue As Long
End Type
Type MIXERLINE
        cbStruct As Long               '  size of MIXERLINE structure
        dwDestination As Long          '  zero based destination index
        dwSource As Long               '  zero based source index (if source)
        dwLineID As Long               '  unique line id for mixer device
        fdwLine As Long                '  state/information about line
        dwUser As Long                 '  driver specific information
        dwComponentType As Long        '  component type line connects to
        cChannels As Long              '  number of channels line supports
        cConnections As Long           '  number of connections (possible)
        cControls As Long              '  number of controls at this line
        szShortName As String * MIXER_SHORT_NAME_CHARS
        szName As String * MIXER_LONG_NAME_CHARS
        lpTarget As Target
End Type
Type MIXERLINECONTROLS
        cbStruct As Long       '  size in Byte of MIXERLINECONTROLS
        dwLineID As Long       '  line id (from MIXERLINE.dwLineID)
                                             '  MIXER_GETLINECONTROLSF_ONEBYID or
        dwControl As Long  '  MIXER_GETLINECONTROLSF_ONEBYTYPE
        cControls As Long      '  count of controls pmxctrl points to
        cbmxctrl As Long       '  size in Byte of _one_ MIXERCONTROL
        pamxctrl As String 'MIXERCONTROL       '  pointer to first MIXERCONTROL array
End Type
Type buf192
    buf(192) As Byte
End Type
Public Const MIXER_GETCONTROLDETAILSF_LISTTEXT = &H1&
Public Const MIXER_GETCONTROLDETAILSF_QUERYMASK = &HF&
Public Const MIXER_GETCONTROLDETAILSF_VALUE = &H0&
Public Const MIXER_GETLINECONTROLSF_ALL = &H0&
Public Const MIXER_GETLINECONTROLSF_ONEBYID = &H1&
Public Const MIXER_GETLINECONTROLSF_ONEBYTYPE = &H2&
Public Const MIXER_GETLINECONTROLSF_QUERYMASK = &HF&
Public Const MIXER_GETLINEINFOF_COMPONENTTYPE = &H3&
Public Const MIXER_GETLINEINFOF_DESTINATION = &H0&
Public Const MIXER_GETLINEINFOF_LINEID = &H2&
Public Const MIXER_GETLINEINFOF_QUERYMASK = &HF&
Public Const MIXER_GETLINEINFOF_SOURCE = &H1&
Public Const MIXER_GETLINEINFOF_TARGETTYPE = &H4&
Public Const MIXER_OBJECTF_AUX = &H50000000
Public Const MIXER_OBJECTF_HANDLE = &H80000000
Public Const MIXER_OBJECTF_MIDIIN = &H40000000
Public Const MIXER_OBJECTF_MIDIOUT = &H30000000
Public Const MIXER_OBJECTF_MIXER = &H0&
Public Const MIXER_OBJECTF_WAVEIN = &H20000000
Public Const MIXER_OBJECTF_WAVEOUT = &H10000000
Public Const MIXERCONTROL_CT_CLASS_CUSTOM = &H0&
Public Const MIXERCONTROL_CT_CLASS_FADER = &H50000000
Public Const MIXERCONTROL_CT_CLASS_LIST = &H70000000
Public Const MIXERCONTROL_CT_CLASS_MASK = &HF0000000
Public Const MIXERCONTROL_CT_CLASS_METER = &H10000000
Public Const MIXERCONTROL_CT_CLASS_NUMBER = &H30000000
Public Const MIXERCONTROL_CT_CLASS_SLIDER = &H40000000
Public Const MIXERCONTROL_CT_CLASS_SWITCH = &H20000000
Public Const MIXERCONTROL_CT_CLASS_TIME = &H60000000
Public Const MIXERCONTROL_CT_SC_LIST_MULTIPLE = &H1000000
Public Const MIXERCONTROL_CT_SC_LIST_SINGLE = &H0&
Public Const MIXERCONTROL_CT_SC_METER_POLLED = &H0&
Public Const MIXERCONTROL_CT_SC_SWITCH_BOOLEAN = &H0&
Public Const MIXERCONTROL_CT_SC_SWITCH_BUTTON = &H1000000
Public Const MIXERCONTROL_CT_SC_TIME_MICROSECS = &H0&
Public Const MIXERCONTROL_CT_SC_TIME_MILLISECS = &H1000000
Public Const MIXERCONTROL_CT_SUBCLASS_MASK = &HF000000
Public Const MIXERCONTROL_CT_UNITS_BOOLEAN = &H10000
Public Const MIXERCONTROL_CT_UNITS_CUSTOM = &H0&
Public Const MIXERCONTROL_CT_UNITS_DECIBELS = &H40000 '  in 10ths
Public Const MIXERCONTROL_CT_UNITS_MASK = &HFF0000
Public Const MIXERCONTROL_CT_UNITS_PERCENT = &H50000 '  in 10ths
Public Const MIXERCONTROL_CT_UNITS_SIGNED = &H20000
Public Const MIXERCONTROL_CT_UNITS_UNSIGNED = &H30000
Public Const MIXER_OBJECTF_HMIDIIN = (MIXER_OBJECTF_HANDLE Or MIXER_OBJECTF_MIDIIN)
Public Const MIXER_OBJECTF_HMIDIOUT = (MIXER_OBJECTF_HANDLE Or MIXER_OBJECTF_MIDIOUT)
Public Const MIXER_OBJECTF_HMIXER = (MIXER_OBJECTF_HANDLE Or MIXER_OBJECTF_MIXER)
Public Const MIXER_OBJECTF_HWAVEIN = (MIXER_OBJECTF_HANDLE Or MIXER_OBJECTF_WAVEIN)
Public Const MIXER_OBJECTF_HWAVEOUT = (MIXER_OBJECTF_HANDLE Or MIXER_OBJECTF_WAVEOUT)
Public Const MIXER_SETCONTROLDETAILSF_CUSTOM = &H1&
Public Const MIXER_SETCONTROLDETAILSF_QUERYMASK = &HF&
Public Const MIXER_SETCONTROLDETAILSF_VALUE = &H0&
Public Const MIXERCONTROL_CONTROLF_DISABLED = &H80000000
Public Const MIXERCONTROL_CONTROLF_MULTIPLE = &H2&
Public Const MIXERCONTROL_CONTROLF_UNIFORM = &H1&
Public Const MIXERCONTROL_CONTROLTYPE_FADER = (MIXERCONTROL_CT_CLASS_FADER Or MIXERCONTROL_CT_UNITS_UNSIGNED)
Public Const MIXERCONTROL_CONTROLTYPE_MULTIPLESELECT = (MIXERCONTROL_CT_CLASS_LIST Or MIXERCONTROL_CT_SC_LIST_MULTIPLE Or MIXERCONTROL_CT_UNITS_BOOLEAN)
Public Const MIXERCONTROL_CONTROLTYPE_SINGLESELECT = (MIXERCONTROL_CT_CLASS_LIST Or MIXERCONTROL_CT_SC_LIST_SINGLE Or MIXERCONTROL_CT_UNITS_BOOLEAN)
Public Const MIXERCONTROL_CONTROLTYPE_SIGNEDMETER = (MIXERCONTROL_CT_CLASS_METER Or MIXERCONTROL_CT_SC_METER_POLLED Or MIXERCONTROL_CT_UNITS_SIGNED)
Public Const MIXERCONTROL_CONTROLTYPE_SLIDER = (MIXERCONTROL_CT_CLASS_SLIDER Or MIXERCONTROL_CT_UNITS_SIGNED)
Public Const MIXERCONTROL_CONTROLTYPE_BOOLEAN = (MIXERCONTROL_CT_CLASS_SWITCH Or MIXERCONTROL_CT_SC_SWITCH_BOOLEAN Or MIXERCONTROL_CT_UNITS_BOOLEAN)
Public Const MIXERCONTROL_CONTROLTYPE_BOOLEANMETER = (MIXERCONTROL_CT_CLASS_METER Or MIXERCONTROL_CT_SC_METER_POLLED Or MIXERCONTROL_CT_UNITS_BOOLEAN)
Public Const MIXERCONTROL_CONTROLTYPE_BUTTON = (MIXERCONTROL_CT_CLASS_SWITCH Or MIXERCONTROL_CT_SC_SWITCH_BUTTON Or MIXERCONTROL_CT_UNITS_BOOLEAN)
Public Const MIXERCONTROL_CONTROLTYPE_CUSTOM = (MIXERCONTROL_CT_CLASS_CUSTOM Or MIXERCONTROL_CT_UNITS_CUSTOM)
Public Const MIXERCONTROL_CONTROLTYPE_DECIBELS = (MIXERCONTROL_CT_CLASS_NUMBER Or MIXERCONTROL_CT_UNITS_DECIBELS)
Public Const MIXERCONTROL_CONTROLTYPE_MICROTIME = (MIXERCONTROL_CT_CLASS_TIME Or MIXERCONTROL_CT_SC_TIME_MICROSECS Or MIXERCONTROL_CT_UNITS_UNSIGNED)
Public Const MIXERCONTROL_CONTROLTYPE_MILLITIME = (MIXERCONTROL_CT_CLASS_TIME Or MIXERCONTROL_CT_SC_TIME_MILLISECS Or MIXERCONTROL_CT_UNITS_UNSIGNED)

Public Const MIXERCONTROL_CONTROLTYPE_MIXER = (MIXERCONTROL_CONTROLTYPE_MULTIPLESELECT + 1)

Public Const MIXERCONTROL_CONTROLTYPE_MUX = (MIXERCONTROL_CONTROLTYPE_SINGLESELECT + 1)

Public Const MIXERCONTROL_CONTROLTYPE_PAN = (MIXERCONTROL_CONTROLTYPE_SLIDER + 1)
Public Const MIXERCONTROL_CONTROLTYPE_QSOUNDPAN = (MIXERCONTROL_CONTROLTYPE_SLIDER + 2)

Public Const MIXERCONTROL_CONTROLTYPE_PEAKMETER = (MIXERCONTROL_CONTROLTYPE_SIGNEDMETER + 1)

Public Const MIXERCONTROL_CONTROLTYPE_ONOFF = (MIXERCONTROL_CONTROLTYPE_BOOLEAN + 1)
Public Const MIXERCONTROL_CONTROLTYPE_MUTE = (MIXERCONTROL_CONTROLTYPE_BOOLEAN + 2)
Public Const MIXERCONTROL_CONTROLTYPE_MONO = (MIXERCONTROL_CONTROLTYPE_BOOLEAN + 3)
Public Const MIXERCONTROL_CONTROLTYPE_LOUDNESS = (MIXERCONTROL_CONTROLTYPE_BOOLEAN + 4)
Public Const MIXERCONTROL_CONTROLTYPE_STEREOENH = (MIXERCONTROL_CONTROLTYPE_BOOLEAN + 5)

Public Const MIXERCONTROL_CONTROLTYPE_VOLUME = (MIXERCONTROL_CONTROLTYPE_FADER + 1)
Public Const MIXERCONTROL_CONTROLTYPE_BASS = (MIXERCONTROL_CONTROLTYPE_FADER + 2)
Public Const MIXERCONTROL_CONTROLTYPE_TREBLE = (MIXERCONTROL_CONTROLTYPE_FADER + 3)
Public Const MIXERCONTROL_CONTROLTYPE_EQUALIZER = (MIXERCONTROL_CONTROLTYPE_FADER + 4)

Public Const MIXERCONTROL_CONTROLTYPE_UNSIGNED = (MIXERCONTROL_CT_CLASS_NUMBER Or MIXERCONTROL_CT_UNITS_UNSIGNED)
Public Const MIXERCONTROL_CONTROLTYPE_UNSIGNEDMETER = (MIXERCONTROL_CT_CLASS_METER Or MIXERCONTROL_CT_SC_METER_POLLED Or MIXERCONTROL_CT_UNITS_UNSIGNED)
Public Const MIXERCONTROL_CONTROLTYPE_PERCENT = (MIXERCONTROL_CT_CLASS_NUMBER Or MIXERCONTROL_CT_UNITS_PERCENT)
Public Const MIXERCONTROL_CONTROLTYPE_SIGNED = (MIXERCONTROL_CT_CLASS_NUMBER Or MIXERCONTROL_CT_UNITS_SIGNED)

Public Const MIXERLINE_COMPONENTTYPE_DST_FIRST = &H0&
Public Const MIXERLINE_COMPONENTTYPE_DST_DIGITAL = (MIXERLINE_COMPONENTTYPE_DST_FIRST + 1)
Public Const MIXERLINE_COMPONENTTYPE_DST_HEADPHONES = (MIXERLINE_COMPONENTTYPE_DST_FIRST + 5)
Public Const MIXERLINE_COMPONENTTYPE_DST_LAST = (MIXERLINE_COMPONENTTYPE_DST_FIRST + 8)
Public Const MIXERLINE_COMPONENTTYPE_DST_LINE = (MIXERLINE_COMPONENTTYPE_DST_FIRST + 2)
Public Const MIXERLINE_COMPONENTTYPE_DST_MONITOR = (MIXERLINE_COMPONENTTYPE_DST_FIRST + 3)
Public Const MIXERLINE_COMPONENTTYPE_DST_SPEAKERS = (MIXERLINE_COMPONENTTYPE_DST_FIRST + 4)
Public Const MIXERLINE_COMPONENTTYPE_DST_TELEPHONE = (MIXERLINE_COMPONENTTYPE_DST_FIRST + 6)
Public Const MIXERLINE_COMPONENTTYPE_DST_UNDEFINED = (MIXERLINE_COMPONENTTYPE_DST_FIRST + 0)
Public Const MIXERLINE_COMPONENTTYPE_DST_WAVEIN = (MIXERLINE_COMPONENTTYPE_DST_FIRST + 7)
Public Const MIXERLINE_COMPONENTTYPE_DST_VOICEIN = (MIXERLINE_COMPONENTTYPE_DST_FIRST + 8)
Public Const MIXERLINE_COMPONENTTYPE_SRC_FIRST = &H1000&
Public Const MIXERLINE_COMPONENTTYPE_SRC_ANALOG = (MIXERLINE_COMPONENTTYPE_SRC_FIRST + 10)
Public Const MIXERLINE_COMPONENTTYPE_SRC_AUXILIARY = (MIXERLINE_COMPONENTTYPE_SRC_FIRST + 9)
Public Const MIXERLINE_COMPONENTTYPE_SRC_COMPACTDISC = (MIXERLINE_COMPONENTTYPE_SRC_FIRST + 5)
Public Const MIXERLINE_COMPONENTTYPE_SRC_DIGITAL = (MIXERLINE_COMPONENTTYPE_SRC_FIRST + 1)
Public Const MIXERLINE_COMPONENTTYPE_SRC_LAST = (MIXERLINE_COMPONENTTYPE_SRC_FIRST + 10)
Public Const MIXERLINE_COMPONENTTYPE_SRC_LINE = (MIXERLINE_COMPONENTTYPE_SRC_FIRST + 2)
Public Const MIXERLINE_COMPONENTTYPE_SRC_MICROPHONE = (MIXERLINE_COMPONENTTYPE_SRC_FIRST + 3)
Public Const MIXERLINE_COMPONENTTYPE_SRC_PCSPEAKER = (MIXERLINE_COMPONENTTYPE_SRC_FIRST + 7)
Public Const MIXERLINE_COMPONENTTYPE_SRC_SYNTHESIZER = (MIXERLINE_COMPONENTTYPE_SRC_FIRST + 4)
Public Const MIXERLINE_COMPONENTTYPE_SRC_TELEPHONE = (MIXERLINE_COMPONENTTYPE_SRC_FIRST + 6)
Public Const MIXERLINE_COMPONENTTYPE_SRC_UNDEFINED = (MIXERLINE_COMPONENTTYPE_SRC_FIRST + 0)
Public Const MIXERLINE_COMPONENTTYPE_SRC_WAVEOUT = (MIXERLINE_COMPONENTTYPE_SRC_FIRST + 8)
Public Const MIXERLINE_LINEF_ACTIVE = &H1&
Public Const MIXERLINE_LINEF_DISCONNECTED = &H8000&
Public Const MIXERLINE_LINEF_SOURCE = &H80000000
Public Const MIXERLINE_TARGETTYPE_AUX = 5
Public Const MIXERLINE_TARGETTYPE_MIDIIN = 4
Public Const MIXERLINE_TARGETTYPE_MIDIOUT = 3
Public Const MIXERLINE_TARGETTYPE_UNDEFINED = 0
Public Const MIXERLINE_TARGETTYPE_WAVEIN = 2
Public Const MIXERLINE_TARGETTYPE_WAVEOUT = 1

Function hex$(d As Long)
    Dim s As String
    Dim i As Integer
    s = ""
    For i = 7 To 0 Step -1
        s = s & hexdig((d / (2 ^ (i * 4))) And &HF)
    Next i
    hex$ = s
End Function

Function hexdig$(d As Long)
    d = d And &HF
    If d >= 10 Then hexdig$ = Chr(Asc("A") + d - 10) Else hexdig = Chr(Asc("0") + d)
End Function


Function s(sz As String) As String
    If InStr(sz, Chr(0)) Then
        s = Left$(sz, InStr(sz, Chr(0)) - 1)
    Else
        s = sz
    End If
End Function


Function tolong(s As String) As Long
If Asc(Mid$(s, 4)) And &H80 Then
    tolong = &H80000000 + (Asc(Mid$(s, 4)) And &H7F) * 2 ^ 24 + Asc(Mid$(s, 3)) * 2 ^ 16 + Asc(Mid$(s, 2)) * 2 ^ 8 + Asc(Mid$(s, 1))
Else
    tolong = (Asc(Mid$(s, 4)) And &H7F) * 2 ^ 24 + Asc(Mid$(s, 3)) * 2 ^ 16 + Asc(Mid$(s, 2)) * 2 ^ 8 + Asc(Mid$(s, 1))
End If
End Function
-------------------------------------------------------------------------






0
 
LVL 5

Expert Comment

by:y96andha
ID: 1426244
A peak meter is not available on all sound cards. It is not available on mine under Windows NT 4.0, but it is available under Windows 95. I have a SB32 PnP.
0
 

Author Comment

by:shurme
ID: 1426245
Thanks a zillion!
The source really works and it's very easy to follow. I asked how to do "VU-meter" and I got an example on how to tame the whole friggin' Mixer. :) Thanks again! Great work!

I think the source should be added to some VB/API faq's.

0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now