示例#1
0
    def GetControls(self, hmixer, mixerline):
        numCtrls = mixerline.cControls
        if numCtrls == 0:
            return []

        mixerControlArray = (MIXERCONTROL * numCtrls)()
        mixerLineControls = MIXERLINECONTROLS()
        mixerLineControls.cbStruct = sizeof(MIXERLINECONTROLS)
        mixerLineControls.cControls = numCtrls
        mixerLineControls.dwLineID = mixerline.dwLineID
        mixerLineControls.pamxctrl = pointer(mixerControlArray[0])
        mixerLineControls.cbmxctrl = sizeof(MIXERCONTROL)
        mixerGetLineControls(hmixer, byref(mixerLineControls),
                             MIXER_GETLINECONTROLSF_ALL)
        result = []

        for i in range(numCtrls):
            mixerControl = mixerControlArray[i]
            dwControlType = mixerControl.dwControlType
            controlClass = MIXER_CONTROL_CLASSES[dwControlType
                                                 & MIXERCONTROL_CT_CLASS_MASK]
            controlClassTypeName = controlClass["types"][dwControlType]
            flagNames = []
            fdwControl = mixerControl.fdwControl
            if fdwControl & MIXERCONTROL_CONTROLF_DISABLED:
                flagNames.append("Disabled")
            if fdwControl & MIXERCONTROL_CONTROLF_MULTIPLE:
                flagNames.append("Multiple(%i)" % mixerControl.cMultipleItems)
            if fdwControl & MIXERCONTROL_CONTROLF_UNIFORM:
                flagNames.append("Uniform")
            result.append((mixerControl.dwControlID, mixerControl.szName,
                           controlClass["name"], controlClassTypeName,
                           ", ".join(flagNames)))

        return result
示例#2
0
def GetControls(hmixer, mixerline):
    numCtrls = mixerline.cControls
    if numCtrls == 0:
        return []
    mixerControlArray = (MIXERCONTROL * numCtrls)()
    mixerLineControls = MIXERLINECONTROLS()
    mixerLineControls.cbStruct = sizeof(MIXERLINECONTROLS)
    mixerLineControls.cControls = numCtrls
    mixerLineControls.dwLineID = mixerline.dwLineID
    mixerLineControls.pamxctrl = pointer(mixerControlArray[0])
    mixerLineControls.cbmxctrl = sizeof(MIXERCONTROL)
    mixerGetLineControls(hmixer, byref(mixerLineControls), MIXER_GETLINECONTROLSF_ALL)
    result = []
    for i in range(numCtrls):
        mixerControl = mixerControlArray[i]
        dwControlType = mixerControl.dwControlType
        controlClass = MIXER_CONTROL_CLASSES[dwControlType & MIXERCONTROL_CT_CLASS_MASK]
        controlClassTypeName = controlClass["types"][dwControlType]
        flagNames = []
        fdwControl = mixerControl.fdwControl
        if fdwControl & MIXERCONTROL_CONTROLF_DISABLED:
            flagNames.append("Disabled")
        if fdwControl & MIXERCONTROL_CONTROLF_MULTIPLE:
            flagNames.append("Multiple(%i)" % mixerControl.cMultipleItems)
        if fdwControl & MIXERCONTROL_CONTROLF_UNIFORM:
            flagNames.append("Uniform")
        result.append((mixerControl.szName, controlClass["name"], controlClassTypeName, ", ".join(flagNames)))
    return result
示例#3
0
    def GetControl(self, mixer, controlId):
        mixerControl = MIXERCONTROL()
        mixerControl.cbStruct = sizeof(MIXERCONTROL)
        mixerLineControls = MIXERLINECONTROLS()
        mixerLineControls.cbStruct = sizeof(MIXERLINECONTROLS)

        mixerLineControls.dwControlID = controlId
        mixerLineControls.cControls = 1
        mixerLineControls.cbmxctrl = sizeof(mixerControl)
        mixerLineControls.pamxctrl = pointer(mixerControl)

        rc = mixerGetLineControls(mixer, byref(mixerLineControls), 1)  # MIXER_GETLINECONTROLSF_ONEBYID
        if MMSYSERR_NOERROR != rc:
            raise SoundMixerException()
        return mixerControl
    def GetControl(self, mixer, controlId):
        mixerControl = MIXERCONTROL()
        mixerControl.cbStruct = sizeof(MIXERCONTROL)
        mixerLineControls = MIXERLINECONTROLS()
        mixerLineControls.cbStruct = sizeof(MIXERLINECONTROLS)

        mixerLineControls.dwControlID = controlId
        mixerLineControls.cControls = 1
        mixerLineControls.cbmxctrl = sizeof(mixerControl)
        mixerLineControls.pamxctrl = pointer(mixerControl)

        rc = mixerGetLineControls(mixer, byref(mixerLineControls), 1) #MIXER_GETLINECONTROLSF_ONEBYID
        if MMSYSERR_NOERROR != rc:
            raise SoundMixerException()
        return mixerControl
