def SetControlValue(hmixer, mixerControl, value): """ Sets the volumne from the pointer of the object passed through ' [Note: original source taken from MSDN http://support.microsoft.com/default.aspx?scid=KB;EN-US;Q178456&] This function sets the value for a volume control. Returns True if successful """ valueDetails = MIXERCONTROLDETAILS_UNSIGNED() valueDetails.dwValue = value mixerControlDetails = MIXERCONTROLDETAILS() mixerControlDetails.cbStruct = sizeof(MIXERCONTROLDETAILS) mixerControlDetails.item = 0 mixerControlDetails.dwControlID = mixerControl.dwControlID mixerControlDetails.cbDetails = sizeof(valueDetails) mixerControlDetails.paDetails = addressof(valueDetails) mixerControlDetails.cChannels = 1 # Set the control value rc = mixerSetControlDetails(hmixer, byref(mixerControlDetails), 0) if rc != MMSYSERR_NOERROR: raise SoundMixerException()
def SetControlValue(self, mixer, controlId, value): valueDetails = MIXERCONTROLDETAILS_UNSIGNED() valueDetails.dwValue = value mixerControlDetails = MIXERCONTROLDETAILS() mixerControlDetails.cbStruct = sizeof(MIXERCONTROLDETAILS) mixerControlDetails.item = 0 mixerControlDetails.dwControlID = controlId mixerControlDetails.cbDetails = sizeof(valueDetails) mixerControlDetails.paDetails = addressof(valueDetails) mixerControlDetails.cChannels = 1 rc = mixerSetControlDetails(mixer, byref(mixerControlDetails), 0) if rc != MMSYSERR_NOERROR: raise SoundMixerException()
def GetControlValue(hmixer, mixerControl): valueDetails = MIXERCONTROLDETAILS_UNSIGNED() mixerControlDetails = MIXERCONTROLDETAILS() mixerControlDetails.cbStruct = sizeof(MIXERCONTROLDETAILS) mixerControlDetails.item = 0 mixerControlDetails.dwControlID = mixerControl.dwControlID mixerControlDetails.cbDetails = sizeof(valueDetails) mixerControlDetails.paDetails = addressof(valueDetails) mixerControlDetails.cChannels = 1 # Get the control value rc = mixerGetControlDetails(hmixer, byref(mixerControlDetails), 0) if rc != MMSYSERR_NOERROR: raise SoundMixerException() return valueDetails.dwValue
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)
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)