def FillTree(self): root = self.AddRoot("Sound Card") mixercaps = MIXERCAPS() mixerline = MIXERLINE() self.mixerHandle = mixerHandle = HMIXER() # Obtain the hmixer struct rc = mixerOpen(byref(mixerHandle), self.deviceId, 0, 0, 0) if rc != MMSYSERR_NOERROR: raise SoundMixerException() if mixerGetDevCaps(mixerHandle, byref(mixercaps), sizeof(MIXERCAPS)): raise SoundMixerException() for i in range(mixercaps.cDestinations): mixerline.cbStruct = sizeof(MIXERLINE) mixerline.dwDestination = i if mixerGetLineInfo(mixerHandle, byref(mixerline), MIXER_GETLINEINFOF_DESTINATION): continue destItem = self.AppendItem( root, mixerline.szName + ": %i" % mixerline.cChannels) self.AddControls(destItem, mixerline) for n in range(mixerline.cConnections): mixerline.cbStruct = sizeof(MIXERLINE) mixerline.dwDestination = i mixerline.dwSource = n if mixerGetLineInfo(mixerHandle, byref(mixerline), MIXER_GETLINEINFOF_SOURCE): continue sourceItem = self.AppendItem( destItem, mixerline.szName + ": %i" % mixerline.cChannels) self.AddControls(sourceItem, mixerline)
def GetMixer(self, deviceId): hmixer = HMIXER() rc = mixerOpen(byref(hmixer), deviceId, 0, 0, 0) if rc != MMSYSERR_NOERROR: raise SoundMixerException() return hmixer