示例#5
0
def GetMixerControl(componentType, ctrlType, deviceId=0):
    '''
    Obtains an appropriate pointer and info for the volume control
    This function attempts to obtain a mixer control. Raises
    SoundMixerException if not successful.
    '''
    deviceId = GetDeviceId(deviceId)
    hmixer = HMIXER()

    # Obtain the hmixer struct
    rc = mixerOpen(byref(hmixer), deviceId, 0, 0, 0)
    if rc != MMSYSERR_NOERROR:
        raise SoundMixerException()

    mixerLineControls = MIXERLINECONTROLS()
    mixerLineControls.cbStruct = sizeof(MIXERLINECONTROLS)
    mixerLine = MIXERLINE()
    mixerLine.cbStruct = sizeof(MIXERLINE)
    mixerControl = MIXERCONTROL()
    mixerControl.cbStruct = sizeof(MIXERCONTROL)

    mixerLine.dwComponentType = componentType

    # Obtain a line corresponding to the component type
    rc = mixerGetLineInfo(
        hmixer,
        byref(mixerLine),
        MIXER_GETLINEINFOF_COMPONENTTYPE
    )
    if rc != MMSYSERR_NOERROR:
        raise SoundMixerException()

    mixerLineControls.dwLineID = mixerLine.dwLineID
    mixerLineControls.dwControlType = ctrlType
    mixerLineControls.cControls = 1
    mixerLineControls.cbmxctrl = sizeof(mixerControl)
    mixerLineControls.pamxctrl = pointer(mixerControl)

    # Get the control
    rc = mixerGetLineControls(
        hmixer,
        byref(mixerLineControls),
        MIXER_GETLINECONTROLSF_ONEBYTYPE
    )
    if MMSYSERR_NOERROR != rc:
        raise SoundMixerException()
    return hmixer, mixerControl
示例#6
0
 def AddControls(self, parentItem, mixerline):
     numCtrls = mixerline.cControls
     if numCtrls == 0:
         return []
     mixerControlArray = (MIXERCONTROL * numCtrls)()
     mixerLineControls = MIXERLINECONTROLS()
     mixerLineControls.cbStruct = sizeof(MIXERLINECONTROLS)
     mixerLineControls.cControls = numCtrls
     mixerLineControls.dwLineID = mixerline.dwLineID
     mixerLineControls.pamxctrl = pointer(mixerControlArray[0])
     mixerLineControls.cbmxctrl = sizeof(MIXERCONTROL)
     mixerGetLineControls(self.mixerHandle, byref(mixerLineControls),
                          MIXER_GETLINECONTROLSF_ALL)
     for i in range(numCtrls):
         mixerControl = mixerControlArray[i]
         ctrlItem = self.AppendItem(parentItem, mixerControl.szName)
         self.SetPyData(ctrlItem, mixerControl.dwControlID)
示例#7
0
 def AddControls(self, parentItem, mixerline):
     numCtrls = mixerline.cControls
     if numCtrls == 0:
         return []
     mixerControlArray = (MIXERCONTROL * numCtrls)()
     mixerLineControls = MIXERLINECONTROLS()
     mixerLineControls.cbStruct = sizeof(MIXERLINECONTROLS)
     mixerLineControls.cControls = numCtrls
     mixerLineControls.dwLineID = mixerline.dwLineID
     mixerLineControls.pamxctrl = pointer(mixerControlArray[0])
     mixerLineControls.cbmxctrl = sizeof(MIXERCONTROL)
     mixerGetLineControls(
         self.mixerHandle,
         byref(mixerLineControls),
         MIXER_GETLINECONTROLSF_ALL
     )
     for i in range(numCtrls):
         mixerControl = mixerControlArray[i]
         ctrlItem = self.AppendItem(
             parentItem,
             mixerControl.szName
         )
         self.SetPyData(ctrlItem, mixerControl.dwControlID)
