Solved

VU-Meter API-Controll, Returns Peak-Values

Posted on 1998-05-11
4
1,353 Views
Last Modified: 2008-02-01
Thanks for mutch Answers.
Sorry don't the right Anwers in the list.

I will a VU-Meter (Audio-Level-Meter)  VB5 Listing to get a Audio Peak Values
back.
I have a API-Listing from Experts-Exchange, this is not
funktionable. The Values back is 0

Pleas send me a runtime-Demo of my problem !!

Thank´s
0
Comment
Question by:berlet
  • 2
  • 2
4 Comments
 

Author Comment

by:berlet
ID: 1445690
Edited text of question
0
 

Accepted Solution

by:
afonso earned 100 total points
ID: 1445691
To buy a PEAK METER, you must know if the driver of your sound card supports it. Generally
they do, but only for playing or recording wave files.
If this is what you want, first of all, you have to know the ID of the PEAK METER, for recording and playing (in my sound card there is one for each purpose).
The following program display the information concerning your mixer:
Build a form with a big picture box (Picture1) where the data will be displayed (printed). Put a command button, to launch the checking procedures. Put four text boxes to enter desired control to check.
A brief explanation about the internal mixer:
It has destination lines (speakers, wave...) - (first text box)
and the respective controls (volume, bass, treble...) - (second text box)
The source lines (CD, wave, microphone...) - (third text box)
and the controls (volume, mute...) - (fourth text box)
So, if you want to know the data about a specific control, you have to enter the correspondent  numbers.
For example: on my internal mixer, the output (destination) for speakers, is number 0, the volume control is number 0, the CD input (source) line is number 2 and the volume control for CD input is number 0.
Using the try an error method, you can find data, including the ID (in hexa) of almost all controls. This code don't shows the data about multiple controls, as for example the mute controls for recording input.
Part of this program is written in portuguese (my own idiom) but I guess it is easy to understand, because the data itself is displayed in the idiom of your driver is written.
Finally there is a routine in the code that readas the data of a control, using the API call GetMixerControlDetails. Using this function with the PEAK METER ID, you will retrave tre current value, and display it.

'------------------------------------------------------------------------------------------------------------------------------
' This code to a MODULE (*.BAS)

Option Explicit

Public Const MAXPNAMELEN = 32  '  max product name length (including NULL)
Public Const MIXER_LONG_NAME_CHARS = 64
Public Const MIXER_SHORT_NAME_CHARS = 16


