def connect(name='Synth input'): for dev in range(pypm.CountDevices()): interf, p_name, inp, outp, opened = pypm.GetDeviceInfo(dev) if (outp == 1) and name in p_name: port = pypm.Output(dev, 0) return port return None
def findInputDevice(deviceName): init() for deviceId in xrange(pypm.CountDevices()): interf, name, inp, outp, opened = pypm.GetDeviceInfo(deviceId) if inp and (deviceName in name): return deviceId
def selectFirebox(self): midiOut = -1 for loop in range(pypm.CountDevices()): interf, name, inp, outp, opened = pypm.GetDeviceInfo(loop) if (outp == 1): if "FIREBOX" in name: midiOut = loop return midiOut
def get_devices(self): """list and set midi device """ self.midi_device_list = [] for loop in range(pypm.CountDevices()): interf, name, inp, outp, opened = pypm.GetDeviceInfo(loop) if outp == 1: self.midi_device_list.append([loop, name, opened]) return self.midi_device_list
def printDevices(self, InOrOut): for loop in range(pypm.CountDevices()): interf, name, inp, outp, opened = pypm.GetDeviceInfo(loop) if ((InOrOut == INPUT) & (inp == 1) | (InOrOut == OUTPUT) & (outp == 1)): print loop, name, " ", if (inp == 1): print "(input) ", else: print "(output) ", if (opened == 1): print "(opened)" else: print "(unopened)"
def PrintDevices(): print "-------------------" print "Devices:" print "-------------------" for loop in range(pypm.CountDevices()): interf,name,inp,outp,opened = pypm.GetDeviceInfo(loop) print loop, name," ", if (inp == 1): print "(input) ", else: print "(output) ", if (opened == 1): print "(opened)" else: print "(unopened)"
def get_info(self): info_keys = ['interface', 'name', 'ins', 'outs', 'open'] for i in range(pyportmidi.CountDevices()): info_list = pyportmidi.GetDeviceInfo(i) info_dict = dict(zip(info_keys, info_list)) if info_dict['ins']: info_dict['type'] = 'in' else: info_dict['type'] = 'out' info_dict['Index'] = i yield info_dict
def findLaunchpads(): ins = [] outs = [] for loop in range(pypm.CountDevices()): interf, name, inp, outp, opened = pypm.GetDeviceInfo(loop) if name.startswith("Launchpad"): if inp: ins.append(loop) else: outs.append(loop) return zip(ins, outs)
def get_devices(self): """ Returns the list of MIDI input devices on this computer. @rtype: list """ self.midi_device_list = [] for loop in range(pypm.CountDevices()): interf, name, inp, outp, opened = pypm.GetDeviceInfo(loop) if inp == 1: self.midi_device_list.append([loop, name, opened]) return self.midi_device_list
def find_device(dev_name): n = pypm.CountDevices() in_device = None out_device = None for i in range(n): info = pypm.GetDeviceInfo(i) if info[1] == dev_name and info[2] == True: in_device = i if info[1] == dev_name and info[3] == True: out_device = i return (in_device, out_device)
def __init__(self): pypm.Initialize() self.midi = None self.debug = False for n in range(pypm.CountDevices()): info = pypm.GetDeviceInfo(n) name = info[1] isOutput = info[3] if name == MIDIOUT_DEFAULT and isOutput == 1: self.midi = pypm.Output(n, 1) print "Found MIDI output (%s)" % name
def find_hiduino(): input_index = -1 output_index = -1 for d in xrange(pypm.CountDevices()): device_info = pypm.GetDeviceInfo(d) if 'HIDUINO' in device_info[1]: if device_info[2]: input_index = d if device_info[3]: output_index = d if (input_index == -1) or (output_index == -1): raise IOError('Hiduino not found: input=%i output=%i' % (input_index, output_index)) return input_index, output_index
def ListMidiInputDevices(self): Found = 0 for DeviceNr in range(pypm.CountDevices()): Interface, Name, Inp, Outp, Opened = pypm.GetDeviceInfo(DeviceNr) if Inp == 1: # input devices only Found = 1 print("Device Number: ", DeviceNr, "Interface: ", Interface, "Name: ", Name) if Found == 0: print( "*** No MIDI input devices found! Consider using a virtual midi keyboard (e.g. vkeyb on linux)" ) print("Going back to command line now.") sys.exit(1)
def findLaunchpads(): ins = [] outs = [] i = 0 for loop in range(pypm.CountDevices()): interf, name, inp, outp, opened = pypm.GetDeviceInfo(loop) print i, interf, name, inp, outp, opened if name.find("Launchpad") >= 0: if inp: ins.append(loop) else: outs.append(loop) i += 1 return zip(ins, outs)
def __init__(self, target=MIDIIN_DEFAULT): pypm.Initialize() self.midi = None for n in range(pypm.CountDevices()): info = pypm.GetDeviceInfo(n) name = info[1] print "[%d] %s %s" % (n, name, info) isInput = info[2] if name == target and isInput == 1: self.midi = pypm.Input(n) print "found target input: %s" % target if self.midi is None: raise Exception, "Could not find MIDI source: %s" % target
def find_device(): count = pypm.CountDevices() print 'Found {0} devices'.format(count) in_dev, out_dev = (None, None) for i in range(count): info = pypm.GetDeviceInfo(i) print info if info[1] == 'Launchpad Mini': if info[2] == 1: print 'Opening input {0}'.format(i) in_dev = pypm.Input(i) if info[3] == 1: print 'Opening output {0}'.format(i) out_dev = pypm.Output(i) return (in_dev, out_dev)
def printDevices(): init() for deviceId in xrange(pypm.CountDevices()): interf, name, inp, outp, opened = pypm.GetDeviceInfo(deviceId) if inp: inOutType = '(input)' elif outp: inOutType = '(output)' else: inOutType = '(unknown)' status = '(opened)' if opened == 1 else '(unopened)' print deviceId, name, inOutType, status
def _gatherDeviceInfo(cls): for devno in range(pypm.CountDevices()): info = pypm.GetDeviceInfo(devno) insouts = {'output': None, 'input': None} m = cls.deviceMap.setdefault(info[1], insouts) if info[3]: cls.outputs.append(devno) m['output'] = devno if info[2]: cls.inputs.append(devno) m['input'] = devno cls.inputNames = dict( (v['input'], k) for (k, v) in cls.deviceMap.items() if v['input'] is not None ) cls.outputNames = dict( (v['output'], k) for (k, v) in cls.deviceMap.items() if v['output'] is not None )
def debug_ShowMidiDevices(self): numDevices = pypm.CountDevices() for n in range(numDevices): print("%d - %s") % (n, pypm.GetDeviceInfo(n))
def get_device_info(self): """ Returns info about the currently selected device """ return pypm.GetDeviceInfo(self.midi_device)
def get_device_info(self): """print info of the current device """ res = pypm.GetDeviceInfo(self.midi_device) return res
def list_devices(cls): '''Queries the MIDI API for available devices.''' ret = [] for i in range(pypm.CountDevices()): ret.append(pypm.GetDeviceInfo(i)) return ret