示例#8
0
    def OnSelectionChanged(self, event):
        dwControlID = self.GetPyData(event.GetItem())
        panel = self.panel
        panel.DestroyChildren()
        sizer = wx.BoxSizer(wx.VERTICAL)

        idCtrl = wx.StaticText(panel, -1, "ID: " + str(dwControlID))
        sizer.Add(idCtrl)
        if dwControlID is None:
            panel.SetSizerAndFit(sizer)
            return

        mixerControl = MIXERCONTROL()
        mixerLineControls = MIXERLINECONTROLS()
        mixerLineControls.cbStruct = sizeof(MIXERLINECONTROLS)
        mixerLineControls.cControls = 1
        mixerLineControls.dwControlID = dwControlID
        mixerLineControls.pamxctrl = pointer(mixerControl)
        mixerLineControls.cbmxctrl = sizeof(MIXERCONTROL)
        err = mixerGetLineControls(
            self.mixerHandle,
            byref(mixerLineControls),
            MIXER_GETLINECONTROLSF_ONEBYID
        )
        if err:
            print "error", err
            return

        idCtrl = wx.StaticText(panel, -1, "Name: " + mixerControl.szName)
        sizer.Add(idCtrl)

        idCtrl = wx.StaticText(
            panel, -1, "Short Name: " + mixerControl.szShortName
        )
        sizer.Add(idCtrl)

        dwControlType = mixerControl.dwControlType

        controlClass = MIXER_CONTROL_CLASSES[
            dwControlType & MIXERCONTROL_CT_CLASS_MASK
        ]
        idCtrl = wx.StaticText(
            panel, -1, "Classification: " + controlClass["name"]
        )
        sizer.Add(idCtrl)

        controlClassTypeName = controlClass["types"][dwControlType]
        idCtrl = wx.StaticText(panel, -1, "Type: " + controlClassTypeName)
        sizer.Add(idCtrl)

        fdwControl = mixerControl.fdwControl
        cMultipleItems = 0
        numMultipleItems = 1
        flagNames = []
        if fdwControl & MIXERCONTROL_CONTROLF_DISABLED:
            flagNames.append("Disabled")
        if fdwControl & MIXERCONTROL_CONTROLF_MULTIPLE:
            flagNames.append("Multiple(%i)" % mixerControl.cMultipleItems)
            numMultipleItems = mixerControl.cMultipleItems
            cMultipleItems = mixerControl.cMultipleItems
        if fdwControl & MIXERCONTROL_CONTROLF_UNIFORM:
            flagNames.append("Uniform")
        idCtrl = wx.StaticText(panel, -1, "Flags: " + ", ".join(flagNames))
        sizer.Add(idCtrl)

        valueType = CONTROLTYPES[dwControlType][1]
        valueTypeName = MIXERCONTROLDETAILS_NAMES[valueType]
        idCtrl = wx.StaticText(panel, -1, "Value Type: " + valueTypeName)
        sizer.Add(idCtrl)

        if dwControlType == MIXERCONTROL_CONTROLTYPE_CUSTOM:
            cChannels = 0
        elif fdwControl & MIXERCONTROL_CONTROLF_UNIFORM:
            cChannels = 1
        else:
            # TODO: Get the number of channels
            cChannels = 2
        details = (valueType * (cChannels * numMultipleItems))()
        mixerControlDetails = MIXERCONTROLDETAILS()
        mixerControlDetails.cbStruct = sizeof(MIXERCONTROLDETAILS)
        mixerControlDetails.dwControlID = dwControlID
        mixerControlDetails.cChannels = cChannels
        mixerControlDetails.cMultipleItems = cMultipleItems
        mixerControlDetails.cbDetails = sizeof(details)
        mixerControlDetails.paDetails = cast(pointer(details), c_void_p)
        valueType()
        mixerGetControlDetails(
            self.mixerHandle,
            byref(mixerControlDetails),
            MIXER_GETCONTROLDETAILSF_VALUE
        )
        values = []
        for i in range(cChannels * numMultipleItems):
            if valueType == MCD_BOOLEAN:
                values.append(details[i].fValue)
            elif valueType == MCD_SIGNED:
                values.append(details[i].lValue)
            elif valueType == MCD_UNSIGNED:
                values.append(details[i].dwValue)

        idCtrl = wx.StaticText(panel, -1, "Value: %r" % values)
        sizer.Add(idCtrl)

        if (
            dwControlType & MIXERCONTROL_CT_CLASS_MASK ==
            MIXERCONTROL_CT_CLASS_LIST
        ):
            labels = (
                MIXERCONTROLDETAILS_LISTTEXT * (cChannels * numMultipleItems)
            )()
            mixerControlDetails.cbDetails = sizeof(
                MIXERCONTROLDETAILS_LISTTEXT
            )
            mixerControlDetails.paDetails = cast(pointer(labels), c_void_p)
            mixerGetControlDetails(
                self.mixerHandle,
                byref(mixerControlDetails),
                MIXER_GETCONTROLDETAILSF_LISTTEXT
            )
            for i in range(cChannels * numMultipleItems):
                print labels[i].szName
        panel.SetSizerAndFit(sizer)