Declare Function mixerGetDevCaps Lib "winmm.dll" Alias "mixerGetDevCapsA" (ByVal uMxId As Long, pmxcaps As MIXERCAPS, ByVal cbmxcaps 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 mixerGetLineControls Lib "winmm.dll" Alias "mixerGetLineControlsA" (ByVal hmxobj As Long, pmxlc As MIXERLINECONTROLS, ByVal fdwControls 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

    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

    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 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 Len(s) > 3 Then
    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 If
    End Function
'---------------------------------------------------------------------------------------------------------------------------
' This code to a FORM
Option Explicit

Private Sub Command1_Click()
    Dim ml As MIXERLINE
    Dim mcs As MIXERCAPS
    Dim mlc As MIXERLINECONTROLS
    Dim mc As MIXERCONTROL
    Dim mcd As MIXERCONTROLDETAILS
   
    Dim Dummy As Integer
    Dim MixNo As Long
    Dim DestNo As Long
    Dim ControlNo As Long
    Dim mcsize As Integer
    Dim EntradaNo As Long
    Dim CtrlEntradaNo As Long
   
    Picture1.Cls
    Picture1.Print
    mcsize = LenB(mc)
'------------ mixerGetCevCaps ------------------------------
    MixNo = 0
       
    Dummy = mixerGetDevCaps(MixNo, mcs, LenB(mcs))
    Picture1.Print " Mixer n:"; LTrim(Str$(MixNo)); ": "; s(mcs.szPname)
    Picture1.Print "      Linhas samda:" & Str$(mcs.cDestinations)
    Picture1.Print
'-------------  Destination: mixerGetLineInfo ----------------------
    DestNo = Val(TxtlinSaida.Text)
   
    ml.cbStruct = LenB(ml)
    ml.dwDestination = DestNo
    ml.dwSource = 0
    Dummy = mixerGetLineInfo(MixNo, ml, MIXER_GETLINEINFOF_DESTINATION)
    Picture1.Print " Saida n:"; LTrim(Str$(DestNo)); ": "; s(ml.szName); " [ ID = "; Hex$(ml.dwLineID); " ]"
    Picture1.Print "      Entradas:"; Str$(ml.cConnections)
    Picture1.Print "      Canais:"; Str$(ml.cChannels)
'--------------- mixerGetLineControls --------------------------------

    mlc.cbStruct = LenB(mlc)
    mlc.dwLineID = ml.dwLineID
    mlc.cControls = ml.cControls
    mlc.cbmxctrl = LenB(mc)
    mlc.pamxctrl = String(LenB(mc) * ml.cControls, 0)
    Dummy = mixerGetLineControls(MixNo, mlc, MIXER_GETLINECONTROLSF_ALL)
    Picture1.Print "      Controles:"; Str$(mlc.cControls)
    Picture1.Print
               
'---------------------- Printing control data ----------------
    ControlNo = Val(TxtCtrlSaida.Text)
   
    Picture1.Print " Controle de samda N:"; LTrim(Str$(ControlNo)); ": ";
    mc.dwControlID = tolong(Mid$(mlc.pamxctrl, ControlNo * mcsize + 1 + 4))
    mc.dwControlType = tolong(Mid$(mlc.pamxctrl, ControlNo * mcsize + 1 + 2 * 4))
    mc.szShortName = Mid$(mlc.pamxctrl, ControlNo * mcsize + 1 + 5 * 4, MIXER_SHORT_NAME_CHARS)
    mc.szName = Mid$(mlc.pamxctrl, ControlNo * mcsize + 1 + 5 * 4 + MIXER_SHORT_NAME_CHARS, MIXER_LONG_NAME_CHARS)
    Picture1.Print s(mc.szShortName); " = "; s(mc.szName); " [ ID = "; Hex$(mc.dwControlID); " ]"
    Picture1.Print "      parsed type = [ ";
    If mc.fdwControl & MIXERCONTROL_CONTROLF_UNIFORM Then
        Picture1.Print "Uniform ";
    End If
    Select Case (mc.dwControlType And MIXERCONTROL_CT_CLASS_MASK)
    Case MIXERCONTROL_CT_CLASS_CUSTOM
        Picture1.Print "Custom ";
    Case MIXERCONTROL_CT_CLASS_FADER
        Picture1.Print "Fader ";
    Case MIXERCONTROL_CT_CLASS_LIST
        Picture1.Print "List ";
    Case MIXERCONTROL_CT_CLASS_METER
        Picture1.Print "Meter ";
    Case MIXERCONTROL_CT_CLASS_NUMBER
        Picture1.Print "Number ";
    Case MIXERCONTROL_CT_CLASS_SLIDER
        Picture1.Print "Slider ";
    Case MIXERCONTROL_CT_CLASS_SWITCH
        Picture1.Print "Switch ";
    Case MIXERCONTROL_CT_CLASS_TIME
        Picture1.Print "Time ";
    Case Else
        Picture1.Print "Unknown ("; Hex$(mc.dwControlType And MIXERCONTROL_CT_CLASS_MASK); ") "
    End Select
   
    Select Case mc.dwControlType
    Case MIXERCONTROL_CONTROLTYPE_MIXER
        Picture1.Print "Mixer ";
    Case MIXERCONTROL_CONTROLTYPE_MUX
        Picture1.Print "Mux ";
    Case MIXERCONTROL_CONTROLTYPE_PEAKMETER
        Picture1.Print "PeakMeter ";
    Case MIXERCONTROL_CONTROLTYPE_ONOFF
        Picture1.Print "OnOff ";
    Case MIXERCONTROL_CONTROLTYPE_MUTE
        Picture1.Print "Mute ";
    Case MIXERCONTROL_CONTROLTYPE_MONO
        Picture1.Print "Mono ";
    Case MIXERCONTROL_CONTROLTYPE_LOUDNESS
        Picture1.Print "Loudness ";
    Case MIXERCONTROL_CONTROLTYPE_STEREOENH
        Picture1.Print "StereoEnh ";
    Case MIXERCONTROL_CONTROLTYPE_VOLUME
        Picture1.Print "Volume ";
    Case MIXERCONTROL_CONTROLTYPE_BASS
        Picture1.Print "Bass ";
    Case MIXERCONTROL_CONTROLTYPE_TREBLE
        Picture1.Print "Treble ";
    Case MIXERCONTROL_CONTROLTYPE_EQUALIZER
        Picture1.Print "Equalizer ";
    Case MIXERCONTROL_CONTROLTYPE_PAN
        Picture1.Print "Pan ";
    Case MIXERCONTROL_CONTROLTYPE_QSOUNDPAN
        Picture1.Print "QSoundPan ";
    End Select
    Picture1.Print "]"
 '--------------------- mixerGetControlDetails ----------------------
                   
    mcd.cbStruct = Len(mcd)
    mcd.dwControlID = mc.dwControlID
    mcd.cChannels = ml.cChannels
    If mc.dwControlType = MIXERCONTROL_CONTROLTYPE_MUTE Then mcd.cChannels = 1
    mcd.cbDetails = 4
    mcd.item = 0
    mcd.paDetails = String$(4 * mcd.cChannels, 0)
    Dummy = mixerGetControlDetails(MixNo, mcd, MIXER_GETCONTROLDETAILSF_VALUE)
    Picture1.Print "      Canal[1] ="; tolong(Mid$(mcd.paDetails, 1, 4))
    If mcd.cChannels > 1 Then Picture1.Print "      Canal[2] ="; tolong(Mid$(mcd.paDetails, 5))
    Picture1.Print
   
'------------------------- Source: mixerGetLineInfo ------------------
    EntradaNo = Val(txtLinEntrada.Text)
   
    ml.dwSource = EntradaNo
    Dummy = mixerGetLineInfo(MixNo, ml, MIXER_GETLINEINFOF_SOURCE)
    Picture1.Print " Entrada n:"; LTrim(Str$(EntradaNo)); ": "; s(ml.szShortName); " = "; s(ml.szName); " [ ID = "; Hex$(ml.dwLineID); " ]"
    Picture1.Print "      Canais: "; ml.cChannels
    Picture1.Print "      Controles: "; 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)
    Picture1.Print
'------------------ Controles de Entrada mixerGetLineControls ---------
    CtrlEntradaNo = Val(txtCtrlEntrada.Text)
   
    Dummy = mixerGetLineControls(MixNo, mlc, MIXER_GETLINECONTROLSF_ALL)

    mc.dwControlID = tolong(Mid$(mlc.pamxctrl, CtrlEntradaNo * mcsize + 1 + 4))
    mc.dwControlType = tolong(Mid$(mlc.pamxctrl, CtrlEntradaNo * mcsize + 1 + 2 * 4))
    mc.fdwControl = tolong(Mid$(mlc.pamxctrl, CtrlEntradaNo * mcsize + 1 + 3 * 4))
    mc.szShortName = Mid$(mlc.pamxctrl, CtrlEntradaNo * mcsize + 1 + 5 * 4, MIXER_SHORT_NAME_CHARS)
    mc.szName = Mid$(mlc.pamxctrl, CtrlEntradaNo * mcsize + 1 + 5 * 4 + MIXER_SHORT_NAME_CHARS, MIXER_LONG_NAME_CHARS)
    Picture1.Print " Controle de entrada n:"; LTrim(Str$(CtrlEntradaNo)); ": "; s(mc.szShortName); " = "; s(mc.szName); " ";
    Picture1.Print " [ ID = "; Hex$(mc.dwControlID); " ]"
    Picture1.Print "      parsed type = [ ";
    If mc.fdwControl & MIXERCONTROL_CONTROLF_UNIFORM Then
        Picture1.Print "Uniform ";
    End If
    Select Case (mc.dwControlType And MIXERCONTROL_CT_CLASS_MASK)
        Case MIXERCONTROL_CT_CLASS_CUSTOM
            Picture1.Print "Custom ";
        Case MIXERCONTROL_CT_CLASS_FADER
            Picture1.Print "Fader ";
        Case MIXERCONTROL_CT_CLASS_LIST
            Picture1.Print "List ";
        Case MIXERCONTROL_CT_CLASS_METER
            Picture1.Print "Meter ";
        Case MIXERCONTROL_CT_CLASS_NUMBER
            Picture1.Print "Number ";
        Case MIXERCONTROL_CT_CLASS_SLIDER
            Picture1.Print "Slider ";
        Case MIXERCONTROL_CT_CLASS_SWITCH
            Picture1.Print "Switch ";
        Case MIXERCONTROL_CT_CLASS_TIME
            Picture1.Print "Time ";
        Case Else
            Picture1.Print "Unknown ("; Hex$(mc.dwControlType And MIXERCONTROL_CT_CLASS_MASK); ") "
    End Select
   
    Select Case mc.dwControlType
        Case MIXERCONTROL_CONTROLTYPE_MIXER
            Picture1.Print "Mixer ";
        Case MIXERCONTROL_CONTROLTYPE_MUX
            Picture1.Print "Mux ";
        Case MIXERCONTROL_CONTROLTYPE_PEAKMETER
            Picture1.Print "PeakMeter ";
        Case MIXERCONTROL_CONTROLTYPE_ONOFF
            Picture1.Print "OnOff ";
        Case MIXERCONTROL_CONTROLTYPE_MUTE
            Picture1.Print "Mute ";
        Case MIXERCONTROL_CONTROLTYPE_MONO
            Picture1.Print "Mono ";
        Case MIXERCONTROL_CONTROLTYPE_LOUDNESS
            Picture1.Print "Loudness ";
        Case MIXERCONTROL_CONTROLTYPE_STEREOENH
            Picture1.Print "StereoEnh ";
        Case MIXERCONTROL_CONTROLTYPE_VOLUME
            Picture1.Print "Volume ";
        Case MIXERCONTROL_CONTROLTYPE_BASS
            Picture1.Print "Bass ";
        Case MIXERCONTROL_CONTROLTYPE_TREBLE
            Picture1.Print "Treble ";
        Case MIXERCONTROL_CONTROLTYPE_EQUALIZER
            Picture1.Print "Equalizer ";
        Case MIXERCONTROL_CONTROLTYPE_PAN
            Picture1.Print "Pan ";
        Case MIXERCONTROL_CONTROLTYPE_QSOUNDPAN
            Picture1.Print "QSoundPan ";
    End Select
    Picture1.Print " ]"
   
'----------- mixerGetControlDetails ---------------------------------
    mcd.cbStruct = Len(mcd)
    mcd.dwControlID = mc.dwControlID
    mcd.cChannels = ml.cChannels
    If mc.dwControlType = MIXERCONTROL_CONTROLTYPE_MUTE Then mcd.cChannels = 1
    mcd.cbDetails = 4
    mcd.item = 0
    mcd.paDetails = String$(4 * mcd.cChannels, 0)
    Dummy = mixerGetControlDetails(MixNo, mcd, MIXER_GETCONTROLDETAILSF_VALUE)
    Picture1.Print "      Canal[1] ="; tolong(Mid$(mcd.paDetails, 1, 4))
    If mcd.cChannels > 1 Then Picture1.Print "      Canal[2] ="; tolong(Mid$(mcd.paDetails, 5))
   
End Sub
'---------------------------------------------------------------------------------------------------------------------------

In the other hand, if you want to build a PEAK METER to display the sound of othet sources than wave files, (ex: CD, MIDI, Mic...) it is another story.
The only way I found to perform this was sampling the source, writing it in buffers and using this data to activate the peak meter display in the screen. To do the job, I used the WAVE IN functions as if I was recording the sound, but don't writing the data to the disk.

There is no enough space here to send you the code. I will try answering again your question.

Afonso

0
 

Expert Comment

by:afonso
ID: 1445692

In the other hand, if you want to build a PEAK METER to display the sound of othet sources than wave files, (ex: CD, MIDI, Mic...) it is another story.
The only way I found to perform this was sampling the source, writing it in buffers and using this data to activate the peak meter display in the screen. To do the job, I used the WAVE IN functions as if I was recording the sound, but don't writing the data to the disk. The following code does the job.

'----------------------------------------------------------------------------------------------------------------------------
'Code to sample a CD music and control a PEAK METER
'Copy this code to a MODULE (.BAS)
'----------------------------------------------------------------------------------------------------------------------------
Option Explicit

Public Const WAVE_BUFSIZE = 4             'Sample buffer size - make it the best size for your                               'purposes
Public Const WAVE_MAPPER = -1
Public Const WAVE_ALLOWSYNC = &H2
Public Const CALLBACK_FUNCTION = &H30000
Public Const GMEM_MOVEABLE = &H2
Public Const GMEM_SHARE = &H2000
Public Const GMEM_ZEROINIT = &H40
Public Const WAVE_FORMAT_PCM = 1
Public Const MM_WIM_DATA = &H3C0

Type WAVEHDR
    lpData As Long                 '  pointer to locked data buffer
    dwBufferLength As Long         '  length of data buffer
    dwBytesRecorded As Long        '  used for input only
    dwUser As Long                 '  for client's use
    dwFlags As Long                '  assorted flags (see defines)
    dwLoops As Long                '  loop control counter
    wavehdr_tag As Long            '  reserved for driver
    reserved As Long               '  reserved for driver
End Type

Type WAVEFORMATEX
    wFormatTag As Integer     '  format type
    nChannels As Integer      '  number of channels (i.e. mono, stereo, etc.)
    nSamplesPerSec As Long    '  sample rate
    nAvgBytesPerSec As Long   '  for buffer estimation
    nBlockAlign As Integer    '  block size of data
    wBitsPerSample As Integer
    cbSize As Integer
End Type


Declare Function waveInAddBuffer Lib "winmm.dll" (ByVal hWaveIn As Long, lpWaveInHdr As WAVEHDR, ByVal uSize As Long) As Long
Declare Function waveInClose Lib "winmm.dll" (ByVal hWaveIn As Long) As Long
Declare Function waveInGetNumDevs Lib "winmm.dll" () As Long
Declare Function waveInOpen Lib "winmm.dll" (lphWaveIn As Long, ByVal uDeviceID As Long, lpFormat As WAVEFORMATEX, ByVal dwCallback As Long, ByVal dwInstance As Long, ByVal dwFlags As Long) As Long
Declare Function waveInPrepareHeader Lib "winmm.dll" (ByVal hWaveIn As Long, lpWaveInHdr As WAVEHDR, ByVal uSize As Long) As Long
Declare Function waveInReset Lib "winmm.dll" (ByVal hWaveIn As Long) As Long
Declare Function waveInStart Lib "winmm.dll" (ByVal hWaveIn As Long) As Long
Declare Function waveInUnprepareHeader Lib "winmm.dll" (ByVal hWaveIn As Long, lpWaveInHdr As WAVEHDR, ByVal uSize As Long) As Long
Declare Function GlobalAlloc Lib "kernel32" (ByVal wFlags As Long, ByVal dwBytes As Long) As Long
Declare Function GlobalLock Lib "kernel32" (ByVal hMem As Long) As Long
Declare Function GlobalUnlock Lib "kernel32" (ByVal hMem As Long) As Long
Declare Function GlobalFree Lib "kernel32" (ByVal hMem As Long) As Long
Declare Sub CopyStructFromPtr Lib "kernel32" Alias "RtlMoveMemory" (struct As Any, ByVal ptr As Long, ByVal cb As Long)

Dim wh(1) As WAVEHDR
Dim wf As WAVEFORMATEX
Dim WaveBufSize As Integer          'size of buffer as multiple of
                                    'nBlockAlign header field

Dim bDeviceOpen As Integer          'flag for opened record device
Dim pWaveHdr(1) As Long             'pointer to WAVEHEADER
Dim hWaveHdr(1) As Long             'handle for WAVEHEADER
Dim hWaveIn As Long                 'handle for the record device
Dim pFormatEx As Long               'pointer to WAVEFORMATEX
Dim hFormatEx As Long               'handle for WAVEFORMATEX
Dim pWaveMem(1) As Long             'pointer to memory buffer
Dim hWaveMem(1) As Long             'handle for memory buffer
Public ModeFlag As Integer             'true if recording
Public bufindex As Integer             'controls wich wave buffer we're using

'Zero out the wave headers and initialize the data pointers and
' buffer lenghts (returns nothing)
Sub InitWaveHeaders()
    Dim Index As Integer
    'make the wave buffer size as multiple of the block align...
    WaveBufSize = WAVE_BUFSIZE - (WAVE_BUFSIZE Mod wf.nBlockAlign)
    'zero out the wave headers...
    For Index = 0 To 1
        wh(Index).lpData = 0
        wh(Index).dwBufferLength = 0
        wh(Index).dwBytesRecorded = 0
        wh(Index).dwUser = 0
        wh(Index).dwFlags = 0
        wh(Index).dwLoops = 0
        wh(Index).wavehdr_tag = 0
        wh(Index).reserved = 0
    Next Index
    'now init the data pointers and buffer lenghts...
    wh(0).dwBufferLength = WaveBufSize
    wh(1).dwBufferLength = WaveBufSize
    wh(0).lpData = pWaveMem(0)
    wh(1).lpData = pWaveMem(1)
End Sub

'Allocate format and wave headers and data buffers.
'Returns zero or errorcode
Function InitWaveRecorder() As Integer
    'allocate memory for wave format structure...
    If (AllocWaveFormatEx()) Then
        InitWaveRecorder = 1
        Exit Function
    End If
    'find a device compatible with the available wave characteristics...
    If waveInGetNumDevs() < 1 Then
        InitWaveRecorder = 2
        Exit Function
    End If
    'allocate the wave header memory...
    If (AllocWaveHeader()) Then
        InitWaveRecorder = 3
        Exit Function
    End If
    'allocate the wave data buffer memory...
    If (AllocPCMBuffers()) Then
        InitWaveRecorder = 4
        Exit Function
    End If
    InitWaveRecorder = 0
End Function

'Free the memory associated with the wave buffers (returns nothing)
Sub DestroyWaveRecorder()
    Call FreeWaveFormatEx
    Call FreePCMBuffers
    Call FreeWaveHeader
End Sub

'Prepare headers, add buffer and start recording
' returns zero if no error
Function StartWaveRecord() As Integer
    Dim ReturnValue As Long
    bufindex = 0
    'open the device for recording...
    hWaveIn = 0
    If waveInOpen(hWaveIn, WAVE_MAPPER, wf, AddressOf WaveInProc, 0, CALLBACK_FUNCTION Or WAVE_ALLOWSYNC) Then
        Call CloseWaveDeviceRecord
        StartWaveRecord = 1
        Exit Function
    End If
    'tell CloseWaveDeviceRecord() that the device is open...
    bDeviceOpen = True
    'prepare the headers...
    Call InitWaveHeaders
    If (waveInPrepareHeader(hWaveIn, wh(0), Len(wh(0)))) Then
        StartWaveRecord = 2
        Call CloseWaveDeviceRecord
        Exit Function
    End If
    If (waveInPrepareHeader(hWaveIn, wh(1), Len(wh(1)))) Then
        StartWaveRecord = 2
        Call CloseWaveDeviceRecord
        Exit Function
    End If
    'add the first buffer...
    If AddNextBuffer() Then
        StartWaveRecord = 3
        Exit Function
    End If
    'start recording first buffer...
    If (waveInStart(hWaveIn)) Then
        StartWaveRecord = 4
        Call CloseWaveDeviceRecord
        Exit Function
    End If
    ModeFlag = True
    'queue the next buffer...
    If (AddNextBuffer()) Then
        StartWaveRecord = 5
        Exit Function
    End If
    StartWaveRecord = 0
End Function

'Add the buffer to the wave input queue and toggle buffer index
'This routine is called from the main window proc (WinProc)
Function AddNextBuffer() As Integer
    'queue buffer for input...
    If waveInAddBuffer(hWaveIn, wh(bufindex), Len(wh(bufindex))) Then
        AddNextBuffer = 1
        Call StopWaveRecord
        Exit Function
    End If
    'toggle for the next buffer...
    bufindex = 1 - bufindex
    Call GetStereo16Sample
    AddNextBuffer = 0
End Function

'Stop the recording
Sub StopWaveRecord()
    Dim ReturnValue As Integer
    'set the flag before stopping since it's used in the MM_WIM_DATA
    'message in our main window proc to control whether we add
    'another buffer...
    ModeFlag = False
    'stop recording and return queued buffers...
    ReturnValue = waveInReset(hWaveIn)
End Sub

'Close wave recording device
Sub CloseWaveDeviceRecord()
    Dim ReturnValue As Integer
    'if the device is already closed, just return...
    If Not bDeviceOpen Then Exit Sub
    'unprepare the headers
    ReturnValue = waveInUnprepareHeader(hWaveIn, wh(0), Len(wh(0)))
    ReturnValue = waveInUnprepareHeader(hWaveIn, wh(1), Len(wh(1)))
    'close the wave input device
    ReturnValue = waveInClose(hWaveIn)
    'tell this function we are now closed
    bDeviceOpen = False
End Sub

'Allocate and lock WAVEFORMATEX structure
Function AllocWaveFormatEx() As Integer
    'allocate the WAVEFORMATEX...
    hFormatEx = GlobalAlloc(GMEM_MOVEABLE, Len(wf))
    pFormatEx = GlobalLock(hFormatEx)
    If hFormatEx = 0 Or pFormatEx = 0 Then
        AllocWaveFormatEx = 1
        Exit Function
    End If
    'initialize the format to standard PCM
    wf.wFormatTag = WAVE_FORMAT_PCM
    wf.nChannels = 2
    wf.nSamplesPerSec = 11025
    wf.nAvgBytesPerSec = 44100
    wf.nBlockAlign = 4
    wf.wBitsPerSample = 16
    wf.cbSize = 0
    AllocWaveFormatEx = 0
End Function

'Free the WAVEFORMATEX buffer
Sub FreeWaveFormatEx()
    Dim ReturnValue As Integer
    ReturnValue = GlobalUnlock(hFormatEx)
    ReturnValue = GlobalFree(hFormatEx)
    hFormatEx = 0
End Sub

'Allocate and lock header memory
Function AllocWaveHeader() As Integer
    Dim Index As Integer
    For Index = 0 To 1
        hWaveHdr(Index) = GlobalAlloc(GMEM_MOVEABLE Or GMEM_SHARE Or GMEM_ZEROINIT, Len(wh(Index)))
        pWaveHdr(Index) = GlobalLock(hWaveHdr(Index))
        If hWaveHdr(Index) = 0 Or pWaveHdr(Index) = 0 Then
            AllocWaveHeader = 1
            Exit Function
        End If
    Next Index
    AllocWaveHeader = 0
End Function

'Free the wave header memory
Sub FreeWaveHeader()
    Dim Index As Integer
    Dim ReturnValue As Integer
    For Index = 0 To 1
        ReturnValue = GlobalUnlock(hWaveHdr(Index))
        ReturnValue = GlobalFree(hWaveHdr(Index))
        hWaveHdr(Index) = 0
    Next Index
End Sub

'Allocate and lock wave memory
Function AllocPCMBuffers() As Integer
    Dim Index As Integer
    For Index = 0 To 1
        hWaveMem(Index) = GlobalAlloc(GMEM_MOVEABLE Or GMEM_SHARE, WAVE_BUFSIZE)
        pWaveMem(Index) = GlobalLock(hWaveMem(Index))
        If hWaveMem(Index) = 0 Or pWaveMem(Index) = 0 Then
            AllocPCMBuffers = 1
            Exit Function
        End If
        wh(Index).lpData = pWaveMem(Index)
    Next Index
    AllocPCMBuffers = 0
End Function

'Free the wave memory
Sub FreePCMBuffers()
    Dim ReturnValue As Integer
    Dim Index As Integer
    For Index = 0 To 1
        ReturnValue = GlobalUnlock(hWaveMem(Index))
        ReturnValue = GlobalFree(hWaveMem(Index))
        hWaveMem(Index) = 0
    Next Index
End Sub

'Called by device driver when opened, closed or when buffer passed
'by waveInAddBuffer function is filled
'Sub waveOutProc(ByVal hwi As Long, ByVal uMsg As Long, ByVal dwInstance As Long, ByRef hdr As WAVEHDR, ByVal dwParam2 As Long)

Sub WaveInProc(ByVal hwi As Long, ByVal uMsg As Long, ByVal dwInstance As Long, wParm As Long, ByVal lParm As Long)
    'process only the buffer filled event
    If uMsg = MM_WIM_DATA Then
        If ModeFlag Then
            If AddNextBuffer() Then
                Call CloseWaveDeviceRecord
            End If
        Else
            Call CloseWaveDeviceRecord
        End If
    End If
End Sub
Sub GetStereo16Sample()
' These subs obtain a PCM sample and converts it into volume levels from (50 to 100)

    Dim sample16 As Integer
    Dim LVol As Long
    Dim RVol As Long
    CopyStructFromPtr sample16, pWaveMem(bufindex), 2
    LVol = (sample16 + 32768) / 65536 * 100
    Form1.LedL.Value = LVol
    CopyStructFromPtr sample16, pWaveMem(bufindex) + 2, 2
    RVol = (sample16 + 32768) / 65536 * 100
    Form1.LedR.Value = RVol
End Sub

'----------------------------------------------------------------------------------------------------------------------------
'Copy this code to a FORM with 2 buttons and 2 gauges
'I used a custom control as gauges: search in internet the custom controls NEDLED. They
'works fine and are shareware or freeware (I don't remember). The MIN propery must be 50
'and the MAX property 100

Option Explicit

'Command button
Private Sub cmdRec_Click()
    If StartWaveRecord Then
        Call DestroyWaveRecorder
    End If
End Sub

'Command button
Private Sub cmdStop_Click()
    Call StopWaveRecord
    LedL.Value = 50
    LedR.Value = 50
End Sub

Private Sub Form_Load()
    'Initialize variables
    Dim ReturnValue As Integer
        Call DestroyWaveRecorder
        End
    End If
    ModeFlag = False
    bufindex = 0
End Sub

Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
    If ModeFlag Then
        Call StopWaveRecord
        Call DestroyWaveRecorder
    End If
End Sub

'-------------------------------------------------------------------------------------------------------------------

I hope all those explanations are usefull to your needs.
Any doubt, you can find me in afonso@imagelink.com.br

0
 

Author Comment

by:berlet
ID: 1445693
Thanks for your greate Help !



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

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
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 process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…

762 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

23 Experts available now in Live!

Get 1:1 Help Now