Announcement

Collapse

Forum Guidelines

This forum is for finished source code that is working properly. If you have questions about this or any other source code, please post it in one of the Discussion Forums, not here.
See more
See less

Sound Mixer Example

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Sound Mixer Example

    This is an example program for a wrapper dll I made for a lot of MMSYS.DLL functions.
    You can use it to make life a bit easier when using the audiomixer.
    (Believe me, the MMSYS dll isn't a pretty one for mixer manipulation)
    Code:
    '==================================================================================================
    ' Testprogram for MixerApi.DLL
    ' You can record and play files, and adjust the mixer controls
    ' Created Peter Lameijn, Aug 26, 2005
    '--------------------------------------------------------------------------------------------------
    #Compile Exe
    #Dim All
    #Include "Win32Api.inc"
    #Include "Commctrl.inc"
    #Include "ComDlg32.inc"
    #Include "MixerApi.inc"
     
    %TRB_STYLE = %WS_CHILD Or %TBS_HORZ Or %WS_VISIBLE Or %TBS_AUTOTICKS Or %TBS_BOTTOM Or %WS_TABSTOP
     
    %VOL_MASTER   = 101 : %VOL_WAVE     = 102 : %VOL_MIDI     = 103 : %VOL_MODEM    = 104
    %VOL_AUX      = 105 : %VOL_MIC      = 106 : %VOL_LINEIN   = 107 : %VOL_CDAUDIO  = 108
    %LVOL_MASTER  = 111 : %LVOL_WAVE    = 112 : %LVOL_MIDI    = 113 : %LVOL_MODEM   = 114
    %LVOL_AUX     = 115 : %LVOL_MIC     = 116 : %LVOL_LINEIN  = 117 : %LVOL_CDAUDIO = 118
    %MUTE_MASTER  = 121 : %MUTE_WAVE    = 122 : %MUTE_MIDI    = 123 : %MUTE_MODEM   = 124
    %MUTE_AUX     = 125 : %MUTE_MIC     = 126 : %MUTE_LINEIN  = 127 : %MUTE_CDAUDIO = 128
    %REC_STMIX    = 131 : %REC_MODEM    = 132 : %REC_AUX      = 133 : %REC_MIC      = 134
    %REC_LINEIN   = 135 : %REC_CDAUDIO  = 136 : %MIX_STMIX    = 141 : %MIX_MODEM    = 142
    %MIX_AUX      = 143 : %MIX_MIC      = 144 : %MIX_LINEIN   = 145 : %MIX_CDAUDIO  = 146
    %LREC_STMIX   = 151 : %LREC_MODEM   = 152 : %LREC_AUX     = 153 : %LREC_MIC     = 154
    %LREC_LINEIN  = 155 : %LREC_CDAUDIO = 156
    %CMD_RECORD   = 161 : %CMD_PLAY     = 162 : %CMD_STOP     = 163 : %CMD_SKIPBACK = 164
    %CMD_SKIPFORW = 165 : %PLAYSTATE    = 166 : %CMD_PAUSE    = 167 : %STATUSBAR    = 168
    %CMD_FILE     = 169 : %CMD_SAVE     = 170
     
    Global hMixer, hDlg As Dword
     
     
    '==================================================================================================
    Sub SetMixerChecks()
      Control Set Check hDlg, %MIX_STMIX    , Mx_GetMixer(%MX_STEREOMIX)
      Control Set Check hDlg, %MIX_MODEM    , Mx_GetMixer(%MX_MODEM)
      Control Set Check hDlg, %MIX_AUX      , Mx_GetMixer(%MX_AUXILIARY)
      Control Set Check hDlg, %MIX_MIC      , Mx_GetMixer(%MX_MICROPHONE)
      Control Set Check hDlg, %MIX_LINEIN   , Mx_GetMixer(%MX_LINEIN)
      Control Set Check hDlg, %MIX_CDAUDIO  , Mx_GetMixer(%MX_CDAUDIO)
    End Sub
     
    Function Control_Update_Text (ByVal hWnd As Dword, ByVal CtrlID As Dword, ByVal Txt As String) As Long
      Local dStr As String
      Control Get Text hWnd, CtrlID To dStr
      If dStr <> Txt Then
        Control Set Text hWnd, CtrlID, Txt
        Function = -1   
      End If  
    End Function                          
     
    Function Control_Update_Check (ByVal hWnd As Dword, ByVal CtrlID As Dword, ByVal NewVal As Long)As Long
      Local Result As Long
      Control Get Check hWnd, CtrlID To Result
      If NewVal <> Result Then
        Control Set Check hWnd, CtrlID, NewVal
        Function = -1   
      End If  
    End Function                          
     
    Function Control_Update_TrackBar (ByVal hWnd As Dword, ByVal CtrlID As Dword, ByVal NewVal As Long)As Long
      Local Result As Long
      Control Send hWnd, CtrlID, %TBM_GETPOS, 0, 0 To Result
      If NewVal <> Result Then
        Control Send hWnd, CtrlID, %TBM_SETPOS, 1, NewVal
        Function = -1   
      End If  
    End Function                          
     
    
    Sub SetValues()
      Local Result As Dword                              
    
      Result = Mx_GetPlayVolume(%MX_MASTER)
      Control_Update_Text hDlg, %LVOL_MASTER , Format$(Result)
      Control_Update_TrackBar hDlg, %VOL_MASTER, Result
      Result = Mx_GetPlayVolume(%MX_WAVE)
      Control_Update_Text hDlg, %LVOL_WAVE   , Format$(Result)
      Control_Update_TrackBar hDlg, %VOL_WAVE, Result
      Result = Mx_GetPlayVolume(%MX_MIDI)
      Control_Update_Text hDlg, %LVOL_MIDI   , Format$(Result)
      Control_Update_TrackBar hDlg, %VOL_MIDI, Result
      Result = Mx_GetPlayVolume(%MX_MODEM)
      Control_Update_Text hDlg, %LVOL_MODEM  , Format$(Result)
      Control_Update_TrackBar hDlg, %VOL_MODEM, Result
      Result = Mx_GetPlayVolume(%MX_AUXILIARY)
      Control_Update_Text hDlg, %LVOL_AUX    , Format$(Result)
      Control_Update_TrackBar hDlg, %VOL_AUX, Result
      Result = Mx_GetPlayVolume(%MX_MICROPHONE)
      Control_Update_Text hDlg, %LVOL_MIC    , Format$(Result)
      Control_Update_TrackBar hDlg, %VOL_MIC, Result
      Result = Mx_GetPlayVolume(%MX_LINEIN)
      Control_Update_Text hDlg, %LVOL_LINEIN , Format$(Result)
      Control_Update_TrackBar hDlg, %VOL_LINEIN, Result
      Result = Mx_GetPlayVolume(%MX_CDAUDIO)
      Control_Update_Text hDlg, %LVOL_CDAUDIO, Format$(Result)
      Control_Update_TrackBar hDlg, %VOL_CDAUDIO, Result
       
      Result = Mx_GetRecordVolume(%MX_STEREOMIX)
      Control_Update_Text hDlg, %LREC_STMIX , Format$(Result)
      Control_Update_TrackBar hDlg, %REC_STMIX, Result
      Result = Mx_GetRecordVolume(%MX_MODEM)
      Control_Update_Text hDlg, %LREC_MODEM  , Format$(Result)
      Control_Update_TrackBar hDlg, %REC_MODEM, Result
      Result = Mx_GetRecordVolume(%MX_AUXILIARY)
      Control_Update_Text hDlg, %LREC_AUX    , Format$(Result)
      Control_Update_TrackBar hDlg, %REC_AUX, Result
      Result = Mx_GetRecordVolume(%MX_MICROPHONE)
      Control_Update_Text hDlg, %LREC_MIC    , Format$(Result)
      Control_Update_TrackBar hDlg, %REC_MIC, Result
      Result = Mx_GetRecordVolume(%MX_LINEIN)
      Control_Update_Text hDlg, %LREC_LINEIN , Format$(Result)
      Control_Update_TrackBar hDlg, %REC_LINEIN, Result
      Result = Mx_GetRecordVolume(%MX_CDAUDIO)
      Control_Update_Text hDlg, %LREC_CDAUDIO, Format$(Result)
      Control_Update_TrackBar hDlg, %REC_CDAUDIO, Result
     
      Result = Mx_GetMute(%MX_MASTER)
      Control_Update_Check hDlg, %MUTE_MASTER, Result
      Result = Mx_GetMute(%MX_WAVE)
      Control_Update_Check hDlg, %MUTE_WAVE, Result
      Result = Mx_GetMute(%MX_MIDI)
      Control_Update_Check hDlg, %MUTE_MIDI, Result
      Result = Mx_GetMute(%MX_MODEM)
      Control_Update_Check hDlg, %MUTE_MODEM, Result
      Result = Mx_GetMute(%MX_AUXILIARY)
      Control_Update_Check hDlg, %MUTE_AUX, Result
      Result = Mx_GetMute(%MX_MICROPHONE)
      Control_Update_Check hDlg, %MUTE_MIC, Result
      Result = Mx_GetMute(%MX_LINEIN)
      Control_Update_Check hDlg, %MUTE_LINEIN, Result
      Result = Mx_GetMute(%MX_CDAUDIO)
      Control_Update_Check hDlg, %MUTE_CDAUDIO, Result
     
      Result = Mx_GetMixer(%MX_STEREOMIX)
      Control_Update_Check hDlg, %MIX_STMIX, Result
      Result = Mx_GetMixer(%MX_MODEM)
      Control_Update_Check hDlg, %MIX_MODEM, Result
      Result = Mx_GetMixer(%MX_AUXILIARY)
      Control_Update_Check hDlg, %MIX_AUX, Result
      Result = Mx_GetMixer(%MX_MICROPHONE)
      Control_Update_Check hDlg, %MIX_MIC, Result
      Result = Mx_GetMixer(%MX_LINEIN)
      Control_Update_Check hDlg, %MIX_LINEIN, Result
      Result = Mx_GetMixer(%MX_CDAUDIO)
      Control_Update_Check hDlg, %MIX_CDAUDIO, Result
     
    End Sub
     
    CallBack Function CbMain()
      Local Result As Long, szStr As Asciiz * 256, dStr As String
      Select Case CbMsg
        Case %WM_INITDIALOG
          SetTimer CbHndl, &h0001, 25, 0
          Mx_Open 0
          Dialog Set Text CbHndl, Mx_GetDescription
          SetValues
     
        Case %WM_COMMAND
          If CbCtlMsg = %BN_CLICKED Then
            Select Case CbCtl
              Case %MUTE_MASTER
                Control Get Check CbHndl, CbCtl To Result : Mx_SetMute(%MX_MASTER, Result)
              Case %MUTE_WAVE
                Control Get Check CbHndl, CbCtl To Result : Mx_SetMute(%MX_WAVE, Result)
              Case %MUTE_MIDI
                Control Get Check CbHndl, CbCtl To Result : Mx_SetMute (%MX_MIDI, Result)
              Case %MUTE_MODEM
                Control Get Check CbHndl, CbCtl To Result : Mx_SetMute (%MX_MODEM, Result)
              Case %MUTE_AUX
                Control Get Check CbHndl, CbCtl To Result : Mx_SetMute (%MX_AUXILIARY, Result)
              Case %MUTE_MIC
                Control Get Check CbHndl, CbCtl To Result : Mx_SetMute (%MX_MICROPHONE, Result)
              Case %MUTE_LINEIN
                Control Get Check CbHndl, CbCtl To Result : Mx_SetMute (%MX_LINEIN, Result)
              Case %MUTE_CDAUDIO
                Control Get Check CbHndl, CbCtl To Result : Mx_SetMute (%MX_CDAUDIO, Result)
     
              Case %MIX_STMIX
                Control Get Check CbHndl, CbCtl To Result : Mx_SetMixer(%MX_STEREOMIX, Result)
                SetMixerChecks
              Case %MIX_MODEM
                Control Get Check CbHndl, CbCtl To Result : Mx_SetMixer(%MX_MODEM, Result)
                SetMixerChecks
              Case %MIX_AUX
                Control Get Check CbHndl, CbCtl To Result : Mx_SetMixer(%MX_AUXILIARY, Result)
                SetMixerChecks
              Case %MIX_MIC
                Control Get Check CbHndl, CbCtl To Result : Mx_SetMixer(%MX_MICROPHONE, Result)
                SetMixerChecks
              Case %MIX_LINEIN
                Control Get Check CbHndl, CbCtl To Result : Mx_SetMixer(%MX_LINEIN, Result)
                SetMixerChecks
              Case %MIX_CDAUDIO
                Control Get Check CbHndl, CbCtl To Result : Mx_SetMixer(%MX_CDAUDIO, Result)
                SetMixerChecks
     
              Case %CMD_RECORD
                Mx_SetSampleParms 44100, 2, 16
                Mx_SetRecordLength 300000
                Result = Mx_Record
                Control Disable CbHndl, %CMD_RECORD
                Control Disable CbHndl, %CMD_PLAY
                Control Enable CbHndl, %CMD_PAUSE
                Control Enable CbHndl, %CMD_SKIPBACK
                Control Enable CbHndl, %CMD_SKIPFORW
              Case %CMD_PLAY
                Control Send hDlg, %STATUSBAR, %SB_SETTEXT, 3, VarPtr(szStr)
                Mx_Play ""
                Control Disable CbHndl, %CMD_RECORD
                Control Disable CbHndl, %CMD_PLAY
                Control Enable CbHndl, %CMD_PAUSE
                Control Enable CbHndl, %CMD_SKIPBACK
                Control Enable CbHndl, %CMD_SKIPFORW
              Case %CMD_STOP
                Mx_Stop
                Control Enable CbHndl, %CMD_RECORD
                Control Enable CbHndl, %CMD_PLAY
                Control Disable CbHndl, %CMD_PAUSE
                Control Disable CbHndl, %CMD_SKIPBACK
                Control Disable CbHndl, %CMD_SKIPFORW
              Case %CMD_SKIPBACK
                Mx_SkipBack(1000)
              Case %CMD_SKIPFORW
                Mx_SkipForward(1000)
              Case %CMD_PAUSE
                szStr = Mx_Status()
                If szStr = "paused" Then
                  Mx_Resume
                Else
                  Mx_Pause
                End If
              Case %CMD_FILE
                dStr = ""
                OpenFileDialog(hDlg, "Open File", dStr, CurDir$, "soundfiles (*.wav)|*.wav", "", _
                                      %OFN_FILEMUSTEXIST Or %OFN_HIDEREADONLY Or %OFN_LONGNAMES)
                Control Send hDlg, %STATUSBAR, %SB_SETTEXT, 3, StrPtr(dStr)
                If dStr <> "" Then
                  Mx_Play dStr
                  Control Disable CbHndl, %CMD_RECORD
                  Control Disable CbHndl, %CMD_PLAY
                  Control Enable CbHndl, %CMD_PAUSE
                  Control Enable CbHndl, %CMD_SKIPBACK
                  Control Enable CbHndl, %CMD_SKIPFORW
                End If
              Case %CMD_SAVE
                dStr = ""
                SaveFileDialog(hDlg, "Open File", dStr, CurDir$, "soundfiles (*.wav)|*.wav", "", _
                                    %OFN_FILEMUSTEXIST Or %OFN_HIDEREADONLY Or %OFN_LONGNAMES)
                Control Send hDlg, %STATUSBAR, %SB_SETTEXT, 3, StrPtr(dStr)
                If dStr <> "" Then Mx_Save dStr
            End Select
          End If
        Case %WM_TIMER 
          SetValues   
          szStr = Mx_Status()
          If szStr = "stopped" Then
            Control Enable CbHndl, %CMD_RECORD
            Control Enable CbHndl, %CMD_PLAY
            Control Disable CbHndl, %CMD_PAUSE
            Control Disable CbHndl, %CMD_SKIPBACK
            Control Disable CbHndl, %CMD_SKIPFORW
          End If
          If (szStr = "playing") Or (szStr = "recording") Then
            Result = Mx_GetPosition()
            dStr = Format$(Result)
            Control Send hdlg, %PLAYSTATE, %PBM_SETPOS, Result, 0
            Control Send hDlg, %STATUSBAR, %SB_SETTEXT, 2, StrPtr(dStr)
          ElseIf szStr = "stopped" Then
            dStr = ""
            Control Send hdlg, %PLAYSTATE, %PBM_SETPOS, 0, 0
            Control Send hDlg, %STATUSBAR, %SB_SETTEXT, 2, StrPtr(dStr)
          End If
        Case %WM_HSCROLL
          Select Case CbLParam
            Case GetDlgItem(CbHndl,%VOL_MASTER)
              Control Send CbHndl, %VOL_MASTER, %TBM_GETPOS, 0, 0 To Result
              Control Set Text CbHndl,  %LVOL_MASTER, Format$(Result)
              Mx_SetPlayVolume (%MX_MASTER, Result)
     
            Case GetDlgItem(CbHndl,%VOL_WAVE)
              Control Send CbHndl, %VOL_WAVE, %TBM_GETPOS, 0, 0 To Result
              Control Set Text CbHndl,  %LVOL_WAVE, Format$(Result)
              Mx_SetPlayVolume (%MX_WAVE, Result)
     
            Case GetDlgItem(CbHndl,%VOL_MIDI)
              Control Send CbHndl, %VOL_MIDI, %TBM_GETPOS, 0, 0 To Result
              Control Set Text CbHndl,  %LVOL_MIDI, Format$(Result)
              Mx_SetPlayVolume (%MX_MIDI, Result)
     
            Case GetDlgItem(CbHndl,%VOL_MODEM)
              Control Send CbHndl, %VOL_MODEM, %TBM_GETPOS, 0, 0 To Result
              Control Set Text CbHndl,  %LVOL_MODEM, Format$(Result)
              Mx_SetPlayVolume (%MX_MODEM, Result)
     
            Case GetDlgItem(CbHndl,%VOL_AUX)
              Control Send CbHndl, %VOL_AUX, %TBM_GETPOS, 0, 0 To Result
              Control Set Text CbHndl,  %LVOL_AUX, Format$(Result)
              Mx_SetPlayVolume (%MX_AUXILIARY, Result)
     
            Case GetDlgItem(CbHndl,%VOL_MIC)
              Control Send CbHndl, %VOL_MIC, %TBM_GETPOS, 0, 0 To Result
              Control Set Text CbHndl,  %LVOL_MIC, Format$(Result)
              Mx_SetPlayVolume (%MX_MICROPHONE, Result)
     
            Case GetDlgItem(CbHndl,%VOL_LINEIN)
              Control Send CbHndl, %VOL_LINEIN, %TBM_GETPOS, 0, 0 To Result
              Control Set Text CbHndl,  %LVOL_LINEIN, Format$(Result)
              Mx_SetPlayVolume (%MX_LINEIN, Result)
     
            Case GetDlgItem(CbHndl,%VOL_CDAUDIO)
              Control Send CbHndl, %VOL_CDAUDIO, %TBM_GETPOS, 0, 0 To Result
              Control Set Text CbHndl,  %LVOL_CDAUDIO, Format$(Result)
              Mx_SetPlayVolume (%MX_CDAUDIO, Result)
     
    
            Case GetDlgItem(CbHndl,%REC_STMIX)
              Control Send CbHndl, %REC_STMIX, %TBM_GETPOS, 0, 0 To Result
              Control Set Text CbHndl,  %LREC_STMIX, Format$(Result)
              Mx_SetRecordVolume (%MX_STEREOMIX, Result)
     
            Case GetDlgItem(CbHndl,%REC_MODEM)
              Control Send CbHndl, %REC_MODEM, %TBM_GETPOS, 0, 0 To Result
              Control Set Text CbHndl,  %LREC_MODEM, Format$(Result)
              Mx_SetRecordVolume (%MX_MODEM, Result)
     
            Case GetDlgItem(CbHndl,%REC_AUX)
              Control Send CbHndl, %REC_AUX, %TBM_GETPOS, 0, 0 To Result
              Control Set Text CbHndl,  %LREC_AUX, Format$(Result)
              Mx_SetRecordVolume (%MX_AUXILIARY, Result)
     
            Case GetDlgItem(CbHndl,%REC_MIC)
              Control Send CbHndl, %REC_MIC, %TBM_GETPOS, 0, 0 To Result
              Control Set Text CbHndl,  %LREC_MIC, Format$(Result)
              Mx_SetRecordVolume (%MX_MICROPHONE, Result)
     
            Case GetDlgItem(CbHndl,%REC_LINEIN)
              Control Send CbHndl, %REC_LINEIN, %TBM_GETPOS, 0, 0 To Result
              Control Set Text CbHndl,  %LREC_LINEIN, Format$(Result)
              Mx_SetRecordVolume (%MX_LINEIN, Result)
     
            Case GetDlgItem(CbHndl,%REC_CDAUDIO)
              Control Send CbHndl, %REC_CDAUDIO, %TBM_GETPOS, 0, 0 To Result
              Control Set Text CbHndl,  %LREC_CDAUDIO, Format$(Result)
              Mx_SetRecordVolume (%MX_CDAUDIO, Result)
     
              End Select
        Case %WM_DESTROY
          Mx_Close
          KillTimer CbHndl, &h0001
          mciSendString("close all", szStr, Len(szStr), 0)
      End Select
    End Function
     
    '==================================================================================================
    ' Main
    '--------------------------------------------------------------------------------------------------
    Function PbMain () As Long
      Local VolMaster, VolWave, VolMidi, VolModem, VolAux, VolMic, VolLineIn, VolCDAudio As Dword
      Dim SbParts(4) As Local Dword
     
      Mx_Debug 1, 0
     
      Dialog New 0, "",,,465,240, %WS_CAPTION Or %WS_BORDER Or %WS_SYSMENU To hDlg
    '..................................................................................................
      Control Add Frame, hDlg, -1, "Muting for speaker:", 5, 10, 80, 145
     
      Control Add CheckBox, hDlg, %MUTE_MASTER  , "Master"  , 15, 25, 60, 12
      Control Add CheckBox, hDlg, %MUTE_WAVE    , "Wave"    , 15, 40, 60, 12
      Control Add CheckBox, hDlg, %MUTE_MIDI    , "Midi"    , 15, 55, 60, 12
      Control Add CheckBox, hDlg, %MUTE_MODEM   , "Modem"   , 15, 70, 60, 12
      Control Add CheckBox, hDlg, %MUTE_AUX     , "Aux"     , 15, 85, 60, 12
      Control Add CheckBox, hDlg, %MUTE_MIC     , "Micro"   , 15,100, 60, 12
      Control Add CheckBox, hDlg, %MUTE_LINEIN  , "Line In" , 15,115, 60, 12
      Control Add CheckBox, hDlg, %MUTE_CDAUDIO , "CD Audio", 15,130, 60, 12
     
    '..................................................................................................
      Control Add Frame, hDlg, -1, "Volume settings for speaker channel:", 90, 10, 140, 145
     
      Control Add "msctls_trackbar32", hDlg, %VOL_MASTER, "", 135, 25, 70, 12, %TRB_STYLE
      Control Send hDlg, %VOL_MASTER , %TBM_SETTICFREQ, 10, 10
      Control Send hDlg, %VOL_MASTER , %TBM_SETRANGE  , 1, MakLng(0,100)
      Control Add Label, hDlg, %LVOL_MASTER, "0", 205, 25, 20, 12, %SS_CENTERIMAGE Or %SS_CENTER
      Control Add Label, hDlg, -1, "Master", 100, 25, 35, 12
     
      Control Add "msctls_trackbar32", hDlg, %VOL_WAVE,"", 135, 40, 70, 12, %TRB_STYLE
      Control Send hDlg, %VOL_WAVE   , %TBM_SETTICFREQ, 10, 10
      Control Send hDlg, %VOL_WAVE   , %TBM_SETRANGE  , 1, MakLng(0,100)
      Control Add Label, hDlg, %LVOL_WAVE, "0", 205, 40, 20, 12, %SS_CENTERIMAGE Or %SS_CENTER
      Control Add Label, hDlg, -1, "Wave", 100, 40, 35, 12
     
      Control Add "msctls_trackbar32", hDlg, %VOL_MIDI,"", 135, 55, 70, 12, %TRB_STYLE
      Control Send hDlg, %VOL_MIDI   , %TBM_SETTICFREQ, 10, 10
      Control Send hDlg, %VOL_MIDI   , %TBM_SETRANGE  , 1, MakLng(0,100)
      Control Add Label, hDlg, %LVOL_MIDI, "0", 205, 55, 20, 12, %SS_CENTERIMAGE Or %SS_CENTER
      Control Add Label, hDlg, -1, "Midi", 100, 55, 35, 12
     
      Control Add "msctls_trackbar32", hDlg, %VOL_MODEM,"", 135, 70, 70, 12, %TRB_STYLE
      Control Send hDlg, %VOL_MODEM   , %TBM_SETTICFREQ, 10, 10
      Control Send hDlg, %VOL_MODEM   , %TBM_SETRANGE  , 1, MakLng(0,100)
      Control Add Label, hDlg, %LVOL_MODEM, "0", 205, 70, 20, 12, %SS_CENTERIMAGE Or %SS_CENTER
      Control Add Label, hDlg, -1, "Modem", 100, 70, 35, 12
     
      Control Add "msctls_trackbar32", hDlg, %VOL_AUX,"", 135, 85, 70, 12, %TRB_STYLE
      Control Send hDlg, %VOL_AUX   , %TBM_SETTICFREQ, 10, 10
      Control Send hDlg, %VOL_AUX   , %TBM_SETRANGE  , 1, MakLng(0,100)
      Control Add Label, hDlg, %LVOL_AUX, "0", 205, 85, 20, 12, %SS_CENTERIMAGE Or %SS_CENTER
      Control Add Label, hDlg, -1, "Auxiliary", 100, 85, 35, 12
     
      Control Add "msctls_trackbar32", hDlg, %VOL_MIC,"", 135, 100, 70, 12, %TRB_STYLE
      Control Send hDlg, %VOL_MIC   , %TBM_SETTICFREQ, 10, 10
      Control Send hDlg, %VOL_MIC   , %TBM_SETRANGE  , 1, MakLng(0,100)
      Control Add Label, hDlg, %LVOL_MIC, "0", 205, 100, 20, 12, %SS_CENTERIMAGE Or %SS_CENTER
      Control Add Label, hDlg, -1, "Micro", 100, 100, 35, 12
     
      Control Add "msctls_trackbar32", hDlg, %VOL_LINEIN,"", 135, 115, 70, 12, %TRB_STYLE
      Control Send hDlg, %VOL_LINEIN   , %TBM_SETTICFREQ, 10, 10
      Control Send hDlg, %VOL_LINEIN   , %TBM_SETRANGE  , 1, MakLng(0,100)
      Control Add Label, hDlg, %LVOL_LINEIN, "0", 205, 115, 20, 12, %SS_CENTERIMAGE Or %SS_CENTER
      Control Add Label, hDlg, -1, "Line In", 100, 115, 35, 12
     
      Control Add "msctls_trackbar32", hDlg, %VOL_CDAUDIO,"", 135, 130, 70, 12, %TRB_STYLE
      Control Send hDlg, %VOL_CDAUDIO   , %TBM_SETTICFREQ, 10, 10
      Control Send hDlg, %VOL_CDAUDIO   , %TBM_SETRANGE  , 1, MakLng(0,100)
      Control Add Label, hDlg, %LVOL_CDAUDIO, "0", 205, 130, 20, 12, %SS_CENTERIMAGE Or %SS_CENTER
      Control Add Label, hDlg, -1, "CD Audio", 100, 130, 35, 12
     
    '..................................................................................................
      Control Add Frame, hDlg, -1, "Mixer (mux) selector:", 235, 10, 80, 145
     
      Control Add CheckBox, hDlg, %MIX_STMIX    , "Stereo mix", 245, 25, 60, 12
      Control Add CheckBox, hDlg, %MIX_MODEM    , "Modem"     , 245, 40, 60, 12
      Control Add CheckBox, hDlg, %MIX_AUX      , "Auxiliary" , 245, 55, 60, 12
      Control Add CheckBox, hDlg, %MIX_MIC      , "Micro    " , 245, 70, 60, 12
      Control Add CheckBox, hDlg, %MIX_LINEIN   , "Line in"   , 245, 85, 60, 12
      Control Add CheckBox, hDlg, %MIX_CDAUDIO  , "CD Audio"  , 245,100, 60, 12
     
    '..................................................................................................
      Control Add Frame, hDlg, -1, "Volume settings for recording channel:", 320, 10, 140, 145
     
      Control Add "msctls_trackbar32", hDlg, %REC_STMIX, "", 365, 25, 70, 12, %TRB_STYLE
      Control Send hDlg, %REC_STMIX , %TBM_SETTICFREQ, 10, 10
      Control Send hDlg, %REC_STMIX , %TBM_SETRANGE  , 1, MakLng(0,100)
      Control Add Label, hDlg, %LREC_STMIX, "0", 435, 25, 20, 12, %SS_CENTERIMAGE Or %SS_CENTER
      Control Add Label, hDlg, -1, "Stereo mix", 330, 25, 35, 12
     
      Control Add "msctls_trackbar32", hDlg, %REC_MODEM,"", 365, 40, 70, 12, %TRB_STYLE
      Control Send hDlg, %REC_MODEM   , %TBM_SETTICFREQ, 10, 10
      Control Send hDlg, %REC_MODEM   , %TBM_SETRANGE  , 1, MakLng(0,100)
      Control Add Label, hDlg, %LREC_MODEM, "0", 435, 40, 20, 12, %SS_CENTERIMAGE Or %SS_CENTER
      Control Add Label, hDlg, -1, "Modem", 330, 40, 35, 12
     
      Control Add "msctls_trackbar32", hDlg, %REC_AUX,"", 365, 55, 70, 12, %TRB_STYLE
      Control Send hDlg, %REC_AUX   , %TBM_SETTICFREQ, 10, 10
      Control Send hDlg, %REC_AUX   , %TBM_SETRANGE  , 1, MakLng(0,100)
      Control Add Label, hDlg, %LREC_AUX, "0", 435, 55, 20, 12, %SS_CENTERIMAGE Or %SS_CENTER
      Control Add Label, hDlg, -1, "Auxiliary", 330, 55, 35, 12
     
      Control Add "msctls_trackbar32", hDlg, %REC_MIC,"", 365, 70, 70, 12, %TRB_STYLE
      Control Send hDlg, %REC_MIC   , %TBM_SETTICFREQ, 10, 10
      Control Send hDlg, %REC_MIC   , %TBM_SETRANGE  , 1, MakLng(0,100)
      Control Add Label, hDlg, %LREC_MIC, "0", 435, 70, 20, 12, %SS_CENTERIMAGE Or %SS_CENTER
      Control Add Label, hDlg, -1, "Micro", 330, 70, 35, 12
     
      Control Add "msctls_trackbar32", hDlg, %REC_LINEIN,"", 365, 85, 70, 12, %TRB_STYLE
      Control Send hDlg, %REC_LINEIN   , %TBM_SETTICFREQ, 10, 10
      Control Send hDlg, %REC_LINEIN   , %TBM_SETRANGE  , 1, MakLng(0,100)
      Control Add Label, hDlg, %LREC_LINEIN, "0", 435, 85, 20, 12, %SS_CENTERIMAGE Or %SS_CENTER
      Control Add Label, hDlg, -1, "Line in", 330, 85, 35, 12
     
      Control Add "msctls_trackbar32", hDlg, %REC_CDAUDIO,"", 365, 100, 70, 12, %TRB_STYLE
      Control Send hDlg, %REC_CDAUDIO   , %TBM_SETTICFREQ, 10, 10
      Control Send hDlg, %REC_CDAUDIO   , %TBM_SETRANGE  , 1, MakLng(0,100)
      Control Add Label, hDlg, %LREC_CDAUDIO, "0", 435, 100, 20, 12, %SS_CENTERIMAGE Or %SS_CENTER
      Control Add Label, hDlg, -1, "CD Audio", 330, 100, 35, 12
     
    '..................................................................................................
      Control Add Frame , hDlg, -1              , "Controls"    ,  5,160,455, 55
      Control Add Button, hDlg, %CMD_SKIPBACK   , "<<"          , 15,170, 50, 15
      Control Add Button, hDlg, %CMD_RECORD     , "Record"      , 70,170, 50, 15
      Control Add Button, hDlg, %CMD_PLAY       , "Play"        ,125,170, 50, 15
      Control Add Button, hDlg, %CMD_STOP       , "Stop"        ,180,170, 50, 15
      Control Add Button, hDlg, %CMD_SKIPFORW   , ">>"          ,235,170, 50, 15
      Control Add Button, hDlg, %CMD_PAUSE      , "| |"         ,290,170, 50, 15
      Control Add Button, hDlg, %CMD_FILE       , "Play file"   ,345,170, 50, 15
      Control Add Button, hDlg, %CMD_SAVE       , "Save to file",400,170, 50, 15
     
      Control Add "msctls_progress32", hDlg, %PLAYSTATE, "", 10,195, 445, 8,%WS_CHILD Or %WS_VISIBLE, %WS_EX_STATICEDGE
      Control Send hdlg, %PLAYSTATE, %PBM_SETRANGE, 0, MakLng(&h0,100)
      Control Send hdlg, %PLAYSTATE, %PBM_SETSTEP, 1, 0
     
      Control Add "msctls_statusbar32", hDlg, %STATUSBAR, "",0,0,0,0, %WS_CHILD Or %WS_VISIBLE
      SbParts(0) = 250 : SbParts(1) = 350 : SbParts(2) = 400 : SbParts(3) = -1                                                                            'Login/out info
      Control Send hDlg, %STATUSBAR, %SB_SETPARTS,4,VarPtr(sbParts(0))
     
      Dialog Show Modal hDlg, Call CbMain
    End Function
    '==================================================================================================
    ------------------
    Regards,
    Peter



    [This message has been edited by Peter Lameijn (edited September 04, 2005).]
    Regards,
    Peter

  • #2
    This is the include file:
    Code:
    '==================================================================================================
    ' MixerApi.Inc - Include file for MixerApi.dll.                                                    
    ' Version 1.00 - Aug 2005 - P.Lameijn
    '--------------------------------------------------------------------------------------------------
    ' Constants declares
    '--------------------------------------------------------------------------------------------------
    %MX_STEREOMIX   = 1         'Only used on recording/mixer
    %MX_MASTER      = 1         'Only used on playback/mute
    %MX_WAVE        = 2         'Only used on playback/mute
    %MX_MIDI        = 3         'Only used on playback/mute
    %MX_MODEM       = 4
    %MX_AUXILIARY   = 5
    %MX_MICROPHONE  = 6
    %MX_LINEIN      = 7
    %MX_CDAUDIO     = 8
     
    '==================================================================================================
    ' Mx_Close.                     Closes the sound device
    '--------------------------------------------------------------------------------------------------
    Declare Function Mx_Close           Lib "MixerApi.dll" Alias "Mx_Close" () As Long                 
     
    '==================================================================================================
    ' Mx_DestChannels               Returns the number of destination channels on the audiomixer
    '--------------------------------------------------------------------------------------------------
    Declare Function Mx_DestChannels    Lib "MixerApi.dll" Alias "Mx_DestChannels" () As Long   
     
    '==================================================================================================
    ' Mx_GetDescription             Returns manufacturer description of the sound device
    '--------------------------------------------------------------------------------------------------
    Declare Function Mx_GetDescription  Lib "MixerApi.dll" Alias "Mx_GetDescription" () As String
     
    '==================================================================================================
    ' Mx_GetError                   Returns the textstring for the last MMSYSERR_xxx  
    '--------------------------------------------------------------------------------------------------
    Declare Function Mx_GetError        Lib "MixerApi.dll" Alias "Mx_GetError" () As String
     
    '==================================================================================================
    ' Mx_GetMixer                   Returns the check state of the specified mixer line
    '                               1st parm: channel to check
    '--------------------------------------------------------------------------------------------------
    Declare Function Mx_GetMixer        Lib "MixerApi.dll" Alias "Mx_GetMixer" (ByVal Dword) As Long
     
    '==================================================================================================
    ' Mx_GetMute                    Returns the check state of the specified mute control 
    '                               1st parm: channel to check
    '--------------------------------------------------------------------------------------------------
    Declare Function Mx_GetMute         Lib "MixerApi.dll" Alias "Mx_GetMute" (ByVal Dword) As Long
     
    '==================================================================================================
    ' Mx_GetPlayVolume              Returns the volume level (0...100) for the specified channel
    '                               1st parm: channel to return volumeinfo on
    '--------------------------------------------------------------------------------------------------
    Declare Function Mx_GetPlayVolume   Lib "MixerApi.dll" Alias "Mx_GetPlayVolume" (ByVal Dword) As Long
     
    '==================================================================================================
    ' Mx_GetPosition                Returns the position (0...100) in a file during play
    '--------------------------------------------------------------------------------------------------
    Declare Function Mx_GetPosition     Lib "MixerApi.dll" Alias "Mx_GetPosition" () As Long                       
     
    '==================================================================================================
    ' Mx_GetRecordVolume            Returns the volume level (0...100) for the specified channel
    '                               1st parm: channel to return volumeinfo on
    '--------------------------------------------------------------------------------------------------
    Declare Function Mx_GetRecordVolume Lib "MixerApi.dll" Alias "Mx_GetRecordVolume" (ByVal Dword) As Long
     
    '==================================================================================================
    ' Mx_IsMixer                    Returns true if mixer present.
    '--------------------------------------------------------------------------------------------------
    Declare Function Mx_IsMixer         Lib "MixerApi.dll" Alias "Mx_IsMixer" () As Long
     
    '==================================================================================================
    ' Mx_IsMux                      Returns true if mux (multiplexer) is present
    '--------------------------------------------------------------------------------------------------
    Declare Function Mx_IsMux           Lib "MixerApi.dll" Alias "Mx_IsMux" () As Long
     
    '==================================================================================================
    ' Mx_Open                       Opens the audio control. Must be called before other calls
    '                               1st parm: Mixer to open. For default mixer, specify "0"
    '--------------------------------------------------------------------------------------------------
    Declare Function Mx_Open            Lib "MixerApi.dll" Alias "Mx_Open" (ByVal Dword) As Long
     
    '==================================================================================================
    ' Mx_Pause                      Pauses the playing of a file
    '--------------------------------------------------------------------------------------------------
    Declare Function Mx_Pause           Lib "MixerApi.dll" Alias "Mx_Pause" () As Long
     
    '==================================================================================================
    ' Mx_Play                       Plays a file if specified, else recorded sound is played
    '                               1st parm: Filename/path to play, or ""
    '--------------------------------------------------------------------------------------------------
    Declare Function Mx_Play            Lib "MixerApi.dll" Alias "Mx_Play" (ByVal String) As Long
     
    '==================================================================================================
    ' Mx_Record                     Records sound from the mixerline that is selected
    '--------------------------------------------------------------------------------------------------
    Declare Function Mx_Record          Lib "MixerApi.dll" Alias "Mx_Record" () As Long
     
    '==================================================================================================
    ' Mx_RestoreParms               If called on exit (before Mx_Close), original parms are restored
    '--------------------------------------------------------------------------------------------------
    Declare Sub      Mx_RestoreParms    Lib "MixerApi.dll" Alias "Mx_RestoreParms" () 
     
    '==================================================================================================
    ' Mx_resume                     Resumes a paused play
    '--------------------------------------------------------------------------------------------------
    Declare Function Mx_Resume          Lib "MixerApi.dll" Alias "Mx_Resume" () As Long
     
    '==================================================================================================
    ' Mx_SaveParms                  Stores parms as set. Can be used for Mx_ResoreParms 
    '--------------------------------------------------------------------------------------------------
    Declare Sub      Mx_SaveParms       Lib "MixerApi.dll" Alias "Mx_SaveParms" ()
     
    '==================================================================================================
    ' Mx_SetMixer                   Sets specified mixer selector to requested state
    '                               1st parm: channel to set mixer on
    '                               2nd parm: state to set mixer to
    '--------------------------------------------------------------------------------------------------
    Declare Function Mx_SetMixer        Lib "MixerApi.dll" Alias "Mx_SetMixer" (ByVal Dword, ByVal Dword) As Long
     
    '==================================================================================================
    ' Mx_SetMute                    Sets state of specified mute control to requested state
    '                               1st parm: channel to set mute control on
    '                               2nd parm: state to set mute to
    '--------------------------------------------------------------------------------------------------
    Declare Function Mx_SetMute         Lib "MixerApi.dll" Alias "Mx_SetMute" (ByVal Dword, ByVal Long) As Long
     
    '==================================================================================================
    ' Mx_SetPlayVolume              Sets volume level (0...100) on the requested speaker channel
    '                               1st parm: channel to set volume on
    '                               2nd parm: volume level to set (0...100)
    '--------------------------------------------------------------------------------------------------
    Declare Function Mx_SetPlayVolume   Lib "MixerApi.dll" Alias "Mx_SetPlayVolume" (ByVal Dword, ByVal Dword) As Long
     
    '==================================================================================================
    ' Mx_SetRecordVolume            Sets volume level (0...100) on the requested record channel
    '                               1st parm: channel to set volume on
    '                               2nd parm: volume level to set (0...100)
    '--------------------------------------------------------------------------------------------------
    Declare Function Mx_SetRecordVolume Lib "MixerApi.dll" Alias "Mx_SetRecordVolume" (ByVal Dword, ByVal Dword) As Long
     
    '==================================================================================================
    ' Mx_SetSampleParms             Sets samplerate, channels, and bits per sample
    '                               1st parm: samplerate (6000, 8000, 11025, 22050, 44100)
    '                               2nd parm: channels (1 = mono, 2 = stereo)
    '                               3rd parm: bits per sample (8, 16)
    '--------------------------------------------------------------------------------------------------
    Declare Function Mx_SetSampleParms  Lib "MixerApi.dll" Alias "Mx_SetSampleParms" (ByVal Dword, ByVal Dword, ByVal Dword) As Dword
     
    '==================================================================================================
    ' Mx_SkipBack                   Skips back during replay
    '                               1st parm: time to skip in mS
    '--------------------------------------------------------------------------------------------------
    Declare Function Mx_SkipBack        Lib "MixerApi.dll" Alias "Mx_SkipBack" (ByVal Dword) As Dword
     
    '==================================================================================================
    ' Mx_SkipForward                Skips forward during replay 
    '                               1st parm: time to skip in mS
    '--------------------------------------------------------------------------------------------------
    Declare Function Mx_SkipForward     Lib "MixerApi.dll" Alias "Mx_SkipForward" (ByVal Dword) As Long
     
    '==================================================================================================
    ' Mx_Status                     Returns present status string from MCI ("recording", "playing"...)
    '--------------------------------------------------------------------------------------------------
    Declare Function Mx_Status          Lib "MixerApi.dll" Alias "Mx_Status" () As String
     
    '==================================================================================================
    ' Mx_Stop                       Stops present replay or recording
    '--------------------------------------------------------------------------------------------------
    Declare Function Mx_Stop            Lib "MixerApi.dll" Alias "Mx_Stop" () As Long
     
    '==================================================================================================
    ' Mx_Save                       Saves a recorded sound to a diskfile
    '                               1st parm: Filename/Path name to save to
    '--------------------------------------------------------------------------------------------------
    Declare Function Mx_Save            Lib "MixerApi.dll" Alias "Mx_Save" (ByVal String) As Long
     
    '==================================================================================================
    ' Mx_SetRecordLength            Sets max length for a recording in mS. If 0, endless recording
    '                               1st parm: recording time in mS
    '--------------------------------------------------------------------------------------------------
    Declare Sub      Mx_SetRecordLength Lib "MixerApi.dll" Alias "Mx_SetRecordLength"(ByVal Dword)
     
    '==================================================================================================
    ' Mx_GetRecordLength            Returns max length for a recording in mS.
    '--------------------------------------------------------------------------------------------------
    Declare Function Mx_GetRecordLength Lib "MixerApi.dll" Alias "Mx_GetRecordLength"() As Dword
     
    '==================================================================================================
    ' Mx_Debug                      Enables / disables debugging
    '--------------------------------------------------------------------------------------------------
    Declare Function Mx_Debug Lib "MixerApi.dll" Alias "Mx_Debug"(ByVal Dword, ByVal Dword) As Dword
    
    '==================================================================================================
    ------------------
    Regards,
    Peter



    [This message has been edited by Peter Lameijn (edited September 04, 2005).]
    Regards,
    Peter

    Comment


    • #3
      This is the DLL:

      Sept 7, 2005 : Changed "MIX" into "STEREO" in Get/SetRecordVolume
      Code:
      #Compile Dll "MixerApi.dll"
      #Dim All
      #Include "Win32Api.inc"
      '#Include "winclean.inc"
      '#Resource "mixerapi.pbr"
       
      Type SavedValues
        Mute(10)      As Dword
        Mixer(10)     As Dword
        RecVol(10)    As Dword
        PlayVol(10)   As Dword
      End Type
       
      Global hDlg                 As Long
      Global hMixer               As Dword
      Global dwResult             As Dword
      Global MxPlayFileName       As String
      Global MxCaps               As MIXERCAPS
      Global MxC_Mixer            As MIXERCONTROL
      Global MxC_RecSrc()         As MIXERCONTROL
      Global MxC_VolSrc()         As MIXERCONTROL
      Global MxC_VolDest()        As MIXERCONTROL
      Global MxL_Dest()           As MIXERLINE
      Global MxL_VolSrc()         As MIXERLINE
      Global MxL_RecSrc()         As MIXERLINE  
      Global MxL_VolDest          As MIXERLINE
      Global MxLC_Mixer           As MIXERLINECONTROLS
      Global SVals                As SAVEDVALUES
      Global MxSampRate           As Dword
      Global MxSampBits           As Dword
      Global MxSampChan           As Dword
      Global MxMaxFileLength      As Dword
      Global MxDebug              As Long
       
      Global MxL_RecDest()        As MIXERLINE
      Global MxC_RecDest()        As MIXERCONTROL
       
      Declare Function Mx_Close () As Long
      Declare Function Mx_DestChannels () As Long
      Declare Function Mx_GetDescription () As String
      Declare Function Mx_GetError () As String
      Declare Function Mx_GetMixer(ByVal Dword) As Long
      Declare Function Mx_GetMute (ByVal Dword) As Long
      Declare Function Mx_GetPlayVolume (ByVal Dword) As Long
      Declare Function Mx_GetPosition () As Long
      Declare Function Mx_GetRecordVolume (ByVal Dword) As Long
      Declare Function Mx_IsMixer() As Long
      Declare Function Mx_IsMux() As Long
      Declare Function Mx_Open (ByVal Dword) As Long
      Declare Function Mx_Pause () As Long
      Declare Function Mx_Play (ByVal String) As Long
      Declare Function Mx_Record () As Long
      Declare Sub      Mx_RestoreParms ()
      Declare Function Mx_Resume () As Long
      Declare Sub      Mx_SaveParms ()
      Declare Function Mx_SetMixer (ByVal Dword, ByVal Dword) As Long
      Declare Function Mx_SetMute (ByVal Dword, ByVal Long) As Long
      Declare Function Mx_SetPlayVolume (ByVal Dword, ByVal Dword) As Long
      Declare Function Mx_SetRecordVolume (ByVal Dword, ByVal Dword) As Long
      Declare Function Mx_SetSampleParms (ByVal Dword, ByVal Dword, ByVal Dword) As Dword
      Declare Function Mx_SkipBack (ByVal Dword) As Dword
      Declare Function Mx_SkipForward (ByVal Dword) As Long
      Declare Function Mx_Status () As String
      Declare Function Mx_Stop () As Long
      Declare Function Mx_Save (ByVal String) As Long
      Declare Sub      Mx_SetRecordLength(ByVal Dword)
      Declare Function Mx_GetRecordLength () As Dword
      Declare Sub      Mx_LogInfo(ByVal String)
      Declare Sub      Mx_Debug(ByVal Long, ByVal Long)
       
      '======================================================================================================================
      'Main init fuction of DLL
      '----------------------------------------------------------------------------------------------------------------------
      Function LibMain Alias "LibMain"(ByVal hInstance As Long, _
                        ByVal wReason As Long, _
                        ByVal wHeapSize As Long) Export As Long
        Select Case wReason
          Case %DLL_PROCESS_ATTACH
            LibMain       = 1
          Case %DLL_PROCESS_DETACH
          Case %DLL_THREAD_ATTACH
          Case %DLL_THREAD_DETACH
        End Select
      End Function
       
      '--------------------------------------------------------------------------------------------------
      ' Constanst used for commands in Get/Set Functions
      '--------------------------------------------------------------------------------------------------
      %MX_STEREOMIX   = 1         'Only used on recording
      %MX_MASTER      = 1         'Only used on playback
      %MX_WAVE        = 2         'Only used on playback
      %MX_MIDI        = 3         'Only used on playback
      %MX_MODEM       = 4
      %MX_AUXILIARY   = 5
      %MX_MICROPHONE  = 6
      %MX_LINEIN      = 7
      %MX_CDAUDIO     = 8
       
      '==================================================================================================
      ' Mx_Open ()                    Checks if a mixer device is present. If present, it is opened.
      ' Parameters:
      ' MixerNumber                   This is the mixer To be opened. 0 is the first one.
      '                               If the specified mixer doesn't exist, an error is returned
      ' Returns:                      On success, returns %MMSYSERR_NOERROR (0), else %MMSYSERR_....
      '--------------------------------------------------------------------------------------------------
      Function Mx_Open Alias "Mx_Open" (ByVal MixerNumber As Dword) Export As Long
        Local Cnt, Tmp As Long, MxC As MIXERCONTROL, MxL As MIXERLINE, MxLC As MIXERLINECONTROLS
        Local MxCD As MIXERCONTROLDETAILS
       
        dwResult = MixerOpen(hMixer, 0, 0, 0, 0)
        If dwResult <> %MMSYSERR_NOERROR Then 
          Function = dwResult 
          Mx_LogInfo "MixerOpen failed, error " & Hex$(dwResult)
          Exit Function                                         
        End If  
        dwResult = MixerGetDevCaps(hMixer, MxCaps, SizeOf(MIXERCAPS))
        If dwResult <> %MMSYSERR_NOERROR Then 
          Function = dwResult 
          Mx_LogInfo "MixerGetDevCaps failed, error " & Hex$(dwResult)
          Exit Function              
        End If  
       
      '--------------------------------------------------------------------------------------------------
      ' Get info for all destination channels. Fill MxL_Dest() structure. Only need SPEAKERS and WAVEIN
      ' MxL_Dest(0) holds %MIXERLINE_COMPONENTTYPE_DST_SPEAKERS info
      ' MxL_Dest(1) holds %MIXERLINE_COMPONENTTYPE_DST_WAVEIN info
      '--------------------------------------------------------------------------------------------------
        MxSampRate = 8000
        MxSampBits = 8
        MxSampChan = 1
        MxPlayFileName = ""
       
        ReDim MxL_Dest(1) As Global MIXERLINE
        For Cnt = 0 To mxCaps.cDestinations -1
          MxL.cbStruct      = SizeOf(MIXERLINE)
          MxL.dwDestination = Cnt
          MxL.dwSource      = 0
          dwResult = MixerGetLineInfo(hMixer, MxL, %MIXER_OBJECTF_HMIXER Or %MIXER_GETLINEINFOF_DESTINATION)
          If dwResult <> %MMSYSERR_NOERROR Then Function = dwResult : Exit Function
          If MxL.dwComponentType = %MIXERLINE_COMPONENTTYPE_DST_SPEAKERS Then MxL_Dest(0) = MxL
          If MxL.dwComponentType = %MIXERLINE_COMPONENTTYPE_DST_WAVEIN Then MxL_Dest(1) = MxL
       
          If MxDebug Then Mx_LogInfo "Destination channel " & Hex$(Cnt) & ": " & mxL_Dest(Cnt).szName & " (" & Hex$(mxL_Dest(Cnt).dwComponentType) & ")"
          If MxDebug Then Mx_LogInfo "------ controlcount = " & Hex$(mxL_Dest(Cnt).cControls) 
          If MxDebug Then Mx_LogInfo "------ connectioncount = " & Hex$(mxL_Dest(Cnt).cConnections)
        Next
       
      '--------------------------------------------------------------------------------------------------
      ' Get type of mixer control (mixer or multiplexer)
      '--------------------------------------------------------------------------------------------------
        MxLC_Mixer.cbStruct         = SizeOf(MIXERLINECONTROLS)
        MxLC_Mixer.dwLineID         = MxL_Dest(1).dwLineID
        MxLC_Mixer.cControls        = 1
        MxLC_Mixer.Item             = %MIXERCONTROL_CONTROLTYPE_MIXER
        MxLC_Mixer.cbmxctrl         = SizeOf(MIXERCONTROL)
        MxLC_Mixer.pamxctrl         = VarPtr(MxC_Mixer)
        dwResult = MixerGetLineControls(hMixer, MxLC, %MIXER_OBJECTF_HMIXER Or %MIXER_GETLINECONTROLSF_ONEBYTYPE)
       
        If dwResult <> %MMSYSERR_NOERROR Then
          MxLC_Mixer.Item           = %MIXERCONTROL_CONTROLTYPE_MUX
          dwResult = MixerGetLineControls(hMixer, MxLC_Mixer, %MIXER_OBJECTF_HMIXER Or %MIXER_GETLINECONTROLSF_ONEBYTYPE)
          If dwResult <> %MMSYSERR_NOERROR Then MxLC_Mixer.Item = 0 : Function = dwResult : Exit Function
        End If
                           
        If MxDebug Then  
          If MxLC_Mixer.item = %MIXERCONTROL_CONTROLTYPE_MIXER Then Mx_LogInfo "Mixer Control found"
          If MxLC_Mixer.item = %MIXERCONTROL_CONTROLTYPE_MUX   Then Mx_LogInfo "Mux Control found"
        End If
       
      '--------------------------------------------------------------------------------------------------
      ' Now fill MxL_VolSrc() with info of sourcelines from destination channel #0 (play volume)
      '--------------------------------------------------------------------------------------------------
       
        ReDim MxL_VolSrc(MxL_Dest(0).cConnections-1) As Global MIXERLINE
        For Cnt = 0 To MxL_Dest(0).cConnections -1
          MxL_VolSrc(Cnt).cbStruct        = SizeOf(MIXERLINE)
          MxL_VolSrc(Cnt).dwDestination   = 0
          MxL_VolSrc(Cnt).dwSource        = Cnt
          dwresult = mixerGetLineInfo(hMixer, mxL_VolSrc(Cnt), %MIXER_GETLINEINFOF_SOURCE)
          If MxDebug Then  
            Mx_Loginfo "Destination channel 0, source line " & Hex$(Cnt) & ": " & mxL_VolSrc(Cnt).szName & " (" & Hex$(mxL_VolSrc(Cnt).dwComponentType) & ")"
            Mx_LogInfo "------ controlcount: " & Hex$(mxL_VolSrc(Cnt).cControls)
          End If
        Next
       
      '--------------------------------------------------------------------------------------------
      ' Get controls belonging to source of destination channel #0
      '--------------------------------------------------------------------------------------------
        Dim MxC_VolSrc(10, MxL_Dest(0).cConnections -1) As Global MIXERCONTROL
        For Cnt = 0 To MxL_Dest(0).cConnections -1
          MxLC.cbStruct     = SizeOf(MIXERLINECONTROLS)
          MxLC.dwLineID     = MxL_VolSrc(Cnt).dwLineID
          MxLC.cControls    = MxL_VolSrc(Cnt).cControls
          MxLC.cbmxctrl     = SizeOf(MIXERCONTROL)
          MxLC.pamxctrl     = VarPtr(MxC_VolSrc(0, Cnt))
          dwResult = mixerGetLineControls(hMixer, MxLC, %MIXER_GETLINECONTROLSF_ALL)
        Next
        For Cnt = 0 To MxL_Dest(0).cConnections -1
          If MxDebug Then Mx_LogInfo "------ controlname: " & MxL_VolSrc(Cnt).szName
          For Tmp = 0 To MxL_VolSrc(Cnt).cControls-1
            If MxDebug Then Mx_LogInfo "------ control # " & Hex$(Tmp) & ", " & MxC_VolSrc(Tmp, Cnt).szName & ", type: " & Hex$(mxC_VolSrc(Tmp, cnt).dwControlType)
          Next
        Next
       
      '--------------------------------------------------------------------------------------------------
      ' Now fill MxL_VolDest() with info of destination lines from destination channel #0 (play volume)
      '--------------------------------------------------------------------------------------------------
       
        MxL_VolDest.cbStruct        = SizeOf(MIXERLINE)
        MxL_VolDest.dwDestination   = 0
        MxL_VolDest.dwSource        = Cnt
        dwresult = mixerGetLineInfo(hMixer, mxL_VolDest, %MIXER_GETLINEINFOF_DESTINATION)
        If MxDebug Then Mx_LogInfo "Destination line " & Format$(Cnt) & ": " & mxL_VolDest.szName & "  (" & Hex$(mxL_VolDest.dwComponentType) & ")"
        If MxDebug Then Mx_LogInfo "------ controlcount: " & Hex$(mxL_VolDest.cControls)
       
      '--------------------------------------------------------------------------------------------
      ' Get controls belonging to source of destination channel #0
      '--------------------------------------------------------------------------------------------
        Dim MxC_VolDest(MxL_Dest(0).cConnections -1) As Global MIXERCONTROL
        For Cnt = 0 To MxL_Dest(0).cConnections -1
          MxLC.cbStruct     = SizeOf(MIXERLINECONTROLS)
          MxLC.dwLineID     = MxL_VolDest.dwLineID
          MxLC.cControls    = MxL_VolDest.cControls
          MxLC.cbmxctrl     = SizeOf(MIXERCONTROL)
          MxLC.pamxctrl     = VarPtr(MxC_VolDest(0))
          dwResult = mixerGetLineControls(hMixer, MxLC, %MIXER_GETLINECONTROLSF_ALL)
        Next
       
        If MxDebug Then
          For Tmp = 0 To MxL_VolDest.cControls-1
            Mx_LogInfo "..Destination 0 source channel " & Format$(Tmp) & ": " & MxC_VolDest(Tmp).szName & " (" & Hex$(mxC_VolDest(Tmp).dwControlType) & ")"
          Next
        End If
         
      '--------------------------------------------------------------------------------------------------
      'Get source lines of destination channel #1 (recording controls)
      '--------------------------------------------------------------------------------------------------
        ReDim MxL_RecSrc(MxL_Dest(1).cConnections-1) As Global MIXERLINE
        For Cnt = 0 To MxL_Dest(1).cConnections -1
          MxL_RecSrc(Cnt).cbStruct        = SizeOf(MIXERLINE)
          MxL_RecSrc(Cnt).dwDestination   = 1
          MxL_RecSrc(Cnt).dwSource        = Cnt
          dwResult = mixerGetLineInfo(hMixer, MxL_RecSrc(Cnt), %MIXER_GETLINEINFOF_SOURCE)
          If MxDebug Then 
            Mx_LogInfo "Destination 1 source channel " & Format$(Cnt) & ": " & MxL_RecSrc(Cnt).szName & " (" & Hex$(mxL_RecSrc(Cnt).dwComponentType) & ")"
            Mx_LogInfo "------ controlcount: " & Hex$(mxL_RecSrc(Cnt).cControls)
          End If  
        Next
       
      '--------------------------------------------------------------------------------------------------
      ' Get controls belonging to source of destination channel #1
      '--------------------------------------------------------------------------------------------------
        Dim MxC_RecSrc(10, MxL_Dest(1).cConnections -1) As Global MIXERCONTROL
        For Cnt = 0 To MxL_Dest(1).cConnections -1
          MxLC.cbStruct       = SizeOf(MIXERLINECONTROLS)
          MxLC.dwLineID       = MxL_RecSrc(Cnt).dwLineID
          MxLC.cControls      = MxL_RecSrc(Cnt).cControls
          MxLC.cbmxctrl       = SizeOf(MIXERCONTROL)
          MxLC.pamxctrl       = VarPtr(MxC_RecSrc(0,Cnt))
          dwResult = MixerGetLineControls(hMixer, MxLC, %MIXER_GETLINECONTROLSF_ALL)
        Next
        For Cnt = 0 To MxL_Dest(1).cConnections -1
          If MxDebug Then Mx_LogInfo "Destination channel 1, connection " & Hex$(Cnt) & " name: " & MxL_RecSrc(Cnt).szName
          For Tmp = 0 To MxL_RecSrc(Cnt).cControls -1
            If MxDebug Then Mx_LogInfo "------ control " & Format$(Tmp) & ", name: " & MxC_RecSrc(Tmp, Cnt).szName & ", " & Hex$(MxC_RecSrc(Tmp, Cnt).dwControlType) & ", " & Hex$(MxL_RecSrc(Cnt).dwComponentType)
          Next
        Next
       
        Call Mx_SaveParms()
       
        Function = dwResult
      End Function
       
      '==================================================================================================
      ' Mx_GetError                   Translates the last occurred error into a description string.
      ' Parameters: none              (Based on the %MMSYSERR_... values)
      ' Returns:                      A string holding the description
      '--------------------------------------------------------------------------------------------------
      Function Mx_GetError Alias "Mx_GetError"() Export As String
        Local szStr As Asciiz * 256
        mciGetErrorString(dwResult, szStr, SizeOf(szStr))
        Function = szStr
      End Function
       
      '==================================================================================================
      ' Mx_GetDescription             The manufacturers string is returned
      ' Parameter: none
      ' Returns:                      A string holding the mixers description
      '--------------------------------------------------------------------------------------------------
      Function Mx_GetDescription Alias "Mx_GetDescription"() Export As String
        Function = MxCaps.szPName
      End Function
       
      '==================================================================================================
      ' Mx_IsMixer                    Tests if recording goes through a mixer. Difference between mixer
      '                               and multiplexer(mux) is that mixer allows multiple selections for
      '                               recording source, and mux doesn't.
      ' Returns:                      Non zero if mixer, else zero
      '--------------------------------------------------------------------------------------------------
      Function Mx_IsMixer Alias "Mx_IsMixer"() Export As Long
        Function = ( MxLC_Mixer.Item = %MIXERCONTROL_CONTROLTYPE_MIXER)
      End Function
       
      '==================================================================================================
      ' Mx_IsMux                      Tests if recording goes through a mux. Difference between mixer
      '                               and multiplexer(mux) is that mixer allows multiple selections for
      '                               recording source, and mux doesn't.
      ' Returns:                      Non zero if mixer, else zero
      '--------------------------------------------------------------------------------------------------
      Function Mx_IsMux Alias "Mx_IsMux"() Export As Long
        Function = ( MxLC_Mixer.Item = %MIXERCONTROL_CONTROLTYPE_MUX)
      End Function
       
      '==================================================================================================
      ' Mx_GetMute()                  Gets state of mute control
      ' Parameters:
      ' dwControl                     Which control to use
      ' Returns:                      0 = not muted, -1 = muted
      '--------------------------------------------------------------------------------------------------
      Function Mx_GetMute Alias "Mx_GetMute"(ByVal Ctrl As Dword) Export As Long
        Dim MxCD_List(50) As Local MIXERCONTROLDETAILS_LISTTEXT
        Dim MxCD_Bool(50) As Local MIXERCONTROLDETAILS_BOOLEAN
        Dim MxCD As Local MIXERCONTROLDETAILS, Cnt As Local Dword, Tmp As Local Dword
        Dim fFound As Local Dword, dStr As Local String, CtrlID As Local Dword
       
          Select Case Ctrl
          Case %MX_MASTER     : dStr = "MASTER": CtrlID = %MIXERLINE_COMPONENTTYPE_DST_SPEAKERS
          Case %MX_WAVE       : dStr = "WAVE"  : CtrlID = %MIXERLINE_COMPONENTTYPE_SRC_WAVEOUT
          Case %MX_MIDI       : dStr = "MIDI"  : CtrlID = %MIXERLINE_COMPONENTTYPE_SRC_SYNTHESIZER
          Case %MX_MODEM      : dStr = "MODEM" : CtrlID = %MIXERLINE_COMPONENTTYPE_SRC_TELEPHONE
          Case %MX_AUXILIARY  : dStr = "AUX"   : CtrlID = %MIXERLINE_COMPONENTTYPE_SRC_AUXILIARY
          Case %MX_MICROPHONE : dstr = "MIC"   : CtrlID = %MIXERLINE_COMPONENTTYPE_SRC_MICROPHONE
          Case %MX_LINEIN     : dstr = "LINE"  : CtrlID = %MIXERLINE_COMPONENTTYPE_SRC_LINE
          Case %MX_CDAUDIO    : dStr = "CD"    : CtrlID = %MIXERLINE_COMPONENTTYPE_SRC_COMPACTDISC
        End Select
       
        If Ctrl = %MX_MASTER Then
          For Cnt = 0 To MxL_VolDest.cControls-1
            If MxC_VolDest(Cnt).dwControlType = %MIXERCONTROL_CONTROLTYPE_MUTE Then
              MxCD.dwControlID  = MxC_VolDest(Cnt).dwControlID
              MxCD.Item         = MxC_VolDest(Cnt).cMultipleItems
              Exit For
            End If
          Next
        Else
          For Cnt = 0 To MxL_Dest(0).cConnections -1
            If (InStr(UCase$( MxL_VolSrc(Cnt).szName), dStr)) Or (MxL_VolSrc(Cnt).dwComponentType = CtrlID) Then
              For Tmp = 0 To MxL_VolSrc(Cnt).cControls-1
                If MxC_VolSrc(Tmp, Cnt).dwControlType = %MIXERCONTROL_CONTROLTYPE_MUTE Then
                  MxCD.dwControlID  = MxC_VolSrc(Tmp, Cnt).dwControlID
                  MxCD.Item         = MxC_VolSrc(Tmp, Cnt).cMultipleItems
                  fFound = 1
                  Exit For
                End If
              Next
              If fFound Then Exit For
            End If
          Next
        End If
        MxCD.cbStruct     = SizeOf(MIXERCONTROLDETAILS)
        MxCD.cChannels    = 1
        MxCD.cbDetails    = SizeOf(MIXERCONTROLDETAILS_UNSIGNED)
        MxCD.paDetails    = VarPtr(MxCD_Bool(0))
        dwResult = mixerGetControlDetails(hMixer, MxCD, %MIXER_GETCONTROLDETAILSF_VALUE)
        If dwResult <> %MMSYSERR_NOERROR Then Exit Function
        If MxCD_Bool(0).fValue Then Function = -1 Else Function = 0
      End Function
       
      '==================================================================================================
      ' Mx_SetMute()                  Sets state of mute control
      ' Parameters:
      ' dwControl                     Which control to use
      ' dwState                       State of mute control; 0 = not muted, -1 = muted
      ' Returns:                      %MMSYSERR_NOERROR on success, %MMSYSERR_.... on error
      '--------------------------------------------------------------------------------------------------
      Function Mx_SetMute Alias "Mx_SetMute"(ByVal Ctrl As Dword, ByVal fState As Long) Export As Long
        Dim MxCD_List(50) As Local MIXERCONTROLDETAILS_LISTTEXT
        Dim MxCD_Bool(50) As Local MIXERCONTROLDETAILS_BOOLEAN
        Dim MxCD As Local MIXERCONTROLDETAILS, Cnt As Local Dword, Tmp As Local Dword
        Dim fFound As Local Dword, dStr As Local String, CtrlID As Local Dword
       
        Select Case Ctrl
          Case %MX_MASTER     : dStr = "MASTER": CtrlID = %MIXERLINE_COMPONENTTYPE_DST_SPEAKERS
          Case %MX_WAVE       : dStr = "WAVE"  : CtrlID = %MIXERLINE_COMPONENTTYPE_SRC_WAVEOUT
          Case %MX_MIDI       : dStr = "MIDI"  : CtrlID = %MIXERLINE_COMPONENTTYPE_SRC_SYNTHESIZER
          Case %MX_MODEM      : dStr = "MODEM" : CtrlID = %MIXERLINE_COMPONENTTYPE_SRC_TELEPHONE
          Case %MX_AUXILIARY  : dStr = "AUX"   : CtrlID = %MIXERLINE_COMPONENTTYPE_SRC_AUXILIARY
          Case %MX_MICROPHONE : dstr = "MIC"   : CtrlID = %MIXERLINE_COMPONENTTYPE_SRC_MICROPHONE
          Case %MX_LINEIN     : dstr = "LINE"  : CtrlID = %MIXERLINE_COMPONENTTYPE_SRC_LINE
          Case %MX_CDAUDIO    : dStr = "CD"    : CtrlID = %MIXERLINE_COMPONENTTYPE_SRC_COMPACTDISC
        End Select
       
        If Ctrl = %MX_MASTER Then
          For Cnt = 0 To MxL_VolDest.cControls-1
            If MxC_VolDest(Cnt).dwControlType = %MIXERCONTROL_CONTROLTYPE_MUTE Then
              MxCD.dwControlID  = MxC_VolDest(Cnt).dwControlID
              MxCD.Item         = MxC_VolDest(Cnt).cMultipleItems
              Exit For
            End If
          Next
        Else
          For Cnt = 0 To MxL_Dest(0).cConnections -1
            If (InStr(UCase$( MxL_VolSrc(Cnt).szName), dStr)) Or (MxL_VolSrc(Cnt).dwComponentType = CtrlID) Then
              For Tmp = 0 To MxL_VolSrc(Cnt).cControls-1
                If MxC_VolSrc(Tmp, Cnt).dwControlType = %MIXERCONTROL_CONTROLTYPE_MUTE Then
                  fFound = 1
                  MxCD.dwControlID      = MxC_VolSrc(Tmp, Cnt).dwControlID
                  MxCD.Item             = MxC_VolSrc(Tmp, Cnt).cMultipleItems
                  Exit For
                End If
              Next
              If fFound Then Exit For
            End If
          Next
        End If
        MxCD.cbStruct         = SizeOf(MIXERCONTROLDETAILS)
        MxCD.cChannels        = 1
        MxCD.cbDetails        = SizeOf(MIXERCONTROLDETAILS_LISTTEXT)
        MxCD.paDetails        = VarPtr(MxCD_Bool(0))
        If fState Then MxCD_Bool(0).fValue = -1 Else MxCD_Bool(0).fValue = 0
       
        dwResult = mixerSetControlDetails(hMixer, MxCD, %MIXER_SETCONTROLDETAILSF_VALUE)
        Function = dwResult
      End Function
       
      '==================================================================================================
      ' Mx_GetMixer()                 Gets state of mixer control switches
      ' Parameters:
      ' dwControl                     Which control to use
      ' Returns:                      0 = not switched, -1 = switched
      '                               A positive value means an %MMSYSERR_... error occurred
      '--------------------------------------------------------------------------------------------------
      Function Mx_GetMixer Alias "Mx_GetMixer"(ByVal Ctrl As Dword) Export As Long
        Dim MxCD_List(50) As Local MIXERCONTROLDETAILS_LISTTEXT
        Dim MxCD_Bool(50) As Local MIXERCONTROLDETAILS_BOOLEAN
        Dim MxCD As Local MIXERCONTROLDETAILS, dStr As Local String, Cnt As Local Dword
        Dim fFound As Local Dword, CtrlID As Local Dword
       
        Select Case Ctrl
          Case %MX_STEREOMIX  : dstr = "MIX"   : CtrlID = %MIXERLINE_COMPONENTTYPE_SRC_WAVEOUT
          Case %MX_MODEM      : dStr = "MODEM" : CtrlID = %MIXERLINE_COMPONENTTYPE_SRC_TELEPHONE
          Case %MX_AUXILIARY  : dStr = "AUX"   : CtrlID = %MIXERLINE_COMPONENTTYPE_SRC_AUXILIARY
          Case %MX_MICROPHONE : dstr = "MIC"   : CtrlID = %MIXERLINE_COMPONENTTYPE_SRC_MICROPHONE
          Case %MX_LINEIN     : dstr = "LINE"  : CtrlID = %MIXERLINE_COMPONENTTYPE_SRC_LINE
          Case %MX_CDAUDIO    : dStr = "CD"    : CtrlID = %MIXERLINE_COMPONENTTYPE_SRC_COMPACTDISC
        End Select
       
        MxCD.cbStruct     = SizeOf(MIXERCONTROLDETAILS)
        MxCD.dwControlID  = MxC_Mixer.dwControlID
        MxCD.cChannels    = 1
        MxCD.Item         = MxC_Mixer.cMultipleItems
        MxCD.cbDetails    = SizeOf(MIXERCONTROLDETAILS_LISTTEXT)
        MxCD.paDetails    = VarPtr(MxCD_List(0))
        dwResult = mixerGetControlDetails(hMixer, MxCD, %MIXER_GETCONTROLDETAILSF_LISTTEXT)
        If dwResult <> %MMSYSERR_NOERROR Then 
          Exit Function   
        End If  
       
        MxCD.cbDetails    = SizeOf(MIXERCONTROLDETAILS_UNSIGNED)
        MxCD.paDetails    = VarPtr(MxCD_Bool(0))
        dwResult = mixerGetControlDetails(hMixer, MxCD, %MIXER_GETCONTROLDETAILSF_VALUE)
        If dwResult <> %MMSYSERR_NOERROR Then 
          Exit Function
        End If  
           
        For Cnt = 0 To MxC_Mixer.cMultipleItems -1                                      
          If (InStr (UCase$(MxCD_List(Cnt).szName), dStr)) Or (MxCD_List(Cnt).dwParam2 = CtrlID) Then
            If MxCD_Bool(Cnt).fValue = 0 Then Function = 0 Else Function = -1
            Exit Function
          End If
          Function = %MMSYSERR_INVALPARAM
        Next
      End Function
       
      '==================================================================================================
      ' Mx_SetMixer()                 Sets state of mute control
      ' Parameters:
      ' dwControl                     Which control to use
      ' Returns:                      %MMSYSERR_NOERROR on success, %MMSYSERR_.... on error
      '--------------------------------------------------------------------------------------------------
      Function Mx_SetMixer Alias "Mx_SetMixer"(ByVal Ctrl As Dword, ByVal Value As Dword) Export As Long
        Dim MxCD_List(50) As Local MIXERCONTROLDETAILS_LISTTEXT
        Dim MxCD_Bool(50) As Local MIXERCONTROLDETAILS_BOOLEAN
        Dim MxCD As Local MIXERCONTROLDETAILS, dStr As Local String, Cnt As Local Dword
        Dim fFound As Local Dword,CtrlID As Local Dword
       
        Select Case Ctrl
          Case %MX_STEREOMIX  : dstr = "MIX"   : CtrlID = %MIXERLINE_COMPONENTTYPE_SRC_WAVEOUT
          Case %MX_MODEM      : dStr = "MODEM" : CtrlID = %MIXERLINE_COMPONENTTYPE_SRC_TELEPHONE
          Case %MX_AUXILIARY  : dStr = "AUX"   : CtrlID = %MIXERLINE_COMPONENTTYPE_SRC_AUXILIARY
          Case %MX_MICROPHONE : dstr = "MIC"   : CtrlID = %MIXERLINE_COMPONENTTYPE_SRC_MICROPHONE
          Case %MX_LINEIN     : dstr = "LINE"  : CtrlID = %MIXERLINE_COMPONENTTYPE_SRC_LINE
          Case %MX_CDAUDIO    : dStr = "CD"    : CtrlID = %MIXERLINE_COMPONENTTYPE_SRC_COMPACTDISC
        End Select
       
        MxCD.cbStruct     = SizeOf(MIXERCONTROLDETAILS)
        MxCD.dwControlID  = MxC_Mixer.dwControlID
        MxCD.cChannels    = 1
        MxCD.Item         = MxC_Mixer.cMultipleItems
        MxCD.cbDetails    = SizeOf(MIXERCONTROLDETAILS_LISTTEXT)
        MxCD.paDetails    = VarPtr(MxCD_List(0))
        dwResult = mixerGetControlDetails(hMixer, MxCD, %MIXER_GETCONTROLDETAILSF_LISTTEXT)
        If dwResult <> %MMSYSERR_NOERROR Then 
          Exit Function
        End If
         
        MxCD.cbDetails    = SizeOf(MIXERCONTROLDETAILS_UNSIGNED)
        MxCD.paDetails    = VarPtr(MxCD_Bool(0))
        dwResult = mixerGetControlDetails(hMixer, MxCD, %MIXER_GETCONTROLDETAILSF_VALUE)
        If dwResult <> %MMSYSERR_NOERROR Then 
          Exit Function
        End If  
        If MxLC_Mixer.Item = %MIXERCONTROL_CONTROLTYPE_MUX Then Reset MxCD_Bool()
       
        For Cnt = 0 To MxC_Mixer.cMultipleItems -1
          If (InStr (UCase$(MxCD_List(Cnt).szName), dStr)) Or (MxCD_List(Cnt).dwParam2 = CtrlID) Then
            If Value Then MxCD_Bool(Cnt).fValue = 1 Else MxCD_Bool(Cnt).fValue = 0
            dwResult = mixerSetControlDetails(hMixer, MxCD, %MIXER_SETCONTROLDETAILSF_VALUE)
            If dwResult <> %MMSYSERR_NOERROR Then 
              Function = dwResult
              Exit Function
            End If  
          End If
          Function = %MMSYSERR_INVALPARAM
        Next
      End Function
       
      '==================================================================================================
      ' Mx_GetRecordVolume()          Gets value of record control
      ' Parameters:
      ' dwControl                     Which control to use
      ' Returns:                      0 to 100 = value of volume control
      '--------------------------------------------------------------------------------------------------
      Function Mx_GetRecordVolume Alias "Mx_GetRecordVolume"(ByVal Ctrl As Dword) Export As Long
        Dim MxCD_List(50) As Local MIXERCONTROLDETAILS_LISTTEXT
        Dim MxCD_USign(50) As Local MIXERCONTROLDETAILS_UNSIGNED
        Dim MxCD As Local MIXERCONTROLDETAILS, Cnt As Local Dword, Tmp As Local Dword
        Dim fFound As Local Dword, dStr As Local String, CtrlID As Local Dword
       
        Select Case Ctrl
          Case %MX_STEREOMIX  : dstr = "STEREO"   : CtrlID = %MIXERLINE_COMPONENTTYPE_SRC_WAVEOUT
          Case %MX_MODEM      : dStr = "MODEM" : CtrlID = %MIXERLINE_COMPONENTTYPE_SRC_TELEPHONE
          Case %MX_AUXILIARY  : dStr = "AUX"   : CtrlID = %MIXERLINE_COMPONENTTYPE_SRC_AUXILIARY
          Case %MX_MICROPHONE : dstr = "MIC"   : CtrlID = %MIXERLINE_COMPONENTTYPE_SRC_MICROPHONE
          Case %MX_LINEIN     : dstr = "LINE"  : CtrlID = %MIXERLINE_COMPONENTTYPE_SRC_LINE
          Case %MX_CDAUDIO    : dStr = "CD"    : CtrlID = %MIXERLINE_COMPONENTTYPE_SRC_COMPACTDISC
        End Select
       
        For Cnt = 0 To MxL_Dest(1).cConnections -1                    
          If (InStr(UCase$( MxL_RecSrc(Cnt).szName), dStr)) Or (MxL_RecSrc(Cnt).dwComponentType = CtrlID) Then
            For Tmp = 0 To MxL_RecSrc(Cnt).cControls-1
              If MxC_RecSrc(Tmp, Cnt).dwControlType = %MIXERCONTROL_CONTROLTYPE_VOLUME Then fFound = 1 : Exit For
            Next
            If fFound Then Exit For
          End If
        Next
       
        MxCD.cbStruct         = SizeOf(MIXERCONTROLDETAILS)
        MxCD.dwControlID      = MxC_RecSrc(Tmp, Cnt).dwControlID
        MxCD.cChannels        = 1
        MxCD.Item             = MxC_RecSrc(Tmp, Cnt).cMultipleItems
        MxCD.cbDetails        = SizeOf(MIXERCONTROLDETAILS_LISTTEXT)
        MxCD.paDetails        = VarPtr(MxCD_Usign(0))
       
        If fFound Then dwResult = mixerGetControlDetails(hMixer, MxCD, %MIXER_GETCONTROLDETAILSF_VALUE)
        If dwResult <> %MMSYSERR_NOERROR Then 
          If MxDebug Then Mx_LogInfo "Mx_GetRecordVolume:mixerGetControlDetails:MIXER_GETCONTROLDETAILSF_VALUE failed with error " & Hex$(dwResult)
        End If  
      '  If MxDebug Then If fFound = 0 Then Mx_LogInfo "Mx_GetRecordVolume: Loop failed on test for " & dStr & " --------------"
        Function = Int((MxCD_USign(0).dwValue / 65535) * 100)
      End Function
       
      '==================================================================================================
      ' Mx_SetRecordVolume()          Sets state of mute control
      ' Parameters:
      ' Parameters:
      ' dwControl                     Which control to use
      ' fState                        Value for volume control; 0 to 100
      ' Returns:                      %MMSYSERR_NOERROR on success, %MMSYSERR_.... on error
      '--------------------------------------------------------------------------------------------------
      Function Mx_SetRecordVolume Alias "Mx_SetRecordVolume"(ByVal Ctrl As Dword, ByVal dwValue As Dword) Export As Long
        Dim MxCD_List(50) As Local MIXERCONTROLDETAILS_LISTTEXT
        Dim MxCD_USign(50) As Local MIXERCONTROLDETAILS_UNSIGNED
        Dim MxCD As Local MIXERCONTROLDETAILS, dStr As Local String, Cnt As Local Dword, Tmp As Local Dword
        Dim fFound As Local Dword, CtrlID As Local Dword
       
        Select Case Ctrl
          Case %MX_STEREOMIX  : dstr = "STEREO"   : CtrlID = %MIXERLINE_COMPONENTTYPE_SRC_WAVEOUT
          Case %MX_MODEM      : dStr = "MODEM" : CtrlID = %MIXERLINE_COMPONENTTYPE_SRC_TELEPHONE
          Case %MX_AUXILIARY  : dStr = "AUX"   : CtrlID = %MIXERLINE_COMPONENTTYPE_SRC_AUXILIARY
          Case %MX_MICROPHONE : dstr = "MIC"   : CtrlID = %MIXERLINE_COMPONENTTYPE_SRC_MICROPHONE
          Case %MX_LINEIN     : dstr = "LINE"  : CtrlID = %MIXERLINE_COMPONENTTYPE_SRC_LINE
          Case %MX_CDAUDIO    : dStr = "CD"    : CtrlID = %MIXERLINE_COMPONENTTYPE_SRC_COMPACTDISC
        End Select
       
        For Cnt = 0 To MxL_Dest(1).cConnections -1
          If (InStr(UCase$( MxL_RecSrc(Cnt).szName), dStr)) Or (MxL_RecSrc(Cnt).dwComponentType = CtrlID) Then
            For Tmp = 0 To MxL_RecSrc(Cnt).cControls-1
              If MxC_RecSrc(Tmp, Cnt).dwControlType = %MIXERCONTROL_CONTROLTYPE_VOLUME Then fFound = 1 : Exit For
            Next
            If fFound Then Exit For
          End If
        Next
       
        MxCD.cbStruct         = SizeOf(MIXERCONTROLDETAILS)
        MxCD.dwControlID      = MxC_RecSrc(Tmp, Cnt).dwControlID
        MxCD.cChannels        = 1
        MxCD.Item             = MxC_RecSrc(Tmp, Cnt).cMultipleItems
        MxCD.cbDetails        = SizeOf(MIXERCONTROLDETAILS_LISTTEXT)
        MxCD.paDetails        = VarPtr(MxCD_Usign(0))
        MxCD_USign(0).dwValue  = Int((dwValue * 65535) / 100)
       
        If fFound Then dwResult = mixerSetControlDetails(hMixer, MxCD, %MIXER_SETCONTROLDETAILSF_VALUE)
        If dwResult <> %MMSYSERR_NOERROR Then 
          If MxDebug Then Mx_LogInfo "Mx_SetRecordVolume:mixerGetControlDetails:MIXER_GETCONTROLDETAILSF_VALUE failed with error " & Hex$(dwResult)
        End If  
      '  If MxDebug Then If fFound = 0 Then Mx_LogInfo "Mx_SetRecordVolume: Loop failed on test for " & dStr & " --------------"
        Function = dwResult
      End Function
       
      '==================================================================================================
      ' Mx_GetPlayVolume()            Gets value of record control
      ' Parameters:
      ' dwControl                     Which control to use
      ' Returns:                      0 to 100 = value of volume control
      '--------------------------------------------------------------------------------------------------
      Function Mx_GetPlayVolume Alias "Mx_GetPlayVolume"(ByVal Ctrl As Dword) Export As Long
        Dim MxCD_List(50) As Local MIXERCONTROLDETAILS_LISTTEXT
        Dim MxCD_USign(50) As Local MIXERCONTROLDETAILS_UNSIGNED
        Dim MxCD As Local MIXERCONTROLDETAILS, dStr As Local String, Cnt As Local Dword, Tmp As Local Dword
        Dim fFound As Local Dword, CtrlID As Local Dword
       
        Select Case Ctrl
          Case %MX_MASTER     : dStr = "MASTER": CtrlID = %MIXERLINE_COMPONENTTYPE_DST_SPEAKERS
          Case %MX_WAVE       : dStr = "WAVE"  : CtrlID = %MIXERLINE_COMPONENTTYPE_SRC_WAVEOUT
          Case %MX_MIDI       : dStr = "MIDI"  : CtrlID = %MIXERLINE_COMPONENTTYPE_SRC_SYNTHESIZER
          Case %MX_MODEM      : dStr = "MODEM" : CtrlID = %MIXERLINE_COMPONENTTYPE_SRC_TELEPHONE
          Case %MX_AUXILIARY  : dStr = "AUX"   : CtrlID = %MIXERLINE_COMPONENTTYPE_SRC_AUXILIARY
          Case %MX_MICROPHONE : dstr = "MIC"   : CtrlID = %MIXERLINE_COMPONENTTYPE_SRC_MICROPHONE
          Case %MX_LINEIN     : dstr = "LINE"  : CtrlID = %MIXERLINE_COMPONENTTYPE_SRC_LINE
          Case %MX_CDAUDIO    : dStr = "CD"    : CtrlID = %MIXERLINE_COMPONENTTYPE_SRC_COMPACTDISC
        End Select
       
        If Ctrl = %MX_MASTER Then
          For Cnt = 0 To MxL_VolDest.cControls-1
            If MxC_VolDest(Cnt).dwControlType = %MIXERCONTROL_CONTROLTYPE_VOLUME Then
              MxCD.dwControlID  = MxC_VolDest(Cnt).dwControlID
              MxCD.Item         = MxC_VolDest(Cnt).cMultipleItems
              fFound = 1
              Exit For
            End If
          Next
        Else
          For Cnt = 0 To MxL_Dest(0).cConnections -1
            If (InStr(UCase$( MxL_VolSrc(Cnt).szName), dStr)) Or (MxL_VolSrc(Cnt).dwComponentType = CtrlID) Then
              For Tmp = 0 To MxL_VolSrc(Cnt).cControls-1
                If MxC_VolSrc(Tmp, Cnt).dwControlType = %MIXERCONTROL_CONTROLTYPE_VOLUME Then
                  fFound = 1
                  MxCD.dwControlID      = MxC_VolSrc(Tmp, Cnt).dwControlID
                  MxCD.Item             = MxC_VolSrc(Tmp, Cnt).cMultipleItems
                  Exit For
                End If
              Next
              If fFound Then Exit For
            End If
          Next
        End If
       
        MxCD.cbStruct         = SizeOf(MIXERCONTROLDETAILS)
        MxCD.cChannels        = 1
        MxCD.cbDetails        = SizeOf(MIXERCONTROLDETAILS_LISTTEXT)
        MxCD.paDetails        = VarPtr(MxCD_Usign(0))
       
        If fFound Then dwResult = mixerGetControlDetails(hMixer, MxCD, %MIXER_GETCONTROLDETAILSF_VALUE)
        If dwResult <> %MMSYSERR_NOERROR Then 
          If MxDebug Then Mx_LogInfo "Mx_GetPlayVolume:mixerGetControlDetails:MIXER_GETCONTROLDETAILSF_VALUE failed with error " & Hex$(dwResult)
        End If  
      '  If MxDebug Then If fFound = 0 Then Mx_LogInfo "Mx_GetPlayVolume: Loop failed on test for " & dStr & " -------------- " & MxC_VolDest(0).szName & ", " & MxC_VolDest(1).szName & ", " & MxC_VolDest(2).szName 
        Function = Int((MxCD_USign(0).dwValue / 65535) * 100)
      End Function
       
      '==================================================================================================
      ' Mx_SetPlayVolume()            Sets state of mute control
      ' Parameters:
      ' Parameters:
      ' dwControl                     Which control to use
      ' fState                        Value for volume control; 0 to 100
      ' Returns:                      %MMSYSERR_NOERROR on success, %MMSYSERR_.... on error
      '--------------------------------------------------------------------------------------------------
      Function Mx_SetPlayVolume Alias "Mx_SetPlayVolume"(ByVal Ctrl As Dword, ByVal dwValue As Dword) Export As Long
        Dim MxCD_List(50) As Local MIXERCONTROLDETAILS_LISTTEXT
        Dim MxCD_USign(50) As Local MIXERCONTROLDETAILS_UNSIGNED
        Dim MxCD As Local MIXERCONTROLDETAILS, dStr As Local String, Cnt As Local Dword, Tmp As Local Dword
        Dim fFound As Local Dword, CtrlID As Local Dword
       
        Select Case Ctrl
          Case %MX_MASTER     : dStr = "MASTER": CtrlID = %MIXERLINE_COMPONENTTYPE_DST_SPEAKERS
          Case %MX_WAVE       : dStr = "WAVE"  : CtrlID = %MIXERLINE_COMPONENTTYPE_SRC_WAVEOUT
          Case %MX_MIDI       : dStr = "MIDI"  : CtrlID = %MIXERLINE_COMPONENTTYPE_SRC_SYNTHESIZER
          Case %MX_MODEM      : dStr = "MODEM" : CtrlID = %MIXERLINE_COMPONENTTYPE_SRC_TELEPHONE
          Case %MX_AUXILIARY  : dStr = "AUX"   : CtrlID = %MIXERLINE_COMPONENTTYPE_SRC_AUXILIARY
          Case %MX_MICROPHONE : dstr = "MIC"   : CtrlID = %MIXERLINE_COMPONENTTYPE_SRC_MICROPHONE
          Case %MX_LINEIN     : dstr = "LINE"  : CtrlID = %MIXERLINE_COMPONENTTYPE_SRC_LINE
          Case %MX_CDAUDIO    : dStr = "CD"    : CtrlID = %MIXERLINE_COMPONENTTYPE_SRC_COMPACTDISC
        End Select
       
        If Ctrl = %MX_MASTER Then
          For Cnt = 0 To MxL_VolDest.cControls-1
            If MxC_VolDest(Cnt).dwControlType = %MIXERCONTROL_CONTROLTYPE_VOLUME Then
              MxCD.dwControlID  = MxC_VolDest(Cnt).dwControlID
              MxCD.Item         = MxC_VolDest(Cnt).cMultipleItems
              fFound = 1
              Exit For
            End If
          Next
        Else
          For Cnt = 0 To MxL_Dest(0).cConnections -1
            If (InStr(UCase$( MxL_VolSrc(Cnt).szName), dStr)) Or (MxL_VolSrc(Cnt).dwComponentType = CtrlID) Then
              For Tmp = 0 To MxL_VolSrc(Cnt).cControls-1
                If MxC_VolSrc(Tmp, Cnt).dwControlType = %MIXERCONTROL_CONTROLTYPE_VOLUME Then
                  fFound = 1
                  MxCD.dwControlID = MxC_VolSrc(Tmp, Cnt).dwControlID
                  MxCD.Item        = MxC_VolSrc(Tmp, Cnt).cMultipleItems
                  Exit For
                End If
              Next
              If fFound Then Exit For
            End If
          Next
        End If
       
        MxCD.cbStruct         = SizeOf(MIXERCONTROLDETAILS)
        MxCD.cChannels        = 1
        MxCD.cbDetails        = SizeOf(MIXERCONTROLDETAILS_LISTTEXT)
        MxCD.paDetails        = VarPtr(MxCD_Usign(0))
        MxCD_USign(0).dwValue  = Int((dwValue * 65535) / 100)
       
        If fFound Then dwResult = mixerSetControlDetails(hMixer, MxCD, %MIXER_SETCONTROLDETAILSF_VALUE)
        If dwResult <> %MMSYSERR_NOERROR Then 
          If MxDebug Then Mx_LogInfo "Mx_SetPlayVolume:mixerGetControlDetails:MIXER_GETCONTROLDETAILSF_VALUE failed with error " & Hex$(dwResult)
        End If  
      '  If MxDebug Then If fFound = 0 Then Mx_LogInfo "Mx_SetPlayVolume: Loop failed on test for " & dStr & " --------------"
        Function = dwResult
      End Function
       
      '==================================================================================================
      ' Mx_SaveParms()                Saves the Mixer parameters as set on entry
      '--------------------------------------------------------------------------------------------------
      Sub Mx_SaveParms Alias "Mx_SaveParms"() Export
        SVals.Mute(%MX_MASTER)        = Mx_GetMute(%MX_MASTER)
        SVals.Mute(%MX_WAVE)          = Mx_GetMute(%MX_WAVE)
        SVals.Mute(%MX_MIDI)          = Mx_GetMute(%MX_MIDI)
        SVals.Mute(%MX_MODEM)         = Mx_GetMute(%MX_MODEM)
        SVals.Mute(%MX_AUXILIARY)     = Mx_GetMute(%MX_AUXILIARY)
        SVals.Mute(%MX_MICROPHONE)    = Mx_GetMute(%MX_MICROPHONE)
        SVals.Mute(%MX_LINEIN)        = Mx_GetMute(%MX_LINEIN)
        SVals.Mute(%MX_CDAUDIO)       = Mx_GetMute(%MX_CDAUDIO)
       
        SVals.Mixer(%MX_STEREOMIX)    = Mx_GetMixer(%MX_STEREOMIX)
        SVals.Mixer(%MX_MODEM)        = Mx_GetMixer(%MX_MODEM)
        SVals.Mixer(%MX_AUXILIARY)    = Mx_GetMixer(%MX_AUXILIARY)
        SVals.Mixer(%MX_MICROPHONE)   = Mx_GetMixer(%MX_MICROPHONE)
        SVals.Mixer(%MX_LINEIN)       = Mx_GetMixer(%MX_LINEIN)
        SVals.Mixer(%MX_CDAUDIO)      = Mx_GetMixer(%MX_CDAUDIO)
       
        SVals.RecVol(%MX_STEREOMIX)   = Mx_GetRecordVolume(%MX_STEREOMIX)
        SVals.RecVol(%MX_MODEM)       = Mx_GetRecordVolume(%MX_MODEM)
        SVals.RecVol(%MX_AUXILIARY)   = Mx_GetRecordVolume(%MX_AUXILIARY)
        SVals.RecVol(%MX_MICROPHONE)  = Mx_GetRecordVolume(%MX_MICROPHONE)
        SVals.RecVol(%MX_LINEIN)      = Mx_GetRecordVolume(%MX_LINEIN)
        SVals.RecVol(%MX_CDAUDIO)     = Mx_GetRecordVolume(%MX_CDAUDIO)
       
        SVals.PlayVol(%MX_MASTER)     = Mx_GetPlayVolume(%MX_MASTER)
        SVals.PlayVol(%MX_WAVE)       = Mx_GetPlayVolume(%MX_WAVE)
        SVals.PlayVol(%MX_MIDI)       = Mx_GetPlayVolume(%MX_MIDI)
        SVals.PlayVol(%MX_MODEM)      = Mx_GetPlayVolume(%MX_MODEM)
        SVals.PlayVol(%MX_AUXILIARY)  = Mx_GetPlayVolume(%MX_AUXILIARY)
        SVals.PlayVol(%MX_MICROPHONE) = Mx_GetPlayVolume(%MX_MICROPHONE)
        SVals.PlayVol(%MX_LINEIN)     = Mx_GetPlayVolume(%MX_LINEIN)
        SVals.PlayVol(%MX_CDAUDIO)    = Mx_GetPlayVolume(%MX_CDAUDIO)
      End Sub
       
      '==================================================================================================
      ' Mx_RestoreParms ()            Restores parameters stored on entry
      '--------------------------------------------------------------------------------------------------
      Sub Mx_RestoreParms Alias "Mx_RestoreParms"() Export
        Mx_SetMute(%MX_MASTER, SVals.Mute(%MX_MASTER))
        Mx_SetMute(%MX_WAVE, SVals.Mute(%MX_WAVE))
        Mx_SetMute(%MX_MIDI, SVals.Mute(%MX_MIDI))
        Mx_SetMute(%MX_MODEM, SVals.Mute(%MX_MODEM))
        Mx_SetMute(%MX_AUXILIARY, SVals.Mute(%MX_AUXILIARY))
        Mx_SetMute(%MX_MICROPHONE, SVals.Mute(%MX_MICROPHONE))
        Mx_SetMute(%MX_LINEIN, SVals.Mute(%MX_LINEIN))
        Mx_SetMute(%MX_CDAUDIO, SVals.Mute(%MX_CDAUDIO))
       
        Mx_SetMixer(%MX_STEREOMIX, SVals.Mixer(%MX_STEREOMIX))
        Mx_SetMixer(%MX_MODEM, SVals.Mixer(%MX_MODEM))
        Mx_SetMixer(%MX_AUXILIARY, SVals.Mixer(%MX_AUXILIARY))
        Mx_SetMixer(%MX_MICROPHONE, SVals.Mixer(%MX_MICROPHONE))
        Mx_SetMixer(%MX_LINEIN, SVals.Mixer(%MX_LINEIN))
        Mx_SetMixer(%MX_CDAUDIO, SVals.Mixer(%MX_CDAUDIO))
       
        Mx_SetRecordVolume(%MX_STEREOMIX, SVals.RecVol(%MX_STEREOMIX))
        Mx_SetRecordVolume(%MX_MODEM, SVals.RecVol(%MX_MODEM))
        Mx_SetRecordVolume(%MX_AUXILIARY, SVals.RecVol(%MX_AUXILIARY))
        Mx_SetRecordVolume(%MX_MICROPHONE, SVals.RecVol(%MX_MICROPHONE))
        Mx_SetRecordVolume(%MX_LINEIN, SVals.RecVol(%MX_LINEIN))
        Mx_SetRecordVolume(%MX_CDAUDIO, SVals.RecVol(%MX_CDAUDIO))
       
        Mx_SetPlayVolume(%MX_MASTER, SVals.PlayVol(%MX_MASTER))
        Mx_SetPlayVolume(%MX_WAVE, SVals.PlayVol(%MX_WAVE))
        Mx_SetPlayVolume(%MX_MIDI, SVals.PlayVol(%MX_MIDI))
        Mx_SetPlayVolume(%MX_MODEM, SVals.PlayVol(%MX_MODEM))
        Mx_SetPlayVolume(%MX_AUXILIARY, SVals.PlayVol(%MX_AUXILIARY))
        Mx_SetPlayVolume(%MX_MICROPHONE, SVals.PlayVol(%MX_MICROPHONE))
        Mx_SetPlayVolume(%MX_LINEIN, SVals.PlayVol(%MX_LINEIN) )
        Mx_SetPlayVolume(%MX_CDAUDIO, SVals.PlayVol(%MX_CDAUDIO) )
      End Sub
       
      '==================================================================================================
      ' Mx_SetSampleParms()           Sets the samplerate, bitspersample, and channels (1/2)
      '--------------------------------------------------------------------------------------------------
      Function Mx_SetSampleParms Alias "Mx_SetSampleParms"(ByVal SRate As Dword, ByVal SChan As Dword, _
                                                         ByVal SBits As Dword) Export As Dword
       
        Local dwResult As Dword
        MxSampRate  = SRate
        MxSampChan  = SChan
        MxSampBits  = SBits
      End Function
       
      '==================================================================================================
      ' Mx_Record
      '--------------------------------------------------------------------------------------------------
      Function Mx_Record Alias "Mx_Record"() Export As Long
        Dim szStr As Local Asciiz * 256, szCapture As Local Asciiz * 256, szVal As Asciiz * 20
        If MxMaxFileLength Then szVal = " to " & Format$(MxMaxFileLength) Else szVal = ""
        szCapture = "set capture alignment " & Format$((MxSampBits\8) * MxSampChan) & _
                    " bitspersample " & Format$(MxSampBits) & _
                    " samplespersec " & Format$(MxSampRate) & _
                    " channels " & Format$(MxSampChan) & _
                    " bytespersec " & Format$((MxSampBits\8) * MxSampChan * MxSampRate)
        mciSendString("close all", szStr, SizeOf(szStr), 0)
        mciSendString("open new type waveaudio alias capture", szStr, SizeOf(szStr), 0)
        mciSendString("Seek capture to start", szStr, SizeOf(szStr), 0)
        mciSendString(szCapture, szStr, SizeOf(szStr), 0)
        mciSendString("record capture" & szVal, szStr, SizeOf(szStr), 0)
      End Function
       
      '==================================================================================================
      ' Mx_Play
      '--------------------------------------------------------------------------------------------------
      Function Mx_Play Alias "Mx_Play"(ByVal FileName As String) Export As Long
        Dim szStr As Local Asciiz * 256
        If FileName = "" Then
          mciSendString("open new type waveaudio alias capture", szStr, SizeOf(szStr), 0)
        Else
          If InStr(FileName, Any "") Then
            GetShortPathName ByVal StrPtr(FileName), ByVal VarPtr(szStr), SizeOf(szStr)
            FileName = szStr
          End If
          mciSendString("close all", szStr, SizeOf(szStr), 0)
          mciSendString("open waveaudio!" & FileName & " alias capture", szStr, SizeOf(szStr), 0)
        End If
       
        mciSendString("Set capture time format ms", szStr, SizeOf(szStr), 0)
        mciSendString("play capture from 0", szStr, SizeOf(szStr), 0)
      End Function
       
      '==================================================================================================
      ' Mx_Stop
      '--------------------------------------------------------------------------------------------------
      Function Mx_Stop Alias "Mx_Stop"() Export As Long
        Dim szStr As Local Asciiz * 256
        mciSendString("stop capture", szStr, SizeOf(szStr), 0)
      End Function
       
      '==================================================================================================
      ' Mx_Pause()
      '--------------------------------------------------------------------------------------------------
      Function Mx_Pause Alias "Mx_Pause"() Export As Long
        Dim szStr As Local Asciiz * 256
        mciSendString("pause capture", szStr, SizeOf(szStr), 0)
      End Function
       
      '==================================================================================================
      ' Mx_Resume()
      '--------------------------------------------------------------------------------------------------
      Function Mx_Resume Alias "Mx_Resume"() Export As Long
        Dim szStr As Local Asciiz * 256
        mciSendString("resume capture", szStr, SizeOf(szStr), 0)
      End Function
       
      '==================================================================================================
      ' Mx_Status()
      '--------------------------------------------------------------------------------------------------
      Function Mx_Status Alias "Mx_Status"() Export As String
        Dim szStr As Local Asciiz * 256
        mciSendString("status capture mode", szStr, SizeOf(szStr), 0)
        Function = szStr
      End Function
       
      '==================================================================================================
      ' Mx_SkipBack()                 On playback, used to skip backward a given period.
      ' Parameters:
      ' SkipTime                      Time in milliseconds for position to move
      ' Returns:                      Time in millisecs moved. Can be smaller as requested on last move.
      '--------------------------------------------------------------------------------------------------
      Function Mx_SkipBack Alias "Mx_SkipBack"(ByVal SkipTime As Dword) Export As Dword
        Local Result As Long, szStr As Asciiz * 256, lPos As Long
        mciSendString("status capture position", szStr, SizeOf(szStr), 0)
        lPos = Val(szStr)
        Result = lPos - SkipTime
        If Result < 0 Then
          Result = 0
          Function = lPos
        Else
          Function = SkipTime
        End If
        mciSendString("play capture from " & Format$(Result), szStr, SizeOf(szStr), 0)
        Function = Result
      End Function
       
      '==================================================================================================
      ' Mx_SkipForward()              On playback, used to skip forward a given period
      ' Parameters:
      ' SkipTime                      Time in milliseconds for position to move
      ' Returns:                      Time in millisecs moved. Can be smaller as requested on last move.
      '--------------------------------------------------------------------------------------------------
      Function Mx_SkipForward Alias "Mx_SkipForward"(ByVal SkipTime As Dword) Export As Long
        Local Result As Long, szStr As Asciiz * 256, lPos As Long, lPosNew As Long
        mciSendString("status capture length", szStr, SizeOf(szStr), 0)
        Result = Val(szStr)
        mciSendString("status capture position", szStr, SizeOf(szStr), 0)
        lPos = Val(szStr)
        lPosNew = lPos + SkipTime
        If lPosNew <= Result Then
          mciSendString("play capture from " & Format$(lPosNew), szStr, SizeOf(szStr), 0)
          Function = Result
        Else
          Function = 0
        End If
      End Function
       
      '==================================================================================================
      ' Mx_GetPosition()              Returns position in percent during playback
      ' Returns:                      Position.
      '--------------------------------------------------------------------------------------------------
      Function Mx_GetPosition Alias "Mx_GetPosition"() Export As Long
        Local Result As Long, szStr As Asciiz * 256, lPos As Long, lPosNew As Long
        mciSendString("status capture mode", szStr, SizeOf(szStr), 0)
        If (szStr = "recording") And (MxMaxFileLength > 0) Then
          Result = MxMaxFileLength
        ElseIf (szStr = "recording") Then
          Function = 0 : Exit Function
        Else
          mciSendString("status capture length", szStr, SizeOf(szStr), 0)
          Result = Val(szStr)
        End If
        mciSendString("status capture position", szStr, SizeOf(szStr), 0)
        lPos = Val(szStr)
        Function = Int((lPos / Result) * 100)
      End Function
       
      '==================================================================================================
      ' Mx_DestChannels               Returns the number of destination channels on the mixer
      ' parameters: none
      ' Returns:                      Number of channels present
      '--------------------------------------------------------------------------------------------------
      Function Mx_DestChannels Alias "Mx_DestChannels"() Export As Long
        Function = MxCaps.cDestinations
      End Function
       
      '==================================================================================================
      ' Mx_Close                      Closes the mixer if open
      ' Parameters: none
      ' Result:                       Function returns %MMSYSERR_NOERROR (0) on succes else %MMSYSERR_...
      '--------------------------------------------------------------------------------------------------
      Function Mx_Close Alias "Mx_Close"() Export As Long
        Function = MixerClose(hMixer)
      End Function
       
      '==================================================================================================
      ' Mx_Save                       Save capture file
      ' Parameters: none
      ' Result:                       Function returns %MMSYSERR_NOERROR (0) on succes else %MMSYSERR_...
      '--------------------------------------------------------------------------------------------------
      Function Mx_Save Alias "Mx_Save"(ByVal FileName As String) Export As Long
        Local szStr As Asciiz * 256
        dwResult = mciSendString("save capture " & FileName, szStr, SizeOf(szStr), 0)
        Function = dwResult
      End Function
       
      '==================================================================================================
      ' Mx_SetRecordLength            Sets max filelenght
      ' Parameters:
      ' FileLen                       in milliseconds
      ' Result:                       None
      '--------------------------------------------------------------------------------------------------
      Sub Mx_SetRecordLength Alias "Mx_SetRecordLength"(ByVal FileLen As Dword) Export
        MxMaxFileLength = FileLen
      End Sub
       
      '==================================================================================================
      ' Mx_GetRecordLength            Sets max filelenght
      ' Result:                       File length
      '--------------------------------------------------------------------------------------------------
      Function Mx_GetRecordLength Alias "Mx_GetRecordLength"() Export As Dword
        Function = MxMaxFileLength
      End Function
       
      '==================================================================================================
      ' Mx_LogInfo
      '--------------------------------------------------------------------------------------------------
      Sub Mx_LogInfo Alias "Mx_LogInfo" (ByVal InfoTxt As String)
        Local hFile As Long
        hFile = FreeFile
        Open "mixerapi.log" For Append  As #hFile
        Print #hFile, InfoTxt
        Close #hFile
      End Sub
       
      '==================================================================================================
      ' Mx_Debug
      '--------------------------------------------------------------------------------------------------
      Sub Mx_Debug Alias "Mx_Debug"(ByVal lState As Long, ByVal lInit As Long) Export
        MxDebug = lState                                                     
        If lState Then
          If Dir$("mixerapi.log") <> "" Then Kill "mixerapi.tst"
        End If  
        If lInit Then
          If hMixer Then
            MixerClose (hMixer)
            Mx_Open 0
          End If  
        End If
      End Sub
       
      '==================================================================================================
      ------------------
      Regards,
      Peter



      [This message has been edited by Peter Lameijn (edited September 06, 2005).]
      Regards,
      Peter

      Comment


      • #4
        Peter,

        FYI - I tried the updated DLL code and it seems to work as intended now on my
        XPProSP2 machine with Realtec AC97 audio.

        ------------------

        Comment


        • #5
          The mixerapi.dll causes GPF on XP SP2 with Realtek HD Audio


          ------------------
          Patrice Terrier
          mailto[email protected][email protected]</A>
          www.zapsolution.com
          Addons: WinLIFT (Skin Engine), GDImage (Graphic control), Artwork (logo creation), GDI+ Helper (GDIPLUS)
          Patrice Terrier
          www.zapsolution.com
          www.objreader.com
          Addons: GDImage.DLL 32/64-bit (Graphic library), WinLIFT.DLL 32/64-bit (Skin Engine).

          Comment


          • #6
            It's probably an array bounds question. Some arrays are ubound fixed at 50.
            Redimming them to the actual needed value should probably fix it.
            (Never thought more than 50 resources would be available, never seen more than 14... )

            ------------------
            Regards,
            Peter
            Regards,
            Peter

            Comment


            • #7
              Demo version with device selection in menu:

              In the DLL source is also a small error. for this code to work, replace:
              Code:
                dwResult = MixerOpen(hMixer, 0, 0, 0, 0)
              with:
              Code:
                dwResult = MixerOpen(hMixer, MixerNumber, 0, 0, 0)
              in the Mx_Open function.

              Code:
              '==================================================================================================
              ' Testprogram for MixerApi.DLL
              ' You can record and play files, and adjust the mixer controls
              ' Created Peter Lameijn, Aug 26, 2005
              '                      , Added device selection menu. April 18, 2009
              '--------------------------------------------------------------------------------------------------
              #Compile Exe
              #Dim All
              #Include "Win32Api.inc"
              #Include "Commctrl.inc"
              #Include "ComDlg32.inc"
              #Include "MixerApi.inc"
              
              %TRB_STYLE = %WS_CHILD Or %TBS_HORZ Or %WS_VISIBLE Or %TBS_AUTOTICKS Or %TBS_BOTTOM Or %WS_TABSTOP
              
              %VOL_MASTER   = 101 : %VOL_WAVE     = 102 : %VOL_MIDI     = 103 : %VOL_MODEM    = 104
              %VOL_AUX      = 105 : %VOL_MIC      = 106 : %VOL_LINEIN   = 107 : %VOL_CDAUDIO  = 108
              %LVOL_MASTER  = 111 : %LVOL_WAVE    = 112 : %LVOL_MIDI    = 113 : %LVOL_MODEM   = 114
              %LVOL_AUX     = 115 : %LVOL_MIC     = 116 : %LVOL_LINEIN  = 117 : %LVOL_CDAUDIO = 118
              %MUTE_MASTER  = 121 : %MUTE_WAVE    = 122 : %MUTE_MIDI    = 123 : %MUTE_MODEM   = 124
              %MUTE_AUX     = 125 : %MUTE_MIC     = 126 : %MUTE_LINEIN  = 127 : %MUTE_CDAUDIO = 128
              %REC_STMIX    = 131 : %REC_MODEM    = 132 : %REC_AUX      = 133 : %REC_MIC      = 134
              %REC_LINEIN   = 135 : %REC_CDAUDIO  = 136 : %MIX_STMIX    = 141 : %MIX_MODEM    = 142
              %MIX_AUX      = 143 : %MIX_MIC      = 144 : %MIX_LINEIN   = 145 : %MIX_CDAUDIO  = 146
              %LREC_STMIX   = 151 : %LREC_MODEM   = 152 : %LREC_AUX     = 153 : %LREC_MIC     = 154
              %LREC_LINEIN  = 155 : %LREC_CDAUDIO = 156
              %CMD_RECORD   = 161 : %CMD_PLAY     = 162 : %CMD_STOP     = 163 : %CMD_SKIPBACK = 164
              %CMD_SKIPFORW = 165 : %PLAYSTATE    = 166 : %CMD_PAUSE    = 167 : %STATUSBAR    = 168
              %CMD_FILE     = 169 : %CMD_SAVE     = 170 : %ID_MENU      = 200
              
              Global hMixer, hDlg, hMixerID, hMenu, hPopup1, hPopup2, hNumDevs As Dword
              
              '==================================================================================================
              Sub SetMixerChecks()
                Control Set Check hDlg, %MIX_STMIX    , Mx_GetMixer(%MX_STEREOMIX)
                Control Set Check hDlg, %MIX_MODEM    , Mx_GetMixer(%MX_MODEM)
                Control Set Check hDlg, %MIX_AUX      , Mx_GetMixer(%MX_AUXILIARY)
                Control Set Check hDlg, %MIX_MIC      , Mx_GetMixer(%MX_MICROPHONE)
                Control Set Check hDlg, %MIX_LINEIN   , Mx_GetMixer(%MX_LINEIN)
                Control Set Check hDlg, %MIX_CDAUDIO  , Mx_GetMixer(%MX_CDAUDIO)
              End Sub
              
              Function Control_Update_Text (ByVal hWnd As Dword, ByVal CtrlID As Dword, ByVal Txt As String) As Long
                Local dStr As String
                Control Get Text hWnd, CtrlID To dStr
                If dStr <> Txt Then
                  Control Set Text hWnd, CtrlID, Txt
                  Function = -1
                End If
              End Function
              
              Function Control_Update_Check (ByVal hWnd As Dword, ByVal CtrlID As Dword, ByVal NewVal As Long)As Long
                Local Result As Long
                Control Get Check hWnd, CtrlID To Result
                If NewVal <> Result Then
                  Control Set Check hWnd, CtrlID, NewVal
                  Function = -1
                End If
              End Function
              
              Function Control_Update_TrackBar (ByVal hWnd As Dword, ByVal CtrlID As Dword, ByVal NewVal As Long)As Long
                Local Result As Long
                Control Send hWnd, CtrlID, %TBM_GETPOS, 0, 0 To Result
                If NewVal <> Result Then
                  Control Send hWnd, CtrlID, %TBM_SETPOS, 1, NewVal
                  Function = -1
                End If
              End Function
              
              
              Sub SetValues()
                Local Result As Dword
              
                Result = Mx_GetPlayVolume(%MX_MASTER)
                Control_Update_Text hDlg, %LVOL_MASTER , Format$(Result)
                Control_Update_TrackBar hDlg, %VOL_MASTER, Result
                Result = Mx_GetPlayVolume(%MX_WAVE)
                Control_Update_Text hDlg, %LVOL_WAVE   , Format$(Result)
                Control_Update_TrackBar hDlg, %VOL_WAVE, Result
                Result = Mx_GetPlayVolume(%MX_MIDI)
                Control_Update_Text hDlg, %LVOL_MIDI   , Format$(Result)
                Control_Update_TrackBar hDlg, %VOL_MIDI, Result
                Result = Mx_GetPlayVolume(%MX_MODEM)
                Control_Update_Text hDlg, %LVOL_MODEM  , Format$(Result)
                Control_Update_TrackBar hDlg, %VOL_MODEM, Result
                Result = Mx_GetPlayVolume(%MX_AUXILIARY)
                Control_Update_Text hDlg, %LVOL_AUX    , Format$(Result)
                Control_Update_TrackBar hDlg, %VOL_AUX, Result
                Result = Mx_GetPlayVolume(%MX_MICROPHONE)
                Control_Update_Text hDlg, %LVOL_MIC    , Format$(Result)
                Control_Update_TrackBar hDlg, %VOL_MIC, Result
                Result = Mx_GetPlayVolume(%MX_LINEIN)
                Control_Update_Text hDlg, %LVOL_LINEIN , Format$(Result)
                Control_Update_TrackBar hDlg, %VOL_LINEIN, Result
                Result = Mx_GetPlayVolume(%MX_CDAUDIO)
                Control_Update_Text hDlg, %LVOL_CDAUDIO, Format$(Result)
                Control_Update_TrackBar hDlg, %VOL_CDAUDIO, Result
              
                Result = Mx_GetRecordVolume(%MX_STEREOMIX)
                Control_Update_Text hDlg, %LREC_STMIX , Format$(Result)
                Control_Update_TrackBar hDlg, %REC_STMIX, Result
                Result = Mx_GetRecordVolume(%MX_MODEM)
                Control_Update_Text hDlg, %LREC_MODEM  , Format$(Result)
                Control_Update_TrackBar hDlg, %REC_MODEM, Result
                Result = Mx_GetRecordVolume(%MX_AUXILIARY)
                Control_Update_Text hDlg, %LREC_AUX    , Format$(Result)
                Control_Update_TrackBar hDlg, %REC_AUX, Result
                Result = Mx_GetRecordVolume(%MX_MICROPHONE)
                Control_Update_Text hDlg, %LREC_MIC    , Format$(Result)
                Control_Update_TrackBar hDlg, %REC_MIC, Result
                Result = Mx_GetRecordVolume(%MX_LINEIN)
                Control_Update_Text hDlg, %LREC_LINEIN , Format$(Result)
                Control_Update_TrackBar hDlg, %REC_LINEIN, Result
                Result = Mx_GetRecordVolume(%MX_CDAUDIO)
                Control_Update_Text hDlg, %LREC_CDAUDIO, Format$(Result)
                Control_Update_TrackBar hDlg, %REC_CDAUDIO, Result
              
                Result = Mx_GetMute(%MX_MASTER)
                Control_Update_Check hDlg, %MUTE_MASTER, Result
                Result = Mx_GetMute(%MX_WAVE)
                Control_Update_Check hDlg, %MUTE_WAVE, Result
                Result = Mx_GetMute(%MX_MIDI)
                Control_Update_Check hDlg, %MUTE_MIDI, Result
                Result = Mx_GetMute(%MX_MODEM)
                Control_Update_Check hDlg, %MUTE_MODEM, Result
                Result = Mx_GetMute(%MX_AUXILIARY)
                Control_Update_Check hDlg, %MUTE_AUX, Result
                Result = Mx_GetMute(%MX_MICROPHONE)
                Control_Update_Check hDlg, %MUTE_MIC, Result
                Result = Mx_GetMute(%MX_LINEIN)
                Control_Update_Check hDlg, %MUTE_LINEIN, Result
                Result = Mx_GetMute(%MX_CDAUDIO)
                Control_Update_Check hDlg, %MUTE_CDAUDIO, Result
              
                Result = Mx_GetMixer(%MX_STEREOMIX)
                Control_Update_Check hDlg, %MIX_STMIX, Result
                Result = Mx_GetMixer(%MX_MODEM)
                Control_Update_Check hDlg, %MIX_MODEM, Result
                Result = Mx_GetMixer(%MX_AUXILIARY)
                Control_Update_Check hDlg, %MIX_AUX, Result
                Result = Mx_GetMixer(%MX_MICROPHONE)
                Control_Update_Check hDlg, %MIX_MIC, Result
                Result = Mx_GetMixer(%MX_LINEIN)
                Control_Update_Check hDlg, %MIX_LINEIN, Result
                Result = Mx_GetMixer(%MX_CDAUDIO)
                Control_Update_Check hDlg, %MIX_CDAUDIO, Result
              
              End Sub
              
              Sub SetMixer ()
                Mx_Close
                Mx_Open hMixerID
                Dialog Set Text hDlg, Mx_GetDescription
              End Sub
              
              CallBack Function CbMain()
                Local Result As Long, szStr As Asciiz * 256, dStr As String, X As Long
                Select Case CbMsg
                  Case %WM_INITDIALOG
                    SetTimer CbHndl, &h0001, 50, 0
                    Mx_Open hMixerID
                    Dialog Set Text CbHndl, Mx_GetDescription
                    Menu Set State hMenu, ByCmd %ID_MENU + hMixerID, %MF_ENABLED Or %MF_CHECKED
                    SetValues
              
                  Case %WM_COMMAND
                    If (CbCtl => %ID_MENU) And (CbCtl <= %ID_MENU + hNumDevs -1) Then
                      hMixerID = CbCtl - %ID_MENU
                      SetMixer
                      For X = %ID_MENU To %ID_MENU + hNumDevs -1
                        If CbCtl = x Then
                          Menu Set State hMenu, ByCmd X, %MF_ENABLED Or %MF_CHECKED
                        Else
                          Menu Set State hMenu, ByCmd X, %MF_ENABLED Or %MF_UNCHECKED
                        End If
                      Next
                    End If
                    If CbCtlMsg = %BN_CLICKED Then
                      Select Case CbCtl
                        Case %MUTE_MASTER
                          Control Get Check CbHndl, CbCtl To Result : Mx_SetMute(%MX_MASTER, Result)
                        Case %MUTE_WAVE
                          Control Get Check CbHndl, CbCtl To Result : Mx_SetMute(%MX_WAVE, Result)
                        Case %MUTE_MIDI
                          Control Get Check CbHndl, CbCtl To Result : Mx_SetMute (%MX_MIDI, Result)
                        Case %MUTE_MODEM
                          Control Get Check CbHndl, CbCtl To Result : Mx_SetMute (%MX_MODEM, Result)
                        Case %MUTE_AUX
                          Control Get Check CbHndl, CbCtl To Result : Mx_SetMute (%MX_AUXILIARY, Result)
                        Case %MUTE_MIC
                          Control Get Check CbHndl, CbCtl To Result : Mx_SetMute (%MX_MICROPHONE, Result)
                        Case %MUTE_LINEIN
                          Control Get Check CbHndl, CbCtl To Result : Mx_SetMute (%MX_LINEIN, Result)
                        Case %MUTE_CDAUDIO
                          Control Get Check CbHndl, CbCtl To Result : Mx_SetMute (%MX_CDAUDIO, Result)
              
                        Case %MIX_STMIX
                          Control Get Check CbHndl, CbCtl To Result : Mx_SetMixer(%MX_STEREOMIX, Result)
                          SetMixerChecks
                        Case %MIX_MODEM
                          Control Get Check CbHndl, CbCtl To Result : Mx_SetMixer(%MX_MODEM, Result)
                          SetMixerChecks
                        Case %MIX_AUX
                          Control Get Check CbHndl, CbCtl To Result : Mx_SetMixer(%MX_AUXILIARY, Result)
                          SetMixerChecks
                        Case %MIX_MIC
                          Control Get Check CbHndl, CbCtl To Result : Mx_SetMixer(%MX_MICROPHONE, Result)
                          SetMixerChecks
                        Case %MIX_LINEIN
                          Control Get Check CbHndl, CbCtl To Result : Mx_SetMixer(%MX_LINEIN, Result)
                          SetMixerChecks
                        Case %MIX_CDAUDIO
                          Control Get Check CbHndl, CbCtl To Result : Mx_SetMixer(%MX_CDAUDIO, Result)
                          SetMixerChecks
              
                        Case %CMD_RECORD
                          Mx_SetSampleParms 44100, 2, 16
                          Mx_SetRecordLength 300000
                          Result = Mx_Record
                          Control Disable CbHndl, %CMD_RECORD
                          Control Disable CbHndl, %CMD_PLAY
                          Control Enable CbHndl, %CMD_PAUSE
                          Control Enable CbHndl, %CMD_SKIPBACK
                          Control Enable CbHndl, %CMD_SKIPFORW
                        Case %CMD_PLAY
                          Control Send hDlg, %STATUSBAR, %SB_SETTEXT, 3, VarPtr(szStr)
                          Mx_Play ""
                          Control Disable CbHndl, %CMD_RECORD
                          Control Disable CbHndl, %CMD_PLAY
                          Control Enable CbHndl, %CMD_PAUSE
                          Control Enable CbHndl, %CMD_SKIPBACK
                          Control Enable CbHndl, %CMD_SKIPFORW
                        Case %CMD_STOP
                          Mx_Stop
                          Control Enable CbHndl, %CMD_RECORD
                          Control Enable CbHndl, %CMD_PLAY
                          Control Disable CbHndl, %CMD_PAUSE
                          Control Disable CbHndl, %CMD_SKIPBACK
                          Control Disable CbHndl, %CMD_SKIPFORW
                        Case %CMD_SKIPBACK
                          Mx_SkipBack(1000)
                        Case %CMD_SKIPFORW
                          Mx_SkipForward(1000)
                        Case %CMD_PAUSE
                          szStr = Mx_Status()
                          If szStr = "paused" Then
                            Mx_Resume
                          Else
                            Mx_Pause
                          End If
                        Case %CMD_FILE
                          dStr = ""
                          OpenFileDialog(hDlg, "Open File", dStr, CurDir$, "soundfiles (*.wav)|*.wav", "", _
                                                %OFN_FILEMUSTEXIST Or %OFN_HIDEREADONLY Or %OFN_LONGNAMES)
                          Control Send hDlg, %STATUSBAR, %SB_SETTEXT, 3, StrPtr(dStr)
                          If dStr <> "" Then
                            Mx_Play dStr
                            Control Disable CbHndl, %CMD_RECORD
                            Control Disable CbHndl, %CMD_PLAY
                            Control Enable CbHndl, %CMD_PAUSE
                            Control Enable CbHndl, %CMD_SKIPBACK
                            Control Enable CbHndl, %CMD_SKIPFORW
                          End If
                        Case %CMD_SAVE
                          dStr = ""
                          SaveFileDialog(hDlg, "Open File", dStr, CurDir$, "soundfiles (*.wav)|*.wav", "", _
                                              %OFN_FILEMUSTEXIST Or %OFN_HIDEREADONLY Or %OFN_LONGNAMES)
                          Control Send hDlg, %STATUSBAR, %SB_SETTEXT, 3, StrPtr(dStr)
                          If dStr <> "" Then Mx_Save dStr
                      End Select
                    End If
                  Case %WM_TIMER
                    SetValues
                    szStr = Mx_Status()
                    If szStr = "stopped" Then
                      Control Enable CbHndl, %CMD_RECORD
                      Control Enable CbHndl, %CMD_PLAY
                      Control Disable CbHndl, %CMD_PAUSE
                      Control Disable CbHndl, %CMD_SKIPBACK
                      Control Disable CbHndl, %CMD_SKIPFORW
                    End If
                    If (szStr = "playing") Or (szStr = "recording") Then
                      Result = Mx_GetPosition()
                      dStr = Format$(Result)
                      Control Send hdlg, %PLAYSTATE, %PBM_SETPOS, Result, 0
                      Control Send hDlg, %STATUSBAR, %SB_SETTEXT, 2, StrPtr(dStr)
                    ElseIf szStr = "stopped" Then
                      dStr = ""
                      Control Send hdlg, %PLAYSTATE, %PBM_SETPOS, 0, 0
                      Control Send hDlg, %STATUSBAR, %SB_SETTEXT, 2, StrPtr(dStr)
                    End If
                  Case %WM_HSCROLL
                    Select Case CbLParam
                      Case GetDlgItem(CbHndl,%VOL_MASTER)
                        Control Send CbHndl, %VOL_MASTER, %TBM_GETPOS, 0, 0 To Result
                        Control Set Text CbHndl,  %LVOL_MASTER, Format$(Result)
                        Mx_SetPlayVolume (%MX_MASTER, Result)
              
                      Case GetDlgItem(CbHndl,%VOL_WAVE)
                        Control Send CbHndl, %VOL_WAVE, %TBM_GETPOS, 0, 0 To Result
                        Control Set Text CbHndl,  %LVOL_WAVE, Format$(Result)
                        Mx_SetPlayVolume (%MX_WAVE, Result)
              
                      Case GetDlgItem(CbHndl,%VOL_MIDI)
                        Control Send CbHndl, %VOL_MIDI, %TBM_GETPOS, 0, 0 To Result
                        Control Set Text CbHndl,  %LVOL_MIDI, Format$(Result)
                        Mx_SetPlayVolume (%MX_MIDI, Result)
              
                      Case GetDlgItem(CbHndl,%VOL_MODEM)
                        Control Send CbHndl, %VOL_MODEM, %TBM_GETPOS, 0, 0 To Result
                        Control Set Text CbHndl,  %LVOL_MODEM, Format$(Result)
                        Mx_SetPlayVolume (%MX_MODEM, Result)
              
                      Case GetDlgItem(CbHndl,%VOL_AUX)
                        Control Send CbHndl, %VOL_AUX, %TBM_GETPOS, 0, 0 To Result
                        Control Set Text CbHndl,  %LVOL_AUX, Format$(Result)
                        Mx_SetPlayVolume (%MX_AUXILIARY, Result)
              
                      Case GetDlgItem(CbHndl,%VOL_MIC)
                        Control Send CbHndl, %VOL_MIC, %TBM_GETPOS, 0, 0 To Result
                        Control Set Text CbHndl,  %LVOL_MIC, Format$(Result)
                        Mx_SetPlayVolume (%MX_MICROPHONE, Result)
              
                      Case GetDlgItem(CbHndl,%VOL_LINEIN)
                        Control Send CbHndl, %VOL_LINEIN, %TBM_GETPOS, 0, 0 To Result
                        Control Set Text CbHndl,  %LVOL_LINEIN, Format$(Result)
                        Mx_SetPlayVolume (%MX_LINEIN, Result)
              
                      Case GetDlgItem(CbHndl,%VOL_CDAUDIO)
                        Control Send CbHndl, %VOL_CDAUDIO, %TBM_GETPOS, 0, 0 To Result
                        Control Set Text CbHndl,  %LVOL_CDAUDIO, Format$(Result)
                        Mx_SetPlayVolume (%MX_CDAUDIO, Result)
              
              
                      Case GetDlgItem(CbHndl,%REC_STMIX)
                        Control Send CbHndl, %REC_STMIX, %TBM_GETPOS, 0, 0 To Result
                        Control Set Text CbHndl,  %LREC_STMIX, Format$(Result)
                        Mx_SetRecordVolume (%MX_STEREOMIX, Result)
              
                      Case GetDlgItem(CbHndl,%REC_MODEM)
                        Control Send CbHndl, %REC_MODEM, %TBM_GETPOS, 0, 0 To Result
                        Control Set Text CbHndl,  %LREC_MODEM, Format$(Result)
                        Mx_SetRecordVolume (%MX_MODEM, Result)
              
                      Case GetDlgItem(CbHndl,%REC_AUX)
                        Control Send CbHndl, %REC_AUX, %TBM_GETPOS, 0, 0 To Result
                        Control Set Text CbHndl,  %LREC_AUX, Format$(Result)
                        Mx_SetRecordVolume (%MX_AUXILIARY, Result)
              
                      Case GetDlgItem(CbHndl,%REC_MIC)
                        Control Send CbHndl, %REC_MIC, %TBM_GETPOS, 0, 0 To Result
                        Control Set Text CbHndl,  %LREC_MIC, Format$(Result)
                        Mx_SetRecordVolume (%MX_MICROPHONE, Result)
              
                      Case GetDlgItem(CbHndl,%REC_LINEIN)
                        Control Send CbHndl, %REC_LINEIN, %TBM_GETPOS, 0, 0 To Result
                        Control Set Text CbHndl,  %LREC_LINEIN, Format$(Result)
                        Mx_SetRecordVolume (%MX_LINEIN, Result)
              
                      Case GetDlgItem(CbHndl,%REC_CDAUDIO)
                        Control Send CbHndl, %REC_CDAUDIO, %TBM_GETPOS, 0, 0 To Result
                        Control Set Text CbHndl,  %LREC_CDAUDIO, Format$(Result)
                        Mx_SetRecordVolume (%MX_CDAUDIO, Result)
              
                        End Select
                  Case %WM_DESTROY
                    Mx_Close
                    KillTimer CbHndl, &h0001
                    mciSendString("close all", szStr, Len(szStr), 0)
                End Select
              End Function
              
              '==================================================================================================
              ' Main
              '--------------------------------------------------------------------------------------------------
              Function PBMain () As Long
                Local VolMaster, VolWave, VolMidi, VolModem, VolAux, VolMic, VolLineIn, VolCDAudio, X As Dword
                Dim SbParts(4) As Local Dword
              
                Mx_Debug 1, 0
              
                Dialog New 0, "",,,465,240, %WS_CAPTION Or %WS_BORDER Or %WS_SYSMENU To hDlg
              
                hNumDevs = MixerGetNumDevs
                Dialog New 0, "",,,465,240, %WS_CAPTION Or %WS_BORDER Or %WS_SYSMENU To hDlg
              
              
                Menu New Bar To hMenu
              
                Menu New PopUp To hPopup1
                Menu Add PopUp, hMenu, "&Device", hPopup1, %MF_ENABLED
                For X = 0 To hNumDevs -1
                  Mx_Open X
                  Menu Add String, hPopup1, Mx_GetDescription, %ID_MENU + x, %MF_ENABLED
                  Mx_Close
                Next
                hMixerID = 0
                Menu Attach hMenu, hDlg
              '..................................................................................................
                Control Add Frame, hDlg, -1, "Muting for speaker:", 5, 10, 80, 145
              
                Control Add CheckBox, hDlg, %MUTE_MASTER  , "Master"  , 15, 25, 60, 12
                Control Add CheckBox, hDlg, %MUTE_WAVE    , "Wave"    , 15, 40, 60, 12
                Control Add CheckBox, hDlg, %MUTE_MIDI    , "Midi"    , 15, 55, 60, 12
                Control Add CheckBox, hDlg, %MUTE_MODEM   , "Modem"   , 15, 70, 60, 12
                Control Add CheckBox, hDlg, %MUTE_AUX     , "Aux"     , 15, 85, 60, 12
                Control Add CheckBox, hDlg, %MUTE_MIC     , "Micro"   , 15,100, 60, 12
                Control Add CheckBox, hDlg, %MUTE_LINEIN  , "Line In" , 15,115, 60, 12
                Control Add CheckBox, hDlg, %MUTE_CDAUDIO , "CD Audio", 15,130, 60, 12
              
              '..................................................................................................
                Control Add Frame, hDlg, -1, "Volume settings for speaker channel:", 90, 10, 140, 145
              
                Control Add "msctls_trackbar32", hDlg, %VOL_MASTER, "", 135, 25, 70, 12, %TRB_STYLE
                Control Send hDlg, %VOL_MASTER , %TBM_SETTICFREQ, 10, 10
                Control Send hDlg, %VOL_MASTER , %TBM_SETRANGE  , 1, MakLng(0,100)
                Control Add Label, hDlg, %LVOL_MASTER, "0", 205, 25, 20, 12, %SS_CENTERIMAGE Or %SS_CENTER
                Control Add Label, hDlg, -1, "Master", 100, 25, 35, 12
              
                Control Add "msctls_trackbar32", hDlg, %VOL_WAVE,"", 135, 40, 70, 12, %TRB_STYLE
                Control Send hDlg, %VOL_WAVE   , %TBM_SETTICFREQ, 10, 10
                Control Send hDlg, %VOL_WAVE   , %TBM_SETRANGE  , 1, MakLng(0,100)
                Control Add Label, hDlg, %LVOL_WAVE, "0", 205, 40, 20, 12, %SS_CENTERIMAGE Or %SS_CENTER
                Control Add Label, hDlg, -1, "Wave", 100, 40, 35, 12
              
                Control Add "msctls_trackbar32", hDlg, %VOL_MIDI,"", 135, 55, 70, 12, %TRB_STYLE
                Control Send hDlg, %VOL_MIDI   , %TBM_SETTICFREQ, 10, 10
                Control Send hDlg, %VOL_MIDI   , %TBM_SETRANGE  , 1, MakLng(0,100)
                Control Add Label, hDlg, %LVOL_MIDI, "0", 205, 55, 20, 12, %SS_CENTERIMAGE Or %SS_CENTER
                Control Add Label, hDlg, -1, "Midi", 100, 55, 35, 12
              
                Control Add "msctls_trackbar32", hDlg, %VOL_MODEM,"", 135, 70, 70, 12, %TRB_STYLE
                Control Send hDlg, %VOL_MODEM   , %TBM_SETTICFREQ, 10, 10
                Control Send hDlg, %VOL_MODEM   , %TBM_SETRANGE  , 1, MakLng(0,100)
                Control Add Label, hDlg, %LVOL_MODEM, "0", 205, 70, 20, 12, %SS_CENTERIMAGE Or %SS_CENTER
                Control Add Label, hDlg, -1, "Modem", 100, 70, 35, 12
              
                Control Add "msctls_trackbar32", hDlg, %VOL_AUX,"", 135, 85, 70, 12, %TRB_STYLE
                Control Send hDlg, %VOL_AUX   , %TBM_SETTICFREQ, 10, 10
                Control Send hDlg, %VOL_AUX   , %TBM_SETRANGE  , 1, MakLng(0,100)
                Control Add Label, hDlg, %LVOL_AUX, "0", 205, 85, 20, 12, %SS_CENTERIMAGE Or %SS_CENTER
                Control Add Label, hDlg, -1, "Auxiliary", 100, 85, 35, 12
              
                Control Add "msctls_trackbar32", hDlg, %VOL_MIC,"", 135, 100, 70, 12, %TRB_STYLE
                Control Send hDlg, %VOL_MIC   , %TBM_SETTICFREQ, 10, 10
                Control Send hDlg, %VOL_MIC   , %TBM_SETRANGE  , 1, MakLng(0,100)
                Control Add Label, hDlg, %LVOL_MIC, "0", 205, 100, 20, 12, %SS_CENTERIMAGE Or %SS_CENTER
                Control Add Label, hDlg, -1, "Micro", 100, 100, 35, 12
              
                Control Add "msctls_trackbar32", hDlg, %VOL_LINEIN,"", 135, 115, 70, 12, %TRB_STYLE
                Control Send hDlg, %VOL_LINEIN   , %TBM_SETTICFREQ, 10, 10
                Control Send hDlg, %VOL_LINEIN   , %TBM_SETRANGE  , 1, MakLng(0,100)
                Control Add Label, hDlg, %LVOL_LINEIN, "0", 205, 115, 20, 12, %SS_CENTERIMAGE Or %SS_CENTER
                Control Add Label, hDlg, -1, "Line In", 100, 115, 35, 12
              
                Control Add "msctls_trackbar32", hDlg, %VOL_CDAUDIO,"", 135, 130, 70, 12, %TRB_STYLE
                Control Send hDlg, %VOL_CDAUDIO   , %TBM_SETTICFREQ, 10, 10
                Control Send hDlg, %VOL_CDAUDIO   , %TBM_SETRANGE  , 1, MakLng(0,100)
                Control Add Label, hDlg, %LVOL_CDAUDIO, "0", 205, 130, 20, 12, %SS_CENTERIMAGE Or %SS_CENTER
                Control Add Label, hDlg, -1, "CD Audio", 100, 130, 35, 12
              
              '..................................................................................................
                Control Add Frame, hDlg, -1, "Mixer (mux) selector:", 235, 10, 80, 145
              
                Control Add CheckBox, hDlg, %MIX_STMIX    , "Stereo mix", 245, 25, 60, 12
                Control Add CheckBox, hDlg, %MIX_MODEM    , "Modem"     , 245, 40, 60, 12
                Control Add CheckBox, hDlg, %MIX_AUX      , "Auxiliary" , 245, 55, 60, 12
                Control Add CheckBox, hDlg, %MIX_MIC      , "Micro    " , 245, 70, 60, 12
                Control Add CheckBox, hDlg, %MIX_LINEIN   , "Line in"   , 245, 85, 60, 12
                Control Add CheckBox, hDlg, %MIX_CDAUDIO  , "CD Audio"  , 245,100, 60, 12
              
              '..................................................................................................
                Control Add Frame, hDlg, -1, "Volume settings for recording channel:", 320, 10, 140, 145
              
                Control Add "msctls_trackbar32", hDlg, %REC_STMIX, "", 365, 25, 70, 12, %TRB_STYLE
                Control Send hDlg, %REC_STMIX , %TBM_SETTICFREQ, 10, 10
                Control Send hDlg, %REC_STMIX , %TBM_SETRANGE  , 1, MakLng(0,100)
                Control Add Label, hDlg, %LREC_STMIX, "0", 435, 25, 20, 12, %SS_CENTERIMAGE Or %SS_CENTER
                Control Add Label, hDlg, -1, "Stereo mix", 330, 25, 35, 12
              
                Control Add "msctls_trackbar32", hDlg, %REC_MODEM,"", 365, 40, 70, 12, %TRB_STYLE
                Control Send hDlg, %REC_MODEM   , %TBM_SETTICFREQ, 10, 10
                Control Send hDlg, %REC_MODEM   , %TBM_SETRANGE  , 1, MakLng(0,100)
                Control Add Label, hDlg, %LREC_MODEM, "0", 435, 40, 20, 12, %SS_CENTERIMAGE Or %SS_CENTER
                Control Add Label, hDlg, -1, "Modem", 330, 40, 35, 12
              
                Control Add "msctls_trackbar32", hDlg, %REC_AUX,"", 365, 55, 70, 12, %TRB_STYLE
                Control Send hDlg, %REC_AUX   , %TBM_SETTICFREQ, 10, 10
                Control Send hDlg, %REC_AUX   , %TBM_SETRANGE  , 1, MakLng(0,100)
                Control Add Label, hDlg, %LREC_AUX, "0", 435, 55, 20, 12, %SS_CENTERIMAGE Or %SS_CENTER
                Control Add Label, hDlg, -1, "Auxiliary", 330, 55, 35, 12
              
                Control Add "msctls_trackbar32", hDlg, %REC_MIC,"", 365, 70, 70, 12, %TRB_STYLE
                Control Send hDlg, %REC_MIC   , %TBM_SETTICFREQ, 10, 10
                Control Send hDlg, %REC_MIC   , %TBM_SETRANGE  , 1, MakLng(0,100)
                Control Add Label, hDlg, %LREC_MIC, "0", 435, 70, 20, 12, %SS_CENTERIMAGE Or %SS_CENTER
                Control Add Label, hDlg, -1, "Micro", 330, 70, 35, 12
              
                Control Add "msctls_trackbar32", hDlg, %REC_LINEIN,"", 365, 85, 70, 12, %TRB_STYLE
                Control Send hDlg, %REC_LINEIN   , %TBM_SETTICFREQ, 10, 10
                Control Send hDlg, %REC_LINEIN   , %TBM_SETRANGE  , 1, MakLng(0,100)
                Control Add Label, hDlg, %LREC_LINEIN, "0", 435, 85, 20, 12, %SS_CENTERIMAGE Or %SS_CENTER
                Control Add Label, hDlg, -1, "Line in", 330, 85, 35, 12
              
                Control Add "msctls_trackbar32", hDlg, %REC_CDAUDIO,"", 365, 100, 70, 12, %TRB_STYLE
                Control Send hDlg, %REC_CDAUDIO   , %TBM_SETTICFREQ, 10, 10
                Control Send hDlg, %REC_CDAUDIO   , %TBM_SETRANGE  , 1, MakLng(0,100)
                Control Add Label, hDlg, %LREC_CDAUDIO, "0", 435, 100, 20, 12, %SS_CENTERIMAGE Or %SS_CENTER
                Control Add Label, hDlg, -1, "CD Audio", 330, 100, 35, 12
              
              '..................................................................................................
                Control Add Frame , hDlg, -1              , "Controls"    ,  5,160,455, 55
                Control Add Button, hDlg, %CMD_SKIPBACK   , "<<"          , 15,170, 50, 15
                Control Add Button, hDlg, %CMD_RECORD     , "Record"      , 70,170, 50, 15
                Control Add Button, hDlg, %CMD_PLAY       , "Play"        ,125,170, 50, 15
                Control Add Button, hDlg, %CMD_STOP       , "Stop"        ,180,170, 50, 15
                Control Add Button, hDlg, %CMD_SKIPFORW   , ">>"          ,235,170, 50, 15
                Control Add Button, hDlg, %CMD_PAUSE      , "| |"         ,290,170, 50, 15
                Control Add Button, hDlg, %CMD_FILE       , "Play file"   ,345,170, 50, 15
                Control Add Button, hDlg, %CMD_SAVE       , "Save to file",400,170, 50, 15
              
                Control Add "msctls_progress32", hDlg, %PLAYSTATE, "", 10,195, 445, 8,%WS_CHILD Or %WS_VISIBLE, %WS_EX_STATICEDGE
                Control Send hdlg, %PLAYSTATE, %PBM_SETRANGE, 0, MakLng(&h0,100)
                Control Send hdlg, %PLAYSTATE, %PBM_SETSTEP, 1, 0
              
                Control Add "msctls_statusbar32", hDlg, %STATUSBAR, "",0,0,0,0, %WS_CHILD Or %WS_VISIBLE
                SbParts(0) = 250 : SbParts(1) = 350 : SbParts(2) = 400 : SbParts(3) = -1                                                                            'Login/out info
                Control Send hDlg, %STATUSBAR, %SB_SETPARTS,4,VarPtr(sbParts(0))
              
                Dialog Show Modal hDlg, Call CbMain
              End Function
              Regards,
              Peter

              Comment


              • #8
                The old mixer API, is obsolete in VISTA and Windows 7.

                ...
                Patrice Terrier
                www.zapsolution.com
                www.objreader.com
                Addons: GDImage.DLL 32/64-bit (Graphic library), WinLIFT.DLL 32/64-bit (Skin Engine).

                Comment

                Working...
                X