Beispiel #1
0
    def __enter__(self) -> 'MidiOutput':
        if not m.get_init():
            m.init()

        port = m.get_default_output_id()
        self._output = m.Output(port)
        return self
Beispiel #2
0
    def __init__(self, mode="live"):
        self.functions = {}
        self.keys = False  #Amount of buttons / leds
        self.mode = mode.lower()

        if (not midi.get_init()):
            midi.init()

        self.input = self.input_port()
        self.output = self.output_port()
        self.clear()
Beispiel #3
0
    def __init__(self, input, output, flash=True):
        midi.init()
        while not midi.get_init():
            pass

        self._midiIn = midi.Input(input)
        self._midiOut = midi.Output(output)

        if flash:
            for i in (5, 3, 1, 0):
                for j in range(64):
                    self._midiOut.note_on(j, i)
                    time.sleep(0.01)
    def __init__(self, channel=1, device_id=None):
        super().__init__()
        self.output = None
        if not midi.get_init():
            midi.init()
        if device_id is None:
            device_id = midi.get_default_output_id()

        mididevs = {}
        dfldev = None
        for did in range(midi.get_count()):
            dev = midi.get_device_info(did)
            if dev[3] == 1:
                devname = dev[1].decode()
                mididevs[devname] = did
            if did == device_id:
                dfldev = devname

        def config_devbox(combo):
            def _set_dev_cb(c):
                self.set_device(self.device)

            combo.connect("changed", _set_dev_cb)
            self.set_device(self.device)

        self.setup_configurable(
            "MIDI Output",
            "midi",
            confmap={
                # "mode": ListConfiguration("Output Mode", "mode", default_val, items),
                "channel":
                NumericConfiguration(
                    "MIDI Channel",
                    "channel",
                    Gtk.SpinButton,
                    channel,
                    1,
                    16,
                    step_incr=1,
                    page_incr=1,
                ),
                "device":
                ListConfiguration(
                    "MIDI Device",
                    "device",
                    dfldev,
                    mididevs,
                    gui_setup_cb=config_devbox,
                ),
            },
        )
Beispiel #5
0
    def getMidi(self):
        midIn = m.Input(m.get_default_input_id())
        while not midIn.poll() and self.running:
            if not m.get_init():
                m.init()
            else:
                pass
        if not self.running:
            return

        event = midIn.read(1)
        mob = mObject(event[0][0][0] >> 4, event[0][0][1], event[0][0][2])
        midIn.close()
        return mob