How to use the mido.get_input_names function in mido

To help you get started, we’ve selected a few mido examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ManiacalLabs / BiblioPixel / scripts / release_test / features.py View on Github external
def midi():
        import mido
        return set(mido.get_input_names()) - MIDI_PORTS_TO_REMOVE
github ojacques / SynthesiaKontrol / SynthesiaKontrol.py View on Github external
MODE = "MK1"
        INSTR_ADDR = 0x1340 # KK S25 MK1
        NB_KEYS = 25
        OFFSET = -21
    else:
        print ("Sorry, keyboard not supported yet!")
        quit()
    
    print ("Connecting to Komplete Kontrol Keyboard")
    connected = init()
    portName = ""
    if connected:
        print("Connected to Komplete Kontrol!")
        CoolDemoSweep(2)    # Happy dance
        print ("Opening LoopBe input port")
        ports = mido.get_input_names()
        for port in ports:
            print("  Found MIDI port " + port + "...")
            if "LoopBe" in port:
                portName = port
        if portName == "":
            print("Error: can't find 'LoopBe' midi port. Please install LoopBe1 from http://www.nerds.de/en/download.html (Windows) or name your IAC midi device 'LoopBe' (on Mac).")
            exit(1)

        print ("Listening to Midi on LoopBe midi port")
        with mido.open_input(portName) as midiPort:
            for message in accept_notes(midiPort):
                print('Received {}'.format(message))
                LightNote(message.note, message.type, message.channel, message.velocity)
github lebaston100 / MIDItoOBS / main.py View on Github external
# so we first check if we can use it as an ioport
            if self._devicename in mido.get_ioport_names():
                self._port_in = mido.open_ioport(name=self._devicename, callback=self.callback, autoreset=True)
                self._port_out = self._port_in
            # otherwise we try to use it separately as input and output
            else:
                if self._devicename in mido.get_input_names():
                    self._port_in = mido.open_input(name=self._devicename, callback=self.callback)
                if self._devicename in mido.get_output_names():
                    self._port_out = mido.open_output(name=self._devicename, callback=self.callback, autoreset=True)
        except:
            self.log.critical("\nCould not open device `%s`" % self._devicename)
            self.log.critical("The midi device might be used by another application/not plugged in/have a different name.")
            self.log.critical("Please close the device in the other application/plug it in/select the rename option in the device management menu and restart this script.")
            self.log.critical("Currently connected devices:")
            for name in mido.get_input_names():
                self.log.critical("  - %s" % name)
            # EIO 5 (Input/output error)
            exit(5)
github lebaston100 / MIDItoOBS / main.py View on Github external
self.log = get_logger("midi_to_obs_device")
        self._id = deviceid
        self._devicename = device["devicename"]
        self._port_in = 0
        self._port_out = 0

        try:
            self.log.debug("Attempting to open midi port `%s`" % self._devicename)
            # a device can be input, output or ioport. in the latter case it can also be the other two
            # so we first check if we can use it as an ioport
            if self._devicename in mido.get_ioport_names():
                self._port_in = mido.open_ioport(name=self._devicename, callback=self.callback, autoreset=True)
                self._port_out = self._port_in
            # otherwise we try to use it separately as input and output
            else:
                if self._devicename in mido.get_input_names():
                    self._port_in = mido.open_input(name=self._devicename, callback=self.callback)
                if self._devicename in mido.get_output_names():
                    self._port_out = mido.open_output(name=self._devicename, callback=self.callback, autoreset=True)
        except:
            self.log.critical("\nCould not open device `%s`" % self._devicename)
            self.log.critical("The midi device might be used by another application/not plugged in/have a different name.")
            self.log.critical("Please close the device in the other application/plug it in/select the rename option in the device management menu and restart this script.")
            self.log.critical("Currently connected devices:")
            for name in mido.get_input_names():
                self.log.critical("  - %s" % name)
            # EIO 5 (Input/output error)
            exit(5)
github AmazingThew / KnobSock / configurator.py View on Github external
def connect(self):
        print('Connecting MIDI devices')
        mido.set_backend('mido.backends.rtmidi')
        controllerNames = mido.get_input_names()

        if not controllerNames: return

        for name in controllerNames:
            try:
                cleanName = name[:name.rfind(' ')]
                print("Connecting " + cleanName)
                mido.open_input(name, callback=lambda m, cn=cleanName: self.onMessage(cn, m))
            except Exception as e:
                print('Unable to open MIDI input: {}'.format(name), file=sys.stderr)