示例#9
0
    def OnSelectionChanged(self, event):
        dwControlID = self.GetPyData(event.GetItem())
        panel = self.panel
        panel.DestroyChildren()
        sizer = wx.BoxSizer(wx.VERTICAL)

        idCtrl = wx.StaticText(panel, -1, "ID: " + str(dwControlID))
        sizer.Add(idCtrl)
        if dwControlID is None:
            panel.SetSizerAndFit(sizer)
            return

        mixerControl = MIXERCONTROL()
        mixerLineControls = MIXERLINECONTROLS()
        mixerLineControls.cbStruct = sizeof(MIXERLINECONTROLS)
        mixerLineControls.cControls = 1
        mixerLineControls.dwControlID = dwControlID
        mixerLineControls.pamxctrl = pointer(mixerControl)
        mixerLineControls.cbmxctrl = sizeof(MIXERCONTROL)
        err = mixerGetLineControls(self.mixerHandle, byref(mixerLineControls),
                                   MIXER_GETLINECONTROLSF_ONEBYID)
        if err:
            print "error", err
            return

        idCtrl = wx.StaticText(panel, -1, "Name: " + mixerControl.szName)
        sizer.Add(idCtrl)

        idCtrl = wx.StaticText(panel, -1,
                               "Short Name: " + mixerControl.szShortName)
        sizer.Add(idCtrl)

        dwControlType = mixerControl.dwControlType

        controlClass = MIXER_CONTROL_CLASSES[dwControlType
                                             & MIXERCONTROL_CT_CLASS_MASK]
        idCtrl = wx.StaticText(panel, -1,
                               "Classification: " + controlClass["name"])
        sizer.Add(idCtrl)

        controlClassTypeName = controlClass["types"][dwControlType]
        idCtrl = wx.StaticText(panel, -1, "Type: " + controlClassTypeName)
        sizer.Add(idCtrl)

        fdwControl = mixerControl.fdwControl
        cMultipleItems = 0
        numMultipleItems = 1
        flagNames = []
        if fdwControl & MIXERCONTROL_CONTROLF_DISABLED:
            flagNames.append("Disabled")
        if fdwControl & MIXERCONTROL_CONTROLF_MULTIPLE:
            flagNames.append("Multiple(%i)" % mixerControl.cMultipleItems)
            numMultipleItems = mixerControl.cMultipleItems
            cMultipleItems = mixerControl.cMultipleItems
        if fdwControl & MIXERCONTROL_CONTROLF_UNIFORM:
            flagNames.append("Uniform")
        idCtrl = wx.StaticText(panel, -1, "Flags: " + ", ".join(flagNames))
        sizer.Add(idCtrl)

        valueType = CONTROLTYPES[dwControlType][1]
        valueTypeName = MIXERCONTROLDETAILS_NAMES[valueType]
        idCtrl = wx.StaticText(panel, -1, "Value Type: " + valueTypeName)
        sizer.Add(idCtrl)

        if dwControlType == MIXERCONTROL_CONTROLTYPE_CUSTOM:
            cChannels = 0
        elif fdwControl & MIXERCONTROL_CONTROLF_UNIFORM:
            cChannels = 1
        else:
            # TODO: Get the number of channels
            cChannels = 2
        details = (valueType * (cChannels * numMultipleItems))()
        mixerControlDetails = MIXERCONTROLDETAILS()
        mixerControlDetails.cbStruct = sizeof(MIXERCONTROLDETAILS)
        mixerControlDetails.dwControlID = dwControlID
        mixerControlDetails.cChannels = cChannels
        mixerControlDetails.cMultipleItems = cMultipleItems
        mixerControlDetails.cbDetails = sizeof(details)
        mixerControlDetails.paDetails = cast(pointer(details), c_void_p)
        pmxcd = valueType()
        mixerGetControlDetails(self.mixerHandle, byref(mixerControlDetails),
                               MIXER_GETCONTROLDETAILSF_VALUE)
        values = []
        for i in range(cChannels * numMultipleItems):
            if valueType == MCD_BOOLEAN:
                values.append(details[i].fValue)
            elif valueType == MCD_SIGNED:
                values.append(details[i].lValue)
            elif valueType == MCD_UNSIGNED:
                values.append(details[i].dwValue)

        idCtrl = wx.StaticText(panel, -1, "Value: %r" % values)
        sizer.Add(idCtrl)

        if (dwControlType
                & MIXERCONTROL_CT_CLASS_MASK == MIXERCONTROL_CT_CLASS_LIST):
            labels = (MIXERCONTROLDETAILS_LISTTEXT *
                      (cChannels * numMultipleItems))()
            mixerControlDetails.cbDetails = sizeof(
                MIXERCONTROLDETAILS_LISTTEXT)
            mixerControlDetails.paDetails = cast(pointer(labels), c_void_p)
            mixerGetControlDetails(self.mixerHandle,
                                   byref(mixerControlDetails),
                                   MIXER_GETCONTROLDETAILSF_LISTTEXT)
            for i in range(cChannels * numMultipleItems):
                print labels[i].szName
        panel.SetSizerAndFit(sizer)