def __init__(self, device_id, buffer_size=4096): """ The buffer_size specifies the number of input events to be buffered waiting to be read using Input.read(). """ self._input = pypm.Input(device_id, buffer_size) self.device_id = device_id
def connectInput(self, device=None): """ Connect input to receive data from VMeter. If no device number is specified, attempts to connect to the first unopened input device with "VMeter" in the name. """ if device is None: a = [ i for (i, (_, name, inp, outp, opened)) in enumerate(get_devices()) if inp == 1 and opened == 0 and "VMeter" in name ] if len(a) > 0: device = a[0] else: raise Exception("No unopened VMeter input devices found!") return pypm.Input(device)
def connect_midi(): # connect MIDI input and output streams output_device = None input_device = None if len(sys.argv) > 2: output_device = int(sys.argv[1]) input_device = int(sys.argv[2]) else: print_devices(OUTPUT) output_device = int(raw_input("Type output number: ")) print_devices(INPUT) input_device = int(raw_input("Type input number: ")) out, in_ = (pypm.Output(output_device, 0), pypm.Input(input_device)) print print "MIDI Connected." print return (out, in_)
def __init__(self, device_id, buffer_size=4096): """ The buffer_size specifies the number of input events to be buffered waiting to be read using Input.read(). """ _check_init() if device_id == -1: raise MidiException("Device id is -1, not a valid output id. " "-1 usually means there were no default " "Output devices.") try: result = get_device_info(device_id) except TypeError: raise TypeError("an integer is required") except OverflowError: raise OverflowError("long int too large to convert to int") # and now some nasty looking error checking, to provide nice error # messages to the kind, lovely, midi using people of wherever. if result: _, _, is_input, is_output, _ = result if is_input: try: self._input = _pypm.Input(device_id, buffer_size) except TypeError: raise TypeError("an integer is required") self.device_id = device_id elif is_output: raise MidiException( "Device id given is not a valid input id, it is an output id." ) else: raise MidiException("Device id given is not a valid input id.") else: raise MidiException("Device id invalid, out of range.")