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

Basic Mixer Information

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

  • PBWin Basic Mixer Information

    I might have overdid this just a hair. Was looking to locate how to address Front & Rear speakers independently, and send different audio to them.

    Fail.

    Had fun making this though:
    Code:
    #COMPILE EXE
    #DIM ALL
    
    '------------------------------------------------------------------------------
    '   ** Includes **
    '------------------------------------------------------------------------------
    #INCLUDE "WIN32API.INC"
    '------------------------------------------------------------------------------
    
    '------------------------------------------------------------------------------
    '   ** Constants **
    '------------------------------------------------------------------------------
    %IDSB_SOMETHING     = 1002
    %IDTX_RESULTS       = 1001
    '------------------------------------------------------------------------------
    
    '------------------------------------------------------------------------------
    '   ** Function And Subroutines **
    '------------------------------------------------------------------------------
    
    SUB SetResultText(hDlg AS DWORD, zText AS ASCIIZ * 1024)
    LOCAL PX    AS DWORD
        zText = $CRLF & zText
        CONTROL SEND hDlg, %IDTX_RESULTS, %EM_SETSEL, 65000, 65000
        CONTROL SEND hDlg, %IDTX_RESULTS, %EM_REPLACESEL, %FALSE, VARPTR(zText)
    END SUB
    
    '------------------------------------------------------------------------------
    
    FUNCTION mixerErrorMessage(idError AS DWORD) AS STRING
    LOCAL eMessage  AS STRING
        SELECT CASE idError
            CASE %MMSYSERR_ALLOCATED
                eMessage = "The specified resource is already allocated by the maximum number of clients possible."
            CASE %MMSYSERR_BADDEVICEID
                eMessage = "The uMxId parameter specifies an invalid device identifier."
            CASE %MMSYSERR_INVALFLAG
                eMessage = "One or more flags are invalid."
            CASE %MMSYSERR_INVALHANDLE
                eMessage = "The uMxId parameter specifies an invalid handle."
            CASE %MMSYSERR_INVALPARAM
                eMessage = "One or more parameters are invalid."
            CASE %MMSYSERR_NODRIVER
                eMessage = "No mixer device is available for the object specified by uMxId."
            CASE %MMSYSERR_NOMEM
                eMessage = "Unable to allocate resources."
            CASE %MIXERR_INVALCONTROL
                eMessage = "The control reference is invalid."
            CASE %MIXERR_INVALLINE
                eMessage = "The audio line reference is invalid."
            CASE ELSE
                eMessage = "Unknown Error Code: "& HEX$(idError, 8)
        END SELECT
        mixerErrorMessage = eMessage
    END FUNCTION
    
    '------------------------------------------------------------------------------
    
    FUNCTION GetQueryTypeString(iQuery AS LONG) AS STRING
    LOCAL sQuery    AS STRING
    
        SELECT CASE iQuery
            CASE %MIXERLINE_COMPONENTTYPE_DST_UNDEFINED
                sQuery = "Destination Undefined"
            CASE %MIXERLINE_COMPONENTTYPE_DST_DIGITAL
                sQuery = "Destination Digital Device"
            CASE %MIXERLINE_COMPONENTTYPE_DST_LINE
                sQuery = "Destination LineOut"
            CASE %MIXERLINE_COMPONENTTYPE_DST_MONITOR
                sQuery = "Destination Monitor"
            CASE %MIXERLINE_COMPONENTTYPE_DST_SPEAKERS
                sQuery = "Destination Speakers"
            CASE %MIXERLINE_COMPONENTTYPE_DST_HEADPHONES
                sQuery = "Destination Headphones"
            CASE %MIXERLINE_COMPONENTTYPE_DST_TELEPHONE
                sQuery = "Destination Telephone"
            CASE %MIXERLINE_COMPONENTTYPE_DST_WAVEIN
                sQuery = "Destination WaveIn"
            CASE %MIXERLINE_COMPONENTTYPE_DST_VOICEIN
                sQuery = "Destination VoiceIn"
            CASE %MIXERLINE_COMPONENTTYPE_SRC_UNDEFINED
                sQuery = "Source Undefined"
            CASE %MIXERLINE_COMPONENTTYPE_SRC_DIGITAL
                sQuery = "Source DigitalIn"
            CASE %MIXERLINE_COMPONENTTYPE_SRC_LINE
                sQuery = "Source LineIn"
            CASE %MIXERLINE_COMPONENTTYPE_SRC_MICROPHONE
                sQuery = "Source Microphone"
            CASE %MIXERLINE_COMPONENTTYPE_SRC_SYNTHESIZER
                sQuery = "Source Synthesizer"
            CASE %MIXERLINE_COMPONENTTYPE_SRC_COMPACTDISC
                sQuery = "Source CD"
            CASE %MIXERLINE_COMPONENTTYPE_SRC_TELEPHONE
                sQuery = "Source Telephone"
            CASE %MIXERLINE_COMPONENTTYPE_SRC_PCSPEAKER
                sQuery = "Source PcSpeaker"
            CASE %MIXERLINE_COMPONENTTYPE_SRC_WAVEOUT
                sQuery = "Source WaveOut"
            CASE %MIXERLINE_COMPONENTTYPE_SRC_AUXILIARY
                sQuery = "Source Aux"
            CASE %MIXERLINE_COMPONENTTYPE_SRC_ANALOG
                sQuery = "Source Analog"
        END SELECT
    
        GetQueryTypeString = sQuery
    END FUNCTION
    
    
    '------------------------------------------------------------------------------
    
    FUNCTION MixerClassDetails(BYVAL mxTypeCode AS LONG) AS STRING
    LOCAL sResults      AS STRING
    LOCAL mxClass       AS DWORD
    LOCAL mxSubClass    AS DWORD
    LOCAL mxUnits       AS DWORD
    
        mxClass     = mxTypeCode AND %MIXERCONTROL_CT_CLASS_MASK
        mxSubClass  = mxTypeCode AND %MIXERCONTROL_CT_SUBCLASS_MASK
        mxUnits     = mxTypeCode AND %MIXERCONTROL_CT_UNITS_MASK
        sResults = "Custom Info "& HEX$(mxTypeCode, 8) ' default error setup
        SELECT CASE mxClass
            CASE %MIXERCONTROL_CT_CLASS_CUSTOM
                sResults = "Custom Class "& HEX$(mxTypeCode, 8)
            CASE %MIXERCONTROL_CT_CLASS_METER
                SELECT CASE mxTypeCode ' different meter types
                    CASE %MIXERCONTROL_CONTROLTYPE_BOOLEANMETER
                        sResults = "Boolean Meter"
                    CASE %MIXERCONTROL_CONTROLTYPE_SIGNEDMETER
                        sResults = "Signed Meter"
                    CASE %MIXERCONTROL_CONTROLTYPE_PEAKMETER
                        sResults = "Peak Meter"
                    CASE %MIXERCONTROL_CONTROLTYPE_UNSIGNEDMETER
                        sResults = "UnSigned Meter"
                END SELECT
            CASE %MIXERCONTROL_CT_CLASS_SWITCH
                SELECT CASE mxTypeCode
                    CASE %MIXERCONTROL_CONTROLTYPE_BOOLEAN
                        sResults = "Boolean Switch"
                    CASE %MIXERCONTROL_CONTROLTYPE_ONOFF
                        sResults = "On/Off Switch"
                    CASE %MIXERCONTROL_CONTROLTYPE_MUTE
                        sResults = "Mute Control"
                    CASE %MIXERCONTROL_CONTROLTYPE_MONO
                        sResults = "Mone / Stereo Mode"
                    CASE %MIXERCONTROL_CONTROLTYPE_LOUDNESS
                        sResults = "Loudness"
                    CASE %MIXERCONTROL_CONTROLTYPE_STEREOENH
                        sResults = "Stereo Enhancement"
                    CASE %MIXERCONTROL_CONTROLTYPE_BUTTON
                        sResults = "A Button"
                END SELECT
            CASE %MIXERCONTROL_CT_CLASS_NUMBER
                SELECT CASE mxUnits
                    CASE %MIXERCONTROL_CT_UNITS_SIGNED
                        sResults = "Number Signed"
                    CASE %MIXERCONTROL_CT_UNITS_UNSIGNED
                        sResults = "Number UnSigned"
                    CASE %MIXERCONTROL_CT_UNITS_DECIBELS
                        sResults = "Number Decibels"
                    CASE %MIXERCONTROL_CT_UNITS_PERCENT
                        sResults = "Number Percent"
                END SELECT
            CASE %MIXERCONTROL_CT_CLASS_SLIDER
                SELECT CASE mxTypeCode
                    CASE %MIXERCONTROL_CONTROLTYPE_SLIDER
                        sResults = "Plain Slider"
                    CASE %MIXERCONTROL_CONTROLTYPE_PAN
                        sResults = "Blance / Panning"
                    CASE %MIXERCONTROL_CONTROLTYPE_QSOUNDPAN
                        sResults = "Quadraphonic Balance / Panning"
                END SELECT
            CASE %MIXERCONTROL_CT_CLASS_FADER
                SELECT CASE mxTypeCode
                    CASE %MIXERCONTROL_CONTROLTYPE_FADER
                        sResults = "Simple Fader"
                    CASE %MIXERCONTROL_CONTROLTYPE_VOLUME
                        sResults = "Volume Control"
                    CASE %MIXERCONTROL_CONTROLTYPE_BASS
                        sResults = "Bass Control"
                    CASE %MIXERCONTROL_CONTROLTYPE_TREBLE
                        sResults = "Treble Control"
                    CASE %MIXERCONTROL_CONTROLTYPE_EQUALIZER
                        sResults = "Equalizer Control"
                END SELECT
            CASE %MIXERCONTROL_CT_CLASS_TIME
                SELECT CASE mxTypeCode
                    CASE %MIXERCONTROL_CONTROLTYPE_MICROTIME
                        sResults = "Time Value In MicroSeconds"
                    CASE %MIXERCONTROL_CONTROLTYPE_MILLITIME
                        sResults = "Time Value In MilliSeconds"
                END SELECT
            CASE %MIXERCONTROL_CT_CLASS_LIST
                SELECT CASE mxTypeCode
                    CASE %MIXERCONTROL_CONTROLTYPE_SINGLESELECT
                        sResults = "Single Selection List Class"
                    CASE %MIXERCONTROL_CONTROLTYPE_MUX
                        sResults = "Multiplexer Control"
                    CASE %MIXERCONTROL_CONTROLTYPE_MULTIPLESELECT
                        sResults = "Multiple Selection List Class"
                    CASE %MIXERCONTROL_CONTROLTYPE_MIXER
                        sResults = "Mixer Control"
                END SELECT
        END SELECT
    
        MixerClassDetails = sResults
    END FUNCTION
    
    '------------------------------------------------------------------------------
    
    FUNCTION MixerControlType(BYVAL mxTypeCode AS LONG) AS STRING
    DIM dType AS STRING
    
      SELECT CASE mxTypeCode
        CASE %MIXERCONTROL_CONTROLTYPE_BASS
            dType = "BASS"
        CASE %MIXERCONTROL_CONTROLTYPE_CUSTOM
            dType = "CUSTOM"
        CASE %MIXERCONTROL_CONTROLTYPE_DECIBELS
            dType = "DECIBELS"
        CASE %MIXERCONTROL_CONTROLTYPE_EQUALIZER
            dType = "EQUALIZER"
        CASE %MIXERCONTROL_CONTROLTYPE_FADER
            dType = "FADER"
        CASE %MIXERCONTROL_CONTROLTYPE_LOUDNESS
            dType = "LOUDNESS"
        CASE %MIXERCONTROL_CONTROLTYPE_MICROTIME
            dType = "MICROTIME"
        CASE %MIXERCONTROL_CONTROLTYPE_MILLITIME
            dType = "MILLITIME"
        CASE %MIXERCONTROL_CONTROLTYPE_MIXER
            dType = "MIXER"
        CASE %MIXERCONTROL_CONTROLTYPE_MONO
            dType = "MONO"
        CASE %MIXERCONTROL_CONTROLTYPE_MULTIPLESELECT
            dType = "MULTIPLESELECT"
        CASE %MIXERCONTROL_CONTROLTYPE_MUTE
            dType = "MUTE"
        CASE %MIXERCONTROL_CONTROLTYPE_MUX
            dType = "MUX"
        CASE %MIXERCONTROL_CONTROLTYPE_ONOFF
            dType = "ONOFF"
        CASE %MIXERCONTROL_CONTROLTYPE_PAN
            dType = "PAN"
        CASE %MIXERCONTROL_CONTROLTYPE_PEAKMETER
            dType = "PEAKMETER"
        CASE %MIXERCONTROL_CONTROLTYPE_PERCENT
            dType = "PERCENT"
        CASE %MIXERCONTROL_CONTROLTYPE_QSOUNDPAN
            dType = "QSOUNDPAN"
        CASE %MIXERCONTROL_CONTROLTYPE_SINGLESELECT
            dType = "SINGLESELECT"
        CASE %MIXERCONTROL_CONTROLTYPE_STEREOENH
            dType = "STEREOENH"
        CASE %MIXERCONTROL_CONTROLTYPE_TREBLE
            dType = "TREBLE"
        CASE %MIXERCONTROL_CONTROLTYPE_VOLUME
            dType = "VOLUME"
        CASE ELSE
            dType = "UNKNOWN(" & HEX$(mxTypeCode) & "H)"
      END SELECT
      MixerControlType = dType
    END FUNCTION
    
    '------------------------------------------------------------------------------
    
    FUNCTION GetSwitchStatus(mxControl AS MIXERCONTROL, Status1 AS LONG, Status2 AS LONG) AS STRING
    LOCAL sResults, Mode1, Mode2    AS STRING
    
        SELECT CASE mxControl.dwControlType
            CASE %MIXERCONTROL_CONTROLTYPE_BOOLEAN
                Mode1 = IIF$(Status1 = 0, "FALSE", "TRUE")
                Mode2 = IIF$(Status2 = 0, "FALSE", "TRUE")
            CASE %MIXERCONTROL_CONTROLTYPE_ONOFF
                Mode1 = IIF$(Status1 = 0, "OFF", "ON")
                Mode2 = IIF$(Status2 = 0, "OFF", "ON")
            CASE %MIXERCONTROL_CONTROLTYPE_MUTE
                Mode1 = IIF$(Status1 = 0, "ACTIVE", "MUTED")
                Mode2 = IIF$(Status2 = 0, "ACTIVE", "MUTED")
            CASE %MIXERCONTROL_CONTROLTYPE_MONO
                Mode1 = IIF$(Status1 = 0, "STEREO", "MONO")
                Mode2 = IIF$(Status2 = 0, "STEREO", "MONO")
            CASE %MIXERCONTROL_CONTROLTYPE_LOUDNESS
                Mode1 = IIF$(Status1 = 0, "Normal Audio Level", "Loudness Enhancement")
                Mode2 = IIF$(Status2 = 0, "Normal Audio Level", "Loudness Enhancement")
            CASE %MIXERCONTROL_CONTROLTYPE_STEREOENH
                Mode1 = IIF$(Status1 = 0, "Normal Stereo", "Stereo Enhancement")
                Mode2 = IIF$(Status2 = 0, "Normal Stereo", "Stereo Enhancement")
            CASE %MIXERCONTROL_CONTROLTYPE_BUTTON
                sResults = "A Button"
                Mode1 = IIF$(Status1 = 0, "Button 1 Is Off", "Button 1 Is On")
                Mode1 = IIF$(Status2 = 0, "Button 2 Is Off", "Button 2 Is On")
        END SELECT
        IF (mxControl.fdwControl = %MIXERCONTROL_CONTROLF_UNIFORM) THEN
            ' return only Status1
            sResults = Mode1
        ELSE
            ' return both
            sResults = Mode1 &" / "& Mode2
        END IF
        GetSwitchStatus = sResults
    END FUNCTION
    
    '------------------------------------------------------------------------------
    
    FUNCTION MixerControlStatus(fdwControl AS DWORD) AS STRING
    LOCAL mxStatus  AS STRING
        SELECT CASE fdwControl
            CASE 0
                mxStatus = ""
            CASE %MIXERCONTROL_CONTROLF_DISABLED
                mxStatus = "Control Is Disabled"
            CASE %MIXERCONTROL_CONTROLF_MULTIPLE
                mxStatus = "Control Is A Multiple Control"
            CASE %MIXERCONTROL_CONTROLF_UNIFORM
                mxStatus = "Control Is Treated Uniformly"
            CASE ELSE
                mxStatus = "Control Status Code Is &h"& HEX$(fdwControl, 8)
        END SELECT
        MixerControlStatus = mxStatus
    END FUNCTION
    
    '------------------------------------------------------------------------------
    
    FUNCTION GetCurrentValue(hMixer AS DWORD, mxControl AS MIXERCONTROL, BYREF Channel1 AS LONG, BYREF Channel2 AS LONG) AS LONG
    LOCAL mxControlDetails  AS MIXERCONTROLDETAILS
    LOCAL dwReturn          AS DWORD
    LOCAL dwResults()       AS LONG
    
        DIM dwResults(1)
        mxControlDetails.dwControlID = mxControl.dwControlID
        mxControlDetails.cbStruct = SIZEOF(mxControlDetails)
        mxControlDetails.cbDetails = 4
        mxControlDetails.cChannels = IIF(mxControl.fdwControl = %MIXERCONTROL_CONTROLF_UNIFORM, 1, 2)
        mxControlDetails.paDetails = VARPTR(dwResults(0))
    
        dwReturn = mixerGetControlDetails(hMixer, mxControlDetails, %MIXER_GETCONTROLDETAILSF_VALUE)
        IF (dwReturn = 0) THEN
            Channel1 = dwResults(0)
            Channel2 = dwResults(1)
            GetCurrentValue = %TRUE
        ELSE
            #DEBUG PRINT mixerErrorMessage(dwReturn)
            GetCurrentValue = %FALSE
        END IF
    
    END FUNCTION
    
    '------------------------------------------------------------------------------
    
    SUB MixerMultipleLabels(hDlg AS DWORD, hMixer AS DWORD, dwControlID AS DWORD, cMultipleItems AS DWORD)
    LOCAL mxControlDetails  AS MIXERCONTROLDETAILS
    LOCAL dwReturn, ixItem  AS LONG
    LOCAL mxListText()      AS MIXERCONTROLDETAILS_LISTTEXT
    
        mxControlDetails.dwControlID    = dwControlID
        mxControlDetails.cbStruct       = SIZEOF(mxControlDetails)
        mxControlDetails.cChannels      = 1
        DIM mxListText(cMultipleItems)
        mxControlDetails.cbDetails      = SIZEOF(mxListText(0))
        mxControlDetails.Item           = cMultipleItems
        mxControlDetails.paDetails      = VARPTR(mxListText(0))
    
        dwReturn = mixerGetControlDetails(hMixer, mxControlDetails, %MIXER_GETCONTROLDETAILSF_LISTTEXT)
        IF (dwReturn = 0) THEN
            FOR ixItem = 0 TO cMultipleItems - 1
                SetResultText hDlg, "          Label "& FORMAT$(ixItem) &" "& mxListText(ixItem).szName
            NEXT ixItem
        ELSE
            SetResultText hDlg, "Error Multiple Labels: "& mixerErrorMessage(dwReturn)
        END IF
    END SUB
    
    '------------------------------------------------------------------------------
    
    SUB QueryMixerInfo(hDlg AS DWORD, hMixer AS DWORD, iQuery AS LONG)
    LOCAL mxLine                AS MIXERLINE
    LOCAL mxLineControls        AS MIXERLINECONTROLS
    LOCAL mxControl()           AS MIXERCONTROL
    LOCAL dwReturn              AS DWORD
    LOCAL nControls, nChannels  AS LONG
    LOCAL ixControl, dwValue    AS LONG
    LOCAL lName, sName          AS STRING
    LOCAL Channel1, Channel2    AS LONG
    
        mxLine.cbStruct         = SIZEOF(mxLine)
        mxLine.dwComponentType  = iQuery
    
        dwReturn = mixerGetLineInfo(hMixer, mxLine, %MIXER_GETLINEINFOF_COMPONENTTYPE)
        IF (dwReturn = 0) THEN
            SetResultText hDlg, "  "& GetQueryTypeString(iQuery)
            mxLineControls.cbStruct = SIZEOF(mxLineControls)
            mxLineControls.dwLineID = mxLine.dwLineID
            nControls = mxLine.cControls
            nChannels = mxLine.cChannels
            SetResultText hDlg, "    Channels = "& FORMAT$(nChannels) &", Controls = "& FORMAT$(nControls)
            mxLineControls.cControls = nControls
            DIM mxControl(nControls)
            mxLineControls.cbmxctrl = SIZEOF(mxControl(0))
            mxLineControls.pamxctrl = VARPTR(mxControl(0))
    
            dwReturn = mixerGetLineControls(hMixer, mxLineControls, %MIXER_GETLINECONTROLSF_ALL)
            IF (dwReturn = 0) THEN
                FOR ixControl = 0 TO nControls - 1
                    SetResultText hDlg, "      Control ID = "& FORMAT$(mxControl(ixControl).dwControlID) _
                        &", "& MixerControlType(mxControl(ixControl).dwControlType) _
                        &" "& MixerControlStatus(mxControl(ixControl).fdwControl)
                    SetResultText hDlg, "        Class: "& MixerClassDetails(mxControl(ixControl).dwControlType)
                    lName = mxControl(ixControl).szName
                    sName = mxControl(ixControl).szShortName
                    IF ((LEN(sName) > 0) OR (LEN(lName) > 0)) THEN
                        SetResultText hDlg, "        Named: "& lName _
                            &" "& FORMAT$(mxControl(ixControl).Bounds.lMinMax.lMinimum) _
                            &" - "& FORMAT$(mxControl(ixControl).Bounds.lMinMax.lMaximum)
                        IF (sName <> lName) THEN
                            SetResultText hDlg, "          Short Alias: "& sName
                        END IF
                    ELSE
                        SetResultText hDlg, "        MinMax: "& FORMAT$(mxControl(ixControl).Bounds.lMinMax.lMinimum) _
                            &" - "& FORMAT$(mxControl(ixControl).Bounds.lMinMax.lMaximum)
                    END IF
                    dwValue = GetCurrentValue(hMixer, mxControl(ixControl), BYREF Channel1, BYREF Channel2)
                    IF (ISTRUE dwValue) THEN ' successfully fetched current setting of control
                        IF ((mxControl(ixControl).dwControlType AND %MIXERCONTROL_CT_CLASS_MASK) = %MIXERCONTROL_CT_CLASS_SWITCH) THEN
                            SetResultText hDlg, "        "& GetSwitchStatus(mxControl(ixControl), Channel1, Channel2)
                        ELSE ' Control is 'stereo'
                            IF (mxControl(ixControl).fdwControl = %MIXERCONTROL_CONTROLF_UNIFORM) THEN
                                SetResultText hDlg, "        Channel Value "& FORMAT$(Channel1)
                            ELSE
                                SetResultText hDlg, "        Channel 1 Value "& FORMAT$(Channel1)
                                SetResultText hDlg, "        Channel 2 Value "& FORMAT$(Channel2)
                            END IF
                        END IF
                    END IF
                    IF (mxControl(ixControl).cMultipleItems <> 0) THEN
                        MixerMultipleLabels hDlg, hMixer, mxControl(ixControl).dwControlID, mxControl(ixControl).cMultipleItems
                    END IF
                NEXT ixControl
            ELSE
                SetResultText hDlg, "Error Get Line Info: "& mixerErrorMessage(dwReturn)
            END IF
        ELSE
            ' oh hey, we don't do this
            ' if we get an error, it's because the hardware doesn't support the query
            ' SetResultText hDlg, "Error Get Line Info: "& mixerErrorMessage(dwReturn)
        END IF
    
    END SUB
    
    '------------------------------------------------------------------------------
    
    FUNCTION GetMixername(mixerID AS LONG) AS STRING
    LOCAL MixerInfo     AS MIXERCAPS
    LOCAL strResults    AS STRING
      mixerGetDevCaps mixerID, MixerInfo, LEN(MixerInfo)
      strResults = MixerInfo.szPname
      GetMixername = strResults
    END FUNCTION
    
    '------------------------------------------------------------------------------
    
    SUB LoadMixerInfo(hDlg AS DWORD)
    LOCAL mCount, mIndex        AS LONG
    LOCAL DstIndex, SrcIndex    AS LONG
    LOCAL hMixer, dwReturn      AS DWORD
    LOCAL zText                 AS ASCIIZ * 256
    
        mCount = mixerGetNumDevs()
        zText = "Number of Mixer Devices Found: "& FORMAT$(mCount)
        CONTROL SET TEXT hDlg, %IDTX_RESULTS, zText
        FOR mIndex = 0 TO mCount - 1
            dwReturn = mixerOpen(hMixer, mIndex, 0, 0, 0)
            IF (dwReturn <> 0) THEN
                SetResultText hDlg, "Error Opening Mixer: "& FORMAT$(mIndex) &" Error Code: "& mixerErrorMessage(dwReturn)
                EXIT SUB
            END IF
    
            SetResultText hDlg, GetMixerName(mIndex) &" Destination ID: "& FORMAT$(mIndex + 1) &" of "& FORMAT$(mCount)
            FOR DstIndex = %MIXERLINE_COMPONENTTYPE_DST_FIRST TO %MIXERLINE_COMPONENTTYPE_DST_LAST
                QueryMixerInfo hDlg, hMixer, DstIndex
            NEXT DstIndex
    
            SetResultText hDlg, GetMixerName(mIndex) &" Source ID: "& FORMAT$(mIndex + 1) &" of "& FORMAT$(mCount)
            FOR SrcIndex = %MIXERLINE_COMPONENTTYPE_SRC_FIRST TO %MIXERLINE_COMPONENTTYPE_SRC_LAST
                QueryMixerInfo hDlg, hMixer, SrcIndex
            NEXT SrcIndex
    
            mixerClose hMixer
        NEXT mIndex
        SetResultText hDlg, "Finished"
    END SUB
    
    
    '------------------------------------------------------------------------------
    
    '------------------------------------------------------------------------------
    '   ** Main Application Entry Point **
    '------------------------------------------------------------------------------
    FUNCTION PBMAIN()
        ShowMixerControls %HWND_DESKTOP
    END FUNCTION
    '------------------------------------------------------------------------------
    
    '------------------------------------------------------------------------------
    '   ** CallBacks **
    '------------------------------------------------------------------------------
    CALLBACK FUNCTION ShowMixerControlsProc()
    
        SELECT CASE AS LONG CB.MSG
            CASE %WM_INITDIALOG
                LoadMixerInfo CB.HNDL
                CONTROL SET FOCUS CB.HNDL, %IDSB_SOMETHING
                ' Initialization handler
    
            CASE %WM_SIZE
            LOCAL DX,DY, SX, SY     AS LONG
                CONTROL SEND CB.HNDL, %IDSB_SOMETHING, CB.MSG, CB.WPARAM, CB.LPARAM
                DIALOG GET CLIENT CB.HNDL TO DX, DY
                CONTROL GET SIZE CB.HNDL, %IDSB_SOMETHING TO SX, SY
                DY = DY - SY
                CONTROL SET LOC CB.HNDL, %IDTX_RESULTS, 0, 0
                CONTROL SET SIZE CB.HNDL, %IDTX_RESULTS, DX, DY
    
        END SELECT
    
    END FUNCTION
    '------------------------------------------------------------------------------
    
    '------------------------------------------------------------------------------
    '   ** Dialogs **
    '------------------------------------------------------------------------------
    FUNCTION ShowMixerControls(BYVAL hParent AS DWORD) AS LONG
        LOCAL lRslt AS LONG
        LOCAL hDlg  AS DWORD
    
        DIALOG NEW PIXELS, hParent, "Mixer Controls", , , 376, 325, _
            %WS_POPUP OR %WS_BORDER OR %WS_THICKFRAME _
            OR %WS_CAPTION OR %WS_SYSMENU _
            OR %WS_MINIMIZEBOX OR %WS_MAXIMIZEBOX OR %WS_CLIPSIBLINGS _
            OR %WS_CLIPCHILDREN OR %WS_VISIBLE OR %DS_MODALFRAME _
            OR %DS_3DLOOK OR %DS_NOFAILCREATE OR %DS_SETFONT, _
            %WS_EX_CONTROLPARENT OR %WS_EX_LEFT _
            OR %WS_EX_LTRREADING OR %WS_EX_RIGHTSCROLLBAR, _
            TO hDlg
        CONTROL ADD TEXTBOX, hDlg, %IDTX_RESULTS, "", 60, 24, 195, 155, _
            %WS_CHILD OR %WS_VISIBLE OR %WS_TABSTOP OR %ES_LEFT _
            OR %ES_MULTILINE OR %ES_AUTOHSCROLL OR %ES_READONLY _
            OR %WS_HSCROLL OR %WS_VSCROLL, _
            %WS_EX_CLIENTEDGE OR %WS_EX_LEFT OR _
            %WS_EX_LTRREADING OR %WS_EX_RIGHTSCROLLBAR
        CONTROL ADD STATUSBAR, hDlg, %IDSB_SOMETHING, "Something To Grab", _
            0, 306, 376, 19, _
            %WS_CHILD OR %WS_VISIBLE, _
            %WS_EX_LEFT OR %WS_EX_LTRREADING OR %WS_EX_RIGHTSCROLLBAR
    
        DIALOG SHOW MODAL hDlg, CALL ShowMixerControlsProc TO lRslt
    
        ShowMixerControls = lRslt
    END FUNCTION
    '------------------------------------------------------------------------------
    All code is presented above, ZIP contains compiled program for those too lazy to copy, paste, and compile.
    Attached Files
    Furcadia, an interesting online MMORPG in which you can create and program your own content.

  • #2

    Code:
    #COMPILE EXE
    #DIM ALL
    
    'NOTE: Modified by Jim Fritts on 2018-02-24
    'See
        '//////// removed this /////////
        'mxControlDetails.Item           = cMultipleItems
        '///////////////////////////////
    
    'now functions properly with Jose' includes
    
    '------------------------------------------------------------------------------
    '   ** Includes **
    '------------------------------------------------------------------------------
    #INCLUDE "WIN32API.INC"
    '------------------------------------------------------------------------------
    
    '------------------------------------------------------------------------------
    '   ** Constants **
    '------------------------------------------------------------------------------
    %IDSB_SOMETHING     = 1002
    %IDTX_RESULTS       = 1001
    '------------------------------------------------------------------------------
    
    '------------------------------------------------------------------------------
    '   ** Function And Subroutines **
    '------------------------------------------------------------------------------
    
    SUB SetResultText(hDlg AS DWORD, zText AS ASCIIZ * 1024)
    LOCAL PX    AS DWORD
        zText = $CRLF & zText
        CONTROL SEND hDlg, %IDTX_RESULTS, %EM_SETSEL, 65000, 65000
        CONTROL SEND hDlg, %IDTX_RESULTS, %EM_REPLACESEL, %FALSE, VARPTR(zText)
    END SUB
    
    '------------------------------------------------------------------------------
    
    FUNCTION mixerErrorMessage(idError AS DWORD) AS STRING
    LOCAL eMessage  AS STRING
        SELECT CASE idError
            CASE %MMSYSERR_ALLOCATED
                eMessage = "The specified resource is already allocated by the maximum number of clients possible."
            CASE %MMSYSERR_BADDEVICEID
                eMessage = "The uMxId parameter specifies an invalid device identifier."
            CASE %MMSYSERR_INVALFLAG
                eMessage = "One or more flags are invalid."
            CASE %MMSYSERR_INVALHANDLE
                eMessage = "The uMxId parameter specifies an invalid handle."
            CASE %MMSYSERR_INVALPARAM
                eMessage = "One or more parameters are invalid."
            CASE %MMSYSERR_NODRIVER
                eMessage = "No mixer device is available for the object specified by uMxId."
            CASE %MMSYSERR_NOMEM
                eMessage = "Unable to allocate resources."
            CASE %MIXERR_INVALCONTROL
                eMessage = "The control reference is invalid."
            CASE %MIXERR_INVALLINE
                eMessage = "The audio line reference is invalid."
            CASE ELSE
                eMessage = "Unknown Error Code: "& HEX$(idError, 8)
        END SELECT
        mixerErrorMessage = eMessage
    END FUNCTION
    
    '------------------------------------------------------------------------------
    
    FUNCTION GetQueryTypeString(iQuery AS LONG) AS STRING
    LOCAL sQuery    AS STRING
    
        SELECT CASE iQuery
            CASE %MIXERLINE_COMPONENTTYPE_DST_UNDEFINED
                sQuery = "Destination Undefined"
            CASE %MIXERLINE_COMPONENTTYPE_DST_DIGITAL
                sQuery = "Destination Digital Device"
            CASE %MIXERLINE_COMPONENTTYPE_DST_LINE
                sQuery = "Destination LineOut"
            CASE %MIXERLINE_COMPONENTTYPE_DST_MONITOR
                sQuery = "Destination Monitor"
            CASE %MIXERLINE_COMPONENTTYPE_DST_SPEAKERS
                sQuery = "Destination Speakers"
            CASE %MIXERLINE_COMPONENTTYPE_DST_HEADPHONES
                sQuery = "Destination Headphones"
            CASE %MIXERLINE_COMPONENTTYPE_DST_TELEPHONE
                sQuery = "Destination Telephone"
            CASE %MIXERLINE_COMPONENTTYPE_DST_WAVEIN
                sQuery = "Destination WaveIn"
            CASE %MIXERLINE_COMPONENTTYPE_DST_VOICEIN
                sQuery = "Destination VoiceIn"
            CASE %MIXERLINE_COMPONENTTYPE_SRC_UNDEFINED
                sQuery = "Source Undefined"
            CASE %MIXERLINE_COMPONENTTYPE_SRC_DIGITAL
                sQuery = "Source DigitalIn"
            CASE %MIXERLINE_COMPONENTTYPE_SRC_LINE
                sQuery = "Source LineIn"
            CASE %MIXERLINE_COMPONENTTYPE_SRC_MICROPHONE
                sQuery = "Source Microphone"
            CASE %MIXERLINE_COMPONENTTYPE_SRC_SYNTHESIZER
                sQuery = "Source Synthesizer"
            CASE %MIXERLINE_COMPONENTTYPE_SRC_COMPACTDISC
                sQuery = "Source CD"
            CASE %MIXERLINE_COMPONENTTYPE_SRC_TELEPHONE
                sQuery = "Source Telephone"
            CASE %MIXERLINE_COMPONENTTYPE_SRC_PCSPEAKER
                sQuery = "Source PcSpeaker"
            CASE %MIXERLINE_COMPONENTTYPE_SRC_WAVEOUT
                sQuery = "Source WaveOut"
            CASE %MIXERLINE_COMPONENTTYPE_SRC_AUXILIARY
                sQuery = "Source Aux"
            CASE %MIXERLINE_COMPONENTTYPE_SRC_ANALOG
                sQuery = "Source Analog"
        END SELECT
    
        GetQueryTypeString = sQuery
    END FUNCTION
    
    
    '------------------------------------------------------------------------------
    
    FUNCTION MixerClassDetails(BYVAL mxTypeCode AS LONG) AS STRING
    LOCAL sResults      AS STRING
    LOCAL mxClass       AS DWORD
    LOCAL mxSubClass    AS DWORD
    LOCAL mxUnits       AS DWORD
    
        mxClass     = mxTypeCode AND %MIXERCONTROL_CT_CLASS_MASK
        mxSubClass  = mxTypeCode AND %MIXERCONTROL_CT_SUBCLASS_MASK
        mxUnits     = mxTypeCode AND %MIXERCONTROL_CT_UNITS_MASK
        sResults = "Custom Info "& HEX$(mxTypeCode, 8) ' default error setup
        SELECT CASE mxClass
            CASE %MIXERCONTROL_CT_CLASS_CUSTOM
                sResults = "Custom Class "& HEX$(mxTypeCode, 8)
            CASE %MIXERCONTROL_CT_CLASS_METER
                SELECT CASE mxTypeCode ' different meter types
                    CASE %MIXERCONTROL_CONTROLTYPE_BOOLEANMETER
                        sResults = "Boolean Meter"
                    CASE %MIXERCONTROL_CONTROLTYPE_SIGNEDMETER
                        sResults = "Signed Meter"
                    CASE %MIXERCONTROL_CONTROLTYPE_PEAKMETER
                        sResults = "Peak Meter"
                    CASE %MIXERCONTROL_CONTROLTYPE_UNSIGNEDMETER
                        sResults = "UnSigned Meter"
                END SELECT
            CASE %MIXERCONTROL_CT_CLASS_SWITCH
                SELECT CASE mxTypeCode
                    CASE %MIXERCONTROL_CONTROLTYPE_BOOLEAN
                        sResults = "Boolean Switch"
                    CASE %MIXERCONTROL_CONTROLTYPE_ONOFF
                        sResults = "On/Off Switch"
                    CASE %MIXERCONTROL_CONTROLTYPE_MUTE
                        sResults = "Mute Control"
                    CASE %MIXERCONTROL_CONTROLTYPE_MONO
                        sResults = "Mone / Stereo Mode"
                    CASE %MIXERCONTROL_CONTROLTYPE_LOUDNESS
                        sResults = "Loudness"
                    CASE %MIXERCONTROL_CONTROLTYPE_STEREOENH
                        sResults = "Stereo Enhancement"
                    CASE %MIXERCONTROL_CONTROLTYPE_BUTTON
                        sResults = "A Button"
                END SELECT
            CASE %MIXERCONTROL_CT_CLASS_NUMBER
                SELECT CASE mxUnits
                    CASE %MIXERCONTROL_CT_UNITS_SIGNED
                        sResults = "Number Signed"
                    CASE %MIXERCONTROL_CT_UNITS_UNSIGNED
                        sResults = "Number UnSigned"
                    CASE %MIXERCONTROL_CT_UNITS_DECIBELS
                        sResults = "Number Decibels"
                    CASE %MIXERCONTROL_CT_UNITS_PERCENT
                        sResults = "Number Percent"
                END SELECT
            CASE %MIXERCONTROL_CT_CLASS_SLIDER
                SELECT CASE mxTypeCode
                    CASE %MIXERCONTROL_CONTROLTYPE_SLIDER
                        sResults = "Plain Slider"
                    CASE %MIXERCONTROL_CONTROLTYPE_PAN
                        sResults = "Blance / Panning"
                    CASE %MIXERCONTROL_CONTROLTYPE_QSOUNDPAN
                        sResults = "Quadraphonic Balance / Panning"
                END SELECT
            CASE %MIXERCONTROL_CT_CLASS_FADER
                SELECT CASE mxTypeCode
                    CASE %MIXERCONTROL_CONTROLTYPE_FADER
                        sResults = "Simple Fader"
                    CASE %MIXERCONTROL_CONTROLTYPE_VOLUME
                        sResults = "Volume Control"
                    CASE %MIXERCONTROL_CONTROLTYPE_BASS
                        sResults = "Bass Control"
                    CASE %MIXERCONTROL_CONTROLTYPE_TREBLE
                        sResults = "Treble Control"
                    CASE %MIXERCONTROL_CONTROLTYPE_EQUALIZER
                        sResults = "Equalizer Control"
                END SELECT
            CASE %MIXERCONTROL_CT_CLASS_TIME
                SELECT CASE mxTypeCode
                    CASE %MIXERCONTROL_CONTROLTYPE_MICROTIME
                        sResults = "Time Value In MicroSeconds"
                    CASE %MIXERCONTROL_CONTROLTYPE_MILLITIME
                        sResults = "Time Value In MilliSeconds"
                END SELECT
            CASE %MIXERCONTROL_CT_CLASS_LIST
                SELECT CASE mxTypeCode
                    CASE %MIXERCONTROL_CONTROLTYPE_SINGLESELECT
                        sResults = "Single Selection List Class"
                    CASE %MIXERCONTROL_CONTROLTYPE_MUX
                        sResults = "Multiplexer Control"
                    CASE %MIXERCONTROL_CONTROLTYPE_MULTIPLESELECT
                        sResults = "Multiple Selection List Class"
                    CASE %MIXERCONTROL_CONTROLTYPE_MIXER
                        sResults = "Mixer Control"
                END SELECT
        END SELECT
    
        MixerClassDetails = sResults
    END FUNCTION
    
    '------------------------------------------------------------------------------
    
    FUNCTION MixerControlType(BYVAL mxTypeCode AS LONG) AS STRING
    DIM dType AS STRING
    
      SELECT CASE mxTypeCode
        CASE %MIXERCONTROL_CONTROLTYPE_BASS
            dType = "BASS"
        CASE %MIXERCONTROL_CONTROLTYPE_CUSTOM
            dType = "CUSTOM"
        CASE %MIXERCONTROL_CONTROLTYPE_DECIBELS
            dType = "DECIBELS"
        CASE %MIXERCONTROL_CONTROLTYPE_EQUALIZER
            dType = "EQUALIZER"
        CASE %MIXERCONTROL_CONTROLTYPE_FADER
            dType = "FADER"
        CASE %MIXERCONTROL_CONTROLTYPE_LOUDNESS
            dType = "LOUDNESS"
        CASE %MIXERCONTROL_CONTROLTYPE_MICROTIME
            dType = "MICROTIME"
        CASE %MIXERCONTROL_CONTROLTYPE_MILLITIME
            dType = "MILLITIME"
        CASE %MIXERCONTROL_CONTROLTYPE_MIXER
            dType = "MIXER"
        CASE %MIXERCONTROL_CONTROLTYPE_MONO
            dType = "MONO"
        CASE %MIXERCONTROL_CONTROLTYPE_MULTIPLESELECT
            dType = "MULTIPLESELECT"
        CASE %MIXERCONTROL_CONTROLTYPE_MUTE
            dType = "MUTE"
        CASE %MIXERCONTROL_CONTROLTYPE_MUX
            dType = "MUX"
        CASE %MIXERCONTROL_CONTROLTYPE_ONOFF
            dType = "ONOFF"
        CASE %MIXERCONTROL_CONTROLTYPE_PAN
            dType = "PAN"
        CASE %MIXERCONTROL_CONTROLTYPE_PEAKMETER
            dType = "PEAKMETER"
        CASE %MIXERCONTROL_CONTROLTYPE_PERCENT
            dType = "PERCENT"
        CASE %MIXERCONTROL_CONTROLTYPE_QSOUNDPAN
            dType = "QSOUNDPAN"
        CASE %MIXERCONTROL_CONTROLTYPE_SINGLESELECT
            dType = "SINGLESELECT"
        CASE %MIXERCONTROL_CONTROLTYPE_STEREOENH
            dType = "STEREOENH"
        CASE %MIXERCONTROL_CONTROLTYPE_TREBLE
            dType = "TREBLE"
        CASE %MIXERCONTROL_CONTROLTYPE_VOLUME
            dType = "VOLUME"
        CASE ELSE
            dType = "UNKNOWN(" & HEX$(mxTypeCode) & "H)"
      END SELECT
      MixerControlType = dType
    END FUNCTION
    
    '------------------------------------------------------------------------------
    
    FUNCTION GetSwitchStatus(mxControl AS MIXERCONTROL, Status1 AS LONG, Status2 AS LONG) AS STRING
    LOCAL sResults, Mode1, Mode2    AS STRING
    
        SELECT CASE mxControl.dwControlType
            CASE %MIXERCONTROL_CONTROLTYPE_BOOLEAN
                Mode1 = IIF$(Status1 = 0, "FALSE", "TRUE")
                Mode2 = IIF$(Status2 = 0, "FALSE", "TRUE")
            CASE %MIXERCONTROL_CONTROLTYPE_ONOFF
                Mode1 = IIF$(Status1 = 0, "OFF", "ON")
                Mode2 = IIF$(Status2 = 0, "OFF", "ON")
            CASE %MIXERCONTROL_CONTROLTYPE_MUTE
                Mode1 = IIF$(Status1 = 0, "ACTIVE", "MUTED")
                Mode2 = IIF$(Status2 = 0, "ACTIVE", "MUTED")
            CASE %MIXERCONTROL_CONTROLTYPE_MONO
                Mode1 = IIF$(Status1 = 0, "STEREO", "MONO")
                Mode2 = IIF$(Status2 = 0, "STEREO", "MONO")
            CASE %MIXERCONTROL_CONTROLTYPE_LOUDNESS
                Mode1 = IIF$(Status1 = 0, "Normal Audio Level", "Loudness Enhancement")
                Mode2 = IIF$(Status2 = 0, "Normal Audio Level", "Loudness Enhancement")
            CASE %MIXERCONTROL_CONTROLTYPE_STEREOENH
                Mode1 = IIF$(Status1 = 0, "Normal Stereo", "Stereo Enhancement")
                Mode2 = IIF$(Status2 = 0, "Normal Stereo", "Stereo Enhancement")
            CASE %MIXERCONTROL_CONTROLTYPE_BUTTON
                sResults = "A Button"
                Mode1 = IIF$(Status1 = 0, "Button 1 Is Off", "Button 1 Is On")
                Mode1 = IIF$(Status2 = 0, "Button 2 Is Off", "Button 2 Is On")
        END SELECT
        IF (mxControl.fdwControl = %MIXERCONTROL_CONTROLF_UNIFORM) THEN
            ' return only Status1
            sResults = Mode1
        ELSE
            ' return both
            sResults = Mode1 &" / "& Mode2
        END IF
        GetSwitchStatus = sResults
    END FUNCTION
    
    '------------------------------------------------------------------------------
    
    FUNCTION MixerControlStatus(fdwControl AS DWORD) AS STRING
    LOCAL mxStatus  AS STRING
        SELECT CASE fdwControl
            CASE 0
                mxStatus = ""
            CASE %MIXERCONTROL_CONTROLF_DISABLED
                mxStatus = "Control Is Disabled"
            CASE %MIXERCONTROL_CONTROLF_MULTIPLE
                mxStatus = "Control Is A Multiple Control"
            CASE %MIXERCONTROL_CONTROLF_UNIFORM
                mxStatus = "Control Is Treated Uniformly"
            CASE ELSE
                mxStatus = "Control Status Code Is &h"& HEX$(fdwControl, 8)
        END SELECT
        MixerControlStatus = mxStatus
    END FUNCTION
    
    '------------------------------------------------------------------------------
    
    FUNCTION GetCurrentValue(hMixer AS DWORD, mxControl AS MIXERCONTROL, BYREF Channel1 AS LONG, BYREF Channel2 AS LONG) AS LONG
    LOCAL mxControlDetails  AS MIXERCONTROLDETAILS
    LOCAL dwReturn          AS DWORD
    LOCAL dwResults()       AS LONG
    
        DIM dwResults(1)
        mxControlDetails.dwControlID = mxControl.dwControlID
        mxControlDetails.cbStruct = SIZEOF(mxControlDetails)
        mxControlDetails.cbDetails = 4
        mxControlDetails.cChannels = IIF(mxControl.fdwControl = %MIXERCONTROL_CONTROLF_UNIFORM, 1, 2)
        mxControlDetails.paDetails = VARPTR(dwResults(0))
    
        dwReturn = mixerGetControlDetails(hMixer, mxControlDetails, %MIXER_GETCONTROLDETAILSF_VALUE)
        IF (dwReturn = 0) THEN
            Channel1 = dwResults(0)
            Channel2 = dwResults(1)
            GetCurrentValue = %TRUE
        ELSE
            #DEBUG PRINT mixerErrorMessage(dwReturn)
            GetCurrentValue = %FALSE
        END IF
    
    END FUNCTION
    
    '------------------------------------------------------------------------------
    
    SUB MixerMultipleLabels(hDlg AS DWORD, hMixer AS DWORD, dwControlID AS DWORD, cMultipleItems AS DWORD)
    LOCAL mxControlDetails  AS MIXERCONTROLDETAILS
    LOCAL dwReturn, ixItem  AS LONG
    LOCAL mxListText()      AS MIXERCONTROLDETAILS_LISTTEXT
    
        mxControlDetails.dwControlID    = dwControlID
        mxControlDetails.cbStruct       = SIZEOF(mxControlDetails)
        mxControlDetails.cChannels      = 1
        DIM mxListText(cMultipleItems)
        mxControlDetails.cbDetails      = SIZEOF(mxListText(0))
    
        '//////// removed this /////////
        'mxControlDetails.Item           = cMultipleItems
        '///////////////////////////////
    
        mxControlDetails.paDetails      = VARPTR(mxListText(0))
    
        dwReturn = mixerGetControlDetails(hMixer, mxControlDetails, %MIXER_GETCONTROLDETAILSF_LISTTEXT)
        IF (dwReturn = 0) THEN
            FOR ixItem = 0 TO cMultipleItems - 1
                SetResultText hDlg, "          Label "& FORMAT$(ixItem) &" "& mxListText(ixItem).szName
            NEXT ixItem
        ELSE
            SetResultText hDlg, "Error Multiple Labels: "& mixerErrorMessage(dwReturn)
        END IF
    END SUB
    
    '------------------------------------------------------------------------------
    
    SUB QueryMixerInfo(hDlg AS DWORD, hMixer AS DWORD, iQuery AS LONG)
    LOCAL mxLine                AS MIXERLINE
    LOCAL mxLineControls        AS MIXERLINECONTROLS
    LOCAL mxControl()           AS MIXERCONTROL
    LOCAL dwReturn              AS DWORD
    LOCAL nControls, nChannels  AS LONG
    LOCAL ixControl, dwValue    AS LONG
    LOCAL lName, sName          AS STRING
    LOCAL Channel1, Channel2    AS LONG
    
        mxLine.cbStruct         = SIZEOF(mxLine)
        mxLine.dwComponentType  = iQuery
    
        dwReturn = mixerGetLineInfo(hMixer, mxLine, %MIXER_GETLINEINFOF_COMPONENTTYPE)
        IF (dwReturn = 0) THEN
            SetResultText hDlg, "  "& GetQueryTypeString(iQuery)
            mxLineControls.cbStruct = SIZEOF(mxLineControls)
            mxLineControls.dwLineID = mxLine.dwLineID
            nControls = mxLine.cControls
            nChannels = mxLine.cChannels
            SetResultText hDlg, "    Channels = "& FORMAT$(nChannels) &", Controls = "& FORMAT$(nControls)
            mxLineControls.cControls = nControls
            DIM mxControl(nControls)
            mxLineControls.cbmxctrl = SIZEOF(mxControl(0))
            mxLineControls.pamxctrl = VARPTR(mxControl(0))
    
            dwReturn = mixerGetLineControls(hMixer, mxLineControls, %MIXER_GETLINECONTROLSF_ALL)
            IF (dwReturn = 0) THEN
                FOR ixControl = 0 TO nControls - 1
                    SetResultText hDlg, "      Control ID = "& FORMAT$(mxControl(ixControl).dwControlID) _
                        &", "& MixerControlType(mxControl(ixControl).dwControlType) _
                        &" "& MixerControlStatus(mxControl(ixControl).fdwControl)
                    SetResultText hDlg, "        Class: "& MixerClassDetails(mxControl(ixControl).dwControlType)
                    lName = mxControl(ixControl).szName
                    sName = mxControl(ixControl).szShortName
                    IF ((LEN(sName) > 0) OR (LEN(lName) > 0)) THEN
                        SetResultText hDlg, "        Named: "& lName _
                            &" "& FORMAT$(mxControl(ixControl).Bounds.lMinMax.lMinimum) _
                            &" - "& FORMAT$(mxControl(ixControl).Bounds.lMinMax.lMaximum)
                        IF (sName <> lName) THEN
                            SetResultText hDlg, "          Short Alias: "& sName
                        END IF
                    ELSE
                        SetResultText hDlg, "        MinMax: "& FORMAT$(mxControl(ixControl).Bounds.lMinMax.lMinimum) _
                            &" - "& FORMAT$(mxControl(ixControl).Bounds.lMinMax.lMaximum)
                    END IF
                    dwValue = GetCurrentValue(hMixer, mxControl(ixControl), BYREF Channel1, BYREF Channel2)
                    IF (ISTRUE dwValue) THEN ' successfully fetched current setting of control
                        IF ((mxControl(ixControl).dwControlType AND %MIXERCONTROL_CT_CLASS_MASK) = %MIXERCONTROL_CT_CLASS_SWITCH) THEN
                            SetResultText hDlg, "        "& GetSwitchStatus(mxControl(ixControl), Channel1, Channel2)
                        ELSE ' Control is 'stereo'
                            IF (mxControl(ixControl).fdwControl = %MIXERCONTROL_CONTROLF_UNIFORM) THEN
                                SetResultText hDlg, "        Channel Value "& FORMAT$(Channel1)
                            ELSE
                                SetResultText hDlg, "        Channel 1 Value "& FORMAT$(Channel1)
                                SetResultText hDlg, "        Channel 2 Value "& FORMAT$(Channel2)
                            END IF
                        END IF
                    END IF
                    IF (mxControl(ixControl).cMultipleItems <> 0) THEN
                        MixerMultipleLabels hDlg, hMixer, mxControl(ixControl).dwControlID, mxControl(ixControl).cMultipleItems
                    END IF
                NEXT ixControl
            ELSE
                SetResultText hDlg, "Error Get Line Info: "& mixerErrorMessage(dwReturn)
            END IF
        ELSE
            ' oh hey, we don't do this
            ' if we get an error, it's because the hardware doesn't support the query
            ' SetResultText hDlg, "Error Get Line Info: "& mixerErrorMessage(dwReturn)
        END IF
    
    END SUB
    
    '------------------------------------------------------------------------------
    
    FUNCTION GetMixername(mixerID AS LONG) AS STRING
    LOCAL MixerInfo     AS MIXERCAPS
    LOCAL strResults    AS STRING
      mixerGetDevCaps mixerID, MixerInfo, LEN(MixerInfo)
      strResults = MixerInfo.szPname
      GetMixername = strResults
    END FUNCTION
    
    '------------------------------------------------------------------------------
    
    SUB LoadMixerInfo(hDlg AS DWORD)
    LOCAL mCount, mIndex        AS LONG
    LOCAL DstIndex, SrcIndex    AS LONG
    LOCAL hMixer, dwReturn      AS DWORD
    LOCAL zText                 AS ASCIIZ * 256
    
        mCount = mixerGetNumDevs()
        zText = "Number of Mixer Devices Found: "& FORMAT$(mCount)
        CONTROL SET TEXT hDlg, %IDTX_RESULTS, zText
        FOR mIndex = 0 TO mCount - 1
            dwReturn = mixerOpen(hMixer, mIndex, 0, 0, 0)
            IF (dwReturn <> 0) THEN
                SetResultText hDlg, "Error Opening Mixer: "& FORMAT$(mIndex) &" Error Code: "& mixerErrorMessage(dwReturn)
                EXIT SUB
            END IF
    
            SetResultText hDlg, GetMixerName(mIndex) &" Destination ID: "& FORMAT$(mIndex + 1) &" of "& FORMAT$(mCount)
            FOR DstIndex = %MIXERLINE_COMPONENTTYPE_DST_FIRST TO %MIXERLINE_COMPONENTTYPE_DST_LAST
                QueryMixerInfo hDlg, hMixer, DstIndex
            NEXT DstIndex
    
            SetResultText hDlg, GetMixerName(mIndex) &" Source ID: "& FORMAT$(mIndex + 1) &" of "& FORMAT$(mCount)
            FOR SrcIndex = %MIXERLINE_COMPONENTTYPE_SRC_FIRST TO %MIXERLINE_COMPONENTTYPE_SRC_LAST
                QueryMixerInfo hDlg, hMixer, SrcIndex
            NEXT SrcIndex
    
            mixerClose hMixer
        NEXT mIndex
        SetResultText hDlg, "Finished"
    END SUB
    
    
    '------------------------------------------------------------------------------
    
    '------------------------------------------------------------------------------
    '   ** Main Application Entry Point **
    '------------------------------------------------------------------------------
    FUNCTION PBMAIN()
        ShowMixerControls %HWND_DESKTOP
    END FUNCTION
    '------------------------------------------------------------------------------
    
    '------------------------------------------------------------------------------
    '   ** CallBacks **
    '------------------------------------------------------------------------------
    CALLBACK FUNCTION ShowMixerControlsProc()
    
        SELECT CASE AS LONG CB.MSG
            CASE %WM_INITDIALOG
                LoadMixerInfo CB.HNDL
                CONTROL SET FOCUS CB.HNDL, %IDSB_SOMETHING
                ' Initialization handler
    
            CASE %WM_SIZE
            LOCAL DX,DY, SX, SY     AS LONG
                CONTROL SEND CB.HNDL, %IDSB_SOMETHING, CB.MSG, CB.WPARAM, CB.LPARAM
                DIALOG GET CLIENT CB.HNDL TO DX, DY
                CONTROL GET SIZE CB.HNDL, %IDSB_SOMETHING TO SX, SY
                DY = DY - SY
                CONTROL SET LOC CB.HNDL, %IDTX_RESULTS, 0, 0
                CONTROL SET SIZE CB.HNDL, %IDTX_RESULTS, DX, DY
    
        END SELECT
    
    END FUNCTION
    '------------------------------------------------------------------------------
    
    '------------------------------------------------------------------------------
    '   ** Dialogs **
    '------------------------------------------------------------------------------
    FUNCTION ShowMixerControls(BYVAL hParent AS DWORD) AS LONG
        LOCAL lRslt AS LONG
        LOCAL hDlg  AS DWORD
    
        DIALOG NEW PIXELS, hParent, "Mixer Controls", , , 376, 325, _
            %WS_POPUP OR %WS_BORDER OR %WS_THICKFRAME _
            OR %WS_CAPTION OR %WS_SYSMENU _
            OR %WS_MINIMIZEBOX OR %WS_MAXIMIZEBOX OR %WS_CLIPSIBLINGS _
            OR %WS_CLIPCHILDREN OR %WS_VISIBLE OR %DS_MODALFRAME _
            OR %DS_3DLOOK OR %DS_NOFAILCREATE OR %DS_SETFONT, _
            %WS_EX_CONTROLPARENT OR %WS_EX_LEFT _
            OR %WS_EX_LTRREADING OR %WS_EX_RIGHTSCROLLBAR, _
            TO hDlg
        CONTROL ADD TEXTBOX, hDlg, %IDTX_RESULTS, "", 60, 24, 195, 155, _
            %WS_CHILD OR %WS_VISIBLE OR %WS_TABSTOP OR %ES_LEFT _
            OR %ES_MULTILINE OR %ES_AUTOHSCROLL OR %ES_READONLY _
            OR %WS_HSCROLL OR %WS_VSCROLL, _
            %WS_EX_CLIENTEDGE OR %WS_EX_LEFT OR _
            %WS_EX_LTRREADING OR %WS_EX_RIGHTSCROLLBAR
        CONTROL ADD STATUSBAR, hDlg, %IDSB_SOMETHING, "Something To Grab", _
            0, 306, 376, 19, _
            %WS_CHILD OR %WS_VISIBLE, _
            %WS_EX_LEFT OR %WS_EX_LTRREADING OR %WS_EX_RIGHTSCROLLBAR
    
        DIALOG SHOW MODAL hDlg, CALL ShowMixerControlsProc TO lRslt
    
        ShowMixerControls = lRslt
    END FUNCTION
    '------------------------------------------------------------------------------
    

    Comment

    Working...
    X