github Roboy / tss18-robotsinmusicalimprovisation / gui / rimi_gui.py View on Github external
# first tab file
        file_tab = bar.addMenu('File')
        vae_action = QAction('&VAEsemane', self)
        file_tab.addAction(vae_action)
        vae_action.triggered.connect(self.start_vae)
        lstm_action = QAction('&LSTM', self)
        file_tab.addAction(lstm_action)
        lstm_action.triggered.connect(self.start_lstm)
        quit_action = QAction('&Quit', self)
        quit_action.setShortcut('Ctrl+W')
        file_tab.addAction(quit_action)
        quit_action.triggered.connect(self.quit_trigger)

        # second tab midi port, sets instrument
        midi_port_tab = bar.addMenu('MIDI Port')
        available_port = mido.get_input_names()
        midi_ports = []
        midi_actions = []
        for port in available_port:
            midi_actions.append(QAction(port, self))
            midi_port_tab.addAction(midi_actions[-1])
        midi_port_tab.triggered.connect(self.set_instrument)

        # third tab model
        model_tab = bar.addMenu('Model')
        model_find_act = QAction('&Find', self)
        model_tab.addAction(model_find_act)
        model_find_act.triggered.connect(self.model_find_func)

        self.show()
github AmazingThew / KnobSock / server.py View on Github external
def awaitDevices(self, loop):
        controllerNames = mido.get_input_names()
        if controllerNames != self.prevControllerNames:
            print('\nConnecting devices:')
            self.connectDevices()
            self.rectifyDeviceState()
            self.animate()
        self.prevControllerNames = controllerNames

        loop.call_later(5, self.awaitDevices, loop)
github Roboy / tss18-robotsinmusicalimprovisation / software_gui / VAEsemane_GUI.py View on Github external
def initUIConnects(self):
        # menu bar
        # first tab "File"
        self.menu_bar.setNativeMenuBar(False)
        self.action_quit.triggered.connect(self.quit_clicked)
        # second tab "MIDI port", sets instrument
        available_port = mido.get_input_names()
        midi_ports = []
        midi_actions = []
        for port in available_port:
            midi_actions.append(QAction(port, self))
            self.menu_midi_port.addAction(midi_actions[-1])
        self.menu_midi_port.triggered.connect(self.set_instrument)
        # third tab set model path
        self.action_find.triggered.connect(self.set_model_path)
        self.action_pretrained.triggered.connect(self.set_pretrained_model)

        # buttons
        self.btn_run.clicked.connect(self.btn_run_clicked)
        self.btn_stop.clicked.connect(self.btn_stop_clicked)
        self.btn_randomize.clicked.connect(self.btn_randomize_clicked)
        self.btn_reset.clicked.connect(self.btn_reset_clicked)
        self.btn_run_endless.clicked.connect(self.btn_run_endless_clicked)
github Roboy / tss18-robotsinmusicalimprovisation / software_gui / Simulation_GUI.py View on Github external
def initUIConnects(self):
        # menu bar
        # first tab "File"
        self.menu_bar.setNativeMenuBar(False)
        self.action_quit.triggered.connect(self.quit_clicked)
        # second tab "MIDI port", sets instrument
        available_port = mido.get_input_names()
        midi_ports = []
        midi_actions = []
        for port in available_port:
            midi_actions.append(QAction(port, self))
            self.menu_midi_port.addAction(midi_actions[-1])
        self.menu_midi_port.triggered.connect(self.set_instrument)
        # third tab set model path
        self.action_find.triggered.connect(self.set_model_path)
        self.action_pretrained.triggered.connect(self.set_pretrained_model)

        # buttons
        self.btn_run.clicked.connect(self.btn_run_clicked)
        self.btn_stop.clicked.connect(self.btn_stop_clicked)
        self.btn_randomize.clicked.connect(self.btn_randomize_clicked)
        self.btn_reset.clicked.connect(self.btn_reset_clicked)
        self.btn_run_endless.clicked.connect(self.btn_run_endless_clicked)