Ejemplo n.º 1
0
def myLoadFunction(path, name):
    global conf, dataFile, out_port, in_port
    dataFile = path + "/" + INI_FILE
    if not os.path.exists(dataFile):
        return True, "Found no file to be loaded."

        return True, "Found no file to load."

    filehandler = open(dataFile, 'rb')
    conf = pickle.load(filehandler)
    window.setConfig(conf)
    conf.prettyPrint()

    #use JACK
    mido.set_backend('mido.backends.rtmidi/UNIX_JACK')

    # open midi port
    out_port = mido.open_output('Output', client_name='Fade Back (OUT)')
    logging.info("Outgoing port: {}".format(out_port))

    in_port = mido.open_input('Input', client_name='Fade Back (IN)')
    logging.info("Incoming port: {}".format(in_port))

    threading.Thread(target=inLoop, args=(in_port, out_port)).start()
    threading.Thread(target=outLoop, args=(out_port, )).start()

    return True, dataFile + " loaded!"
Ejemplo n.º 2
0
 def __init__(self,inPort,outPort,loopSize=4,measureSize=96):
   mido.set_backend('mido.backends.rtmidi')
   self.on=127
   self.off=0
   self.last = time.time()
   self.togStartStop = cc(0,self.on)
   self.muteAll = cc(127,self.on)
   self.notesOff = cc(123,self.off)
   self.reset=cc(126,self.on)
   self.midiIn = mido.open_input(inPort,callback=self.eventHandler)
   self.midiOut = mido.open_output(outPort)
   self.running=False 
   self.first=False
   self.ignoreFlag = False
   self.count=0
   self.realStart=False
   self.messages = {
     'clock' : self.clock
     ,'stop' : self.stop
     ,'start' : self.start
     ,'songpos' : self.songpos
     ,'continue' : self.cont
     ,'control_change': self.control_change
     ,'pitchwheel' : self.pitchwheel
   }
   
   self.eventList = {}
Ejemplo n.º 3
0
def mainthread():
    lastMidi = 0
    global out_port

    #use JACK
    mido.set_backend('mido.backends.rtmidi/UNIX_JACK')

    # open midi port
    out_port = mido.open_output('Output', client_name='Note On Scale (OUT)')
    logging.info("Outgoing port: {}".format(out_port))

    in_port = mido.open_input('Input', client_name='Note On Scale (IN)')
    logging.info("Incoming port: {}".format(in_port))

    while gRun:
        for msg in in_port.iter_pending():
            midi = msg.value
            channel = msg.channel
            if midi == lastMidi or midi == 0:
                continue

            # send_midi_message(midi)
            threading.Thread(target=send_midi_message,
                             args=(midi, channel, out_port)).start()
            lastMidi = midi
        time.sleep(0.1)
Ejemplo n.º 4
0
    def __init__(self):
        super(PySynth, self).__init__()

        self.instrument = []
        for i in range(0, NUM_INSTRUMENTS):
            self.instrument.append(Synth())
        self.p = pyaudio.PyAudio()
        self.buffer = np.empty(BUFFER_SIZE)
        mido.set_backend('mido.backends.rtmidi/LINUX_ALSA')

        # VARIABLES:
        self.cur = 0
        self.cur_keys = [0] * NUM_INSTRUMENTS
        self.cur_note = 0
        self.cur_freq = 0
        self.cur_vol = 0
        self.cur_pitch = 1
        self.semi_shift = 0
        self.global_vol = 128

        self.stream = self.p.open(format=pyaudio.paInt16,
                                  channels=1,
                                  rate=48000,
                                  output=True,
                                  stream_callback=self.audio_callback)
        self.stream.start_stream()

        self.inport = mido.open_input(mido.get_input_names()[0],
                                      callback=self.midi_callback)
Ejemplo n.º 5
0
    def capture(self):
        self.capturing = False
        self.final_tick = False
        # Start clocks at -1 to account for Circuit's leading clock message after start
        self.clocks = [-1, -1, -1]
        self.total_ticks = 0

        output_dir = os.path.dirname(self.output)
        if not os.path.exists(output_dir):
            os.makedirs(output_dir)

        mido.set_backend('mido.backends.rtmidi')

        with mido.MidiFile(type=1, ticks_per_beat=TICKS_PER_BEAT) as mid:
            # Create tracks
            self.tempo_map_track = mid.add_track(name=SONG_NAME)
            self.tracks = [mid.add_track(name="Synth 1"),
                mid.add_track(name="Synth 2"),
                mid.add_track(name="Drums")]

            # Set synth instruments
            self.tracks[CHANNEL_SYNTH1].append(mido.Message('program_change', program=PROGRAM_SYNTH1))
            self.tracks[CHANNEL_SYNTH2].append(mido.Message('program_change', program=PROGRAM_SYNTH2))

            with mido.open_input(self.input) as port:
                print("Push 'Play' to start capture.")
                for msg in port:
                    if not self.process_message(msg):
                        break

            self.capturing = False
            self.write_tempo_map()
            mid.save(self.output)

        print("All done!")
Ejemplo n.º 6
0
def detect_midi_device():
    """Returns the a MIDI device name. Looks for devices starting with 'USB', 'MIDI 1' or 'VMPK'.
    None otherwise.
    """
    midi_devices = []
    try:
        # Override default (portmidi) to use rtmidi. Note that portmidi
        # worked fine on RPI but rtmidi is faster and more portable in my experience
        # rtmidi had to be built directly on the RPI though
        mido.set_backend('mido.backends.rtmidi')
        midi_devices = mido.get_input_names()

    except ImportError:
        print("Could not load rtmidi. Try 'pip install python-rtmidi'")

    first_usb_device = next((x for x in midi_devices if 'USB' in x), None)

    if first_usb_device is None:
        print("Trying name 'MIDI 1'")
        first_usb_device = next((x for x in midi_devices if 'MIDI 1' in x),
                                None)

    if first_usb_device is None:
        print("Trying name VMPK")
        first_usb_device = next((x for x in midi_devices if 'VMPK' in x), None)

    return first_usb_device
 def __init__(
         self,
         # TODO for now just leave port_name as None, it seems like picking a
         # specific port is broken
         port_name=None,
         backend='mido.backends.portmidi'):
     mido.set_backend(backend)
     self._port = mido.open_output(port_name)
Ejemplo n.º 8
0
 def __init__(self):
     Thread.__init__(self)
     mido.set_backend('mido.backends.%s' % config['midi_backend'])
     avail_ports = mido.get_output_names()
     if config['midi_port'] and config['midi_port'] in avail_ports:
         self.port = mido.open_output(name=config['midi_port'])
     elif len(avail_ports):
         self.port = mido.open_output(name=avail_ports[0])
Ejemplo n.º 9
0
Archivo: io.py Proyecto: steveb/bogt
def set_backend(conf=None):
    if not conf:
        conf = {}
    backend = conf.get('backend', 'mido.backends.rtmidi')
    api = conf.get('api')
    if api:
        mido.set_backend('%s/%s' % (backend, api))
    else:
        mido.set_backend(backend)
Ejemplo n.º 10
0
 def __init__(self):
   super(MidiHandler,self).__init__()
   spec = Specs().s
   self.midiSpec = Hosts().getLocalAttr('midi')
   mido.set_backend(self.midiSpec['backend']) 
   self.name = "MidiHandler"
   self.running = True
   self.queue = Queue.Queue()
   self.portHandlers = []
Ejemplo n.º 11
0
 def __init__(self):
     self.openmidiinputs = self.scanIO()
     self.lpl.spanAudibleRange(FromScala.readSCL('22equal.scl'))
     #self.lpl.addFlatLattice()
     self.lpl.addFlatLattice(2, 3)
     self.lpl.openVirtualOuts()
     #default backend, written in C++, convenient for that transformation
     mido.set_backend('mido.backends.rtmidi')
     print(mido.backend)
Ejemplo n.º 12
0
    def __init__(self):
        # Register the settings widget
        AppSettings.register_settings_widget(MIDISettings)

        bk_name = config['MIDI']['Backend']
        try:
            # Load the backend and set as current mido backend
            mido.set_backend(mido.Backend(bk_name, load=True))
        except Exception:
            raise RuntimeError('Backend loading failed: {0}'.format(bk_name))
Ejemplo n.º 13
0
def main():
    mido.set_backend('mido.backends.rtmidi')
    try:
        code = cli.main()
        sys.exit(code)
    except KeyboardInterrupt:
        print()
        sys.exit(1)
    except cli.ConfigError as err:
        print(str(err), file=sys.stderr)
        sys.exit(1)
Ejemplo n.º 14
0
    def __init__(self):
        threading.Thread.__init__(self)
        self.exit = threading.Event()

        # Initialize the timekeeper
        self.timekeeper = 0
        # Set a baseline timestamp
        self.prev_time = time.time()
        # Set the mido backend
        mido.set_backend('mido.backends.' + gm_backend)
        # Open MIDI output
        self.gm_out = mido.open_output(gm_output)
Ejemplo n.º 15
0
 def __init__(self):
     QObject.__init__(self)
     mido.set_backend(
         'mido.backends.rtmidi/LINUX_ALSA'
     )
     print(
         "Using MIDI APIs: {}".format(
             mido.backend.module.get_api_names()
         )
     )
     self.velocity=0
     self.state=0
Ejemplo n.º 16
0
 def play(self):
     port_name = 'Microsoft GS Wavetable Synth'    #will need to pick up which port to use when used on different devices
     filename = 'assets/game/enemies/level_1.MID'    #use this to set which level is played
     
     mido.set_backend('mido.backends.pygame')
     with mido.open_output(port_name) as output:
         with MidiFile(filename) as midi_file:
             for message in midi_file.play():
                 if __main__.app.midi_thread.stopped_test():   #checks for stop thread flag
                     break
                 byte_message = message.bytes()
                 self.spawn_enemy(byte_message)
                 output.send(message) 
Ejemplo n.º 17
0
    def do_start_logging(self, midi_port_name):
        logging.info("start midi logging on {}".format(midi_port_name))

        self.do_stop_logging()
        MidiLogMessageHandler.midi_port_name = midi_port_name

        try:
            mido.set_backend('mido.backends.rtmidi/UNIX_JACK')
            MidiLogMessageHandler.mido_port = mido.open_input(
                self.midi_port_name, callback=self.on_midi_in)
        except:
            logging.error("Can't open MIDI Port {}".format(
                self.midi_port_name))
Ejemplo n.º 18
0
    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)
Ejemplo n.º 19
0
 def __init__(self):
     mido.set_backend('mido.backends.rtmidi')
     try:
         self.outport = mido.open_output('Ableton Push User Port')
     except IOError:
         pass
     self.dialLine = ["","","","","","","",""]
     self.statusLine = {}
     self.modeNames = ["grain", "sample", "loop", "pattern"]
     self.setNetMode(0)
     self.setMidiMode(0)
     self.thread = Thread( target = self.listenToMidi )
     self.thread.start()
     self.currentValues = {}
Ejemplo n.º 20
0
def setMidoBackend():
    """
        library mido sends MIDI 
        to some other application running;
        here we set to what;
    """
    if _platform == "linux" or _platform == "linux2":
        mido.set_backend('mido.backends.rtmidi')
    elif _platform == "darwin":
        # OS X
        pass
    elif _platform == "win32":
        # Windows
        pass
Ejemplo n.º 21
0
def build_midi_ports() -> (mido.ports.BaseInput, mido.ports.BaseOutput):
    mido.set_backend('mido.backends.rtmidi/UNIX_JACK')
    name_in = get_xtouch_port_in_name()
    if name_in is not None:
        pin = mido.open_input(name_in)
    else:
        pin = mido.open_input('xtouch-in', virtual=True, client_name='xtouchr')

    name_out = get_xtouch_port_out_name()
    if name_out is not None:
        pout = mido.open_output(name_out)
    else:
        pout = mido.open_output('xtouch-out',
                                virtual=True,
                                client_name='xtouchr')

    return pin, pout
Ejemplo n.º 22
0
def main_thread():
    #use JACK
    mido.set_backend('mido.backends.rtmidi/UNIX_JACK')

    # open midi port
    port = mido.open_output('Heartbeat', client_name='Heart Detector (OUT)')
    print('Using {}'.format(port))

    threading.Thread(target=sender_thread, args=(port, )).start()
    p = goConnectWithRetry(addr)

    while gRun:
        try:
            if p.waitForNotifications(3):
                continue
            else:
                window.setConnectionStatus("Time-out")
                logging.debug("TIMEOUT")
        except (btle.BTLEException):
            p = goConnectWithRetry(addr)
Ejemplo n.º 23
0
def process_midi():
    print('Available MIDI-in:', mido.get_input_names())
    mido.set_backend('mido.backends.rtmidi')

    inport = None
    try:
        inport = mido.open_input(CHANNEL)
    except Exception as exc:
        print(exc)
        sys.exit(1)

    hub = MidiProcessor(inport)
    try:
        hub.start()
    except Exception as exc:
        print(exc)
    finally:
        del hub
        inport.close()
        del inport
Ejemplo n.º 24
0
def initialize_MIDI_inout():
    """Initialize MIDI input and output ports using RTMIDI through mido

    We will go ahead and initialize all four of the input ports from the MIDIPLUS
    interface, plus the output port to the console.
    """

    # select rtmidi as our backend
    mido.set_backend('mido.backends.rtmidi')
    # print "Backend selected is %s " % mido.backend

    # Enumerate the available port names
    outports = mido.get_output_names()

    # Now try to pick the right port to output on.
    # If we're in the deployed configuration, it's a MIO adapter.
    outport = None
    for name in outports:
        if re.match(r'mio', name):
            try:
                outport = mido.open_output(name)
                break
            except:
                pass

    if not outport:
        print("Unable to open the MIO MIDI output port.")
        sys.exit(1)

    # Now locate the ports of the MIDIPLUS interface and open them for input.
    port_prefix = 'MIDI4x4.*:'
    inports = []
    for port in ('0', '1', '2', '3'):
        inports.append(open_midi_input_port(port_prefix + port))

    if len(inports) != 4:
        print("Unable to open MIDI input ports. Is the MIDIPLUS connected?")
        sys.exit(1)

    return (inports, outport)
Ejemplo n.º 25
0
def initialize_MIDI_out():
    """Initialize a MIDI output port using RTMIDI through mido
    """

    # select rtmidi as our backend
    mido.set_backend('mido.backends.rtmidi')
    # print "Backend selected is %s " % mido.backend

    # Enumerate the available port names
    outports = mido.get_output_names()

    # Now try to pick the right port to output on.
    # If we're in the deployed configuration, it's a MIO adapter, but
    # if we're in the lab, it might be something else.
    # In either event, there might be more than one matching adapter!
    # In that case, we'll punt and take the first one we find.
    out = None
    for name in outports:
        if re.match(r'mio', name):
            try:
                out = mido.open_output(name)
                break
            except:
                pass

    if not out:
        for name in outports:
            try:
                out = mido.open_output(name)
                break
            except:
                pass

    if not out:
        print("Sorry, unable to open any MIDI output port.")
        sys.exit(1)

    return out
Ejemplo n.º 26
0
    def __init__(self,
                 ticks_per_beat=480,
                 bpm=240,
                 output_file='new_song.midi',
                 backend='mido.backends.rtmidi',
                 port='IAC Driver Bus 1'):
        self.backend = backend
        self.output_file = output_file
        mido.set_backend(backend)
        self.port_name = port
        self.port = mido.open_output(port)

        self.channel_ids = [{x: -1} for x in range(16)]
        self.channels = []

        self.midi_file = MidiFile(
            type=1, ticks_per_beat=ticks_per_beat)  #beat set to eigth notes
        self.ticks_per_beat = ticks_per_beat
        self.quantization = [{
            f'1/{math.floor(8*x)}':
            math.floor(ticks_per_beat // x)
        } for x in [48, 24, 16, 12, 8, 4, 3, 2, 1.5, 1, 0.5, 0.25, 0.125]]
        self.bpm = mido.bpm2tempo(int(bpm))
Ejemplo n.º 27
0
    def __init__(self):
        QObject.__init__(self)

        mido.set_backend(
            'mido.backends.rtmidi/MACOSX_CORE'
        )

        print("\n~~~~ MIDI ~~~~")
        print("Backend: ", mido.backend)

        # detect whether user has tried to change devices
        self.newDevice = False


        # the midi devices must have different names for this to work
        if not mido.get_output_names():
            self.MIDI_in = "Virtual Port"
            self.isVirtual = True
            print("No MIDI device detected, using Virtual Port")
        else:
            # set midi port name to that of the first port available
            self.MIDI_in = str(mido.get_output_names()[0])
            self.isVirtual = False
            print("Device:", self.MIDI_in)
Ejemplo n.º 28
0
def scalezor_start():
    lastMidi = 0
    global out_port

    #use JACK
    mido.set_backend('mido.backends.rtmidi/UNIX_JACK')

    # open midi port
    out_port = mido.open_output('Output', client_name='Scalezor')
    print("Outgoing port: {}".format(out_port))

    in_port = mido.open_input('Input', client_name='Scalezor')
    print("Incoming port: {}".format(in_port))

    for msg in in_port:
        midi = msg.value

        if midi == lastMidi or midi == 0:
            continue

#		send_midi_message(midi)
        threading.Thread(target=send_midi_message, args=(midi, )).start()

        lastMidi = midi
Ejemplo n.º 29
0
class AlesisV25Device(object):

    mido.set_backend('mido.backends.portmidi')
    _PORT_PREFIX = "VMini"

    def __init__(self):
        for port in mido.get_input_names():
            if port.startswith(self._PORT_PREFIX):
                self._port = mido.open_input(port)
                break
        for port in mido.get_output_names():
            if port.startswith(self._PORT_PREFIX):
                self._outport = mido.open_output(port)
                break
        else:
            raise RuntimeError("Could not find a port named '%s'" %
                               self._PORT_PREFIX)

    def __del__(self):
        try:
            self.port.close()
        except:
            pass

    def _send(self, message):
        if not isinstance(message, SysexMessage):
            raise ValueError("Can only send a SysexMessage")
        p = mido.Parser()
        p.feed(message.serialize())
        self._outport.send(p.get_message())

    def _recv(self):
        while True:
            r = self._port.receive()
            if r.type == 'sysex':
                break
        return SysexMessage.deserialize(r.bin())

    def get_config(self):
        self._send(SysexMessage('query'))
        return self._recv().model

    def set_config(self, model):
        model_bin = model.serialize()
        self._send(SysexMessage('update', model))
        if self.get_config().serialize() != model_bin:
            raise RuntimeError('Failed to update configuration')
Ejemplo n.º 30
0
def sender_thread():
	while True:
		on = Message('note_on', channel=13, note=1, velocity=127)
        	port.send(on)
		time.sleep(gWaitTime)
		off = Message('note_off', channel=13, note=1, velocity=127)
		port.send(off)


# construct the argument parser and parse the arguments
ap = argparse.ArgumentParser()
args = ap.parse_args()

#use JACK
mido.set_backend('mido.backends.rtmidi/UNIX_JACK')

# open midi port
port = mido.open_output('Output', client_name='heart2MIDI')
print('Using {}'.format(port))

threading.Thread(target=sender_thread).start()


p = goConnectWithRetry('18:93:d7:4d:e4:03')

while True:
	try: 
		if p.waitForNotifications(3):
			continue
		else:
Ejemplo n.º 31
0
import lib.mpx1.debug_state as debug_state
import lib.mpx1.sysex as mpx1_sysex

## CONF

MIDO_BACKEND = 'mido.backends.pygame'

INPORT_LABEL = 'MidiSport 1x1 MIDI 1'
OUTPORT_LABEL = 'MidiSport 1x1 MIDI 1'

DEVICE_ID = 0x00

## INIT - MIDI

mido.set_backend(MIDO_BACKEND)

inport = mido.open_input(INPORT_LABEL)
outport = mido.open_output(OUTPORT_LABEL)

# outport.reset()


def cleanup_mido():
    inport.close()
    outport.close()


def handler(signum, frame):
    cleanup_mido()
Ejemplo n.º 32
0
import os
import signal

os.environ['PYGAME_HIDE_SUPPORT_PROMPT'] = "hide"
import mido

## INIT - MIDI

mido.set_backend('mido.backends.pygame')

inport = mido.open_input('MidiSport 1x1 MIDI 1')


def cleanup_mido():
    inport.close()


def handler(signum, frame):
    cleanup_mido()


signal.signal(signal.SIGHUP, handler)

## MAIN

try:
    for msg in inport:
        print("-----------------")
        print(msg)
        print(msg.hex())
except KeyboardInterrupt as e:
Ejemplo n.º 33
0
_DEFAULT_METRONOME_PROGRAM = 117  # Melodic Tom
_DEFAULT_METRONOME_MESSAGES = [
    mido.Message(type='note_on', note=44, velocity=64),
    mido.Message(type='note_on', note=35, velocity=64),
    mido.Message(type='note_on', note=35, velocity=64),
    mido.Message(type='note_on', note=35, velocity=64),
]
_DEFAULT_METRONOME_CHANNEL = 1

# 0-indexed.
_DRUM_CHANNEL = 9

try:
  # The RtMidi backend is easier to install and has support for virtual ports.
  import rtmidi  # pylint: disable=unused-import,g-import-not-at-top
  mido.set_backend('mido.backends.rtmidi')
except ImportError:
  # Tries to use PortMidi backend by default.
  tf.logging.warn('Could not import RtMidi. Virtual ports are disabled.')


class MidiHubError(Exception):  # pylint:disable=g-bad-exception-name
  """Base class for exceptions in this module."""
  pass


def get_available_input_ports():
  """Returns a list of available input MIDI ports."""
  return mido.get_input_names()

Ejemplo n.º 34
0
Install the 'Akai Internal MIDI Port' located within MPC directory
C:\Program Files\Akai Pro\MPC Essentials\support

In MPC Essentials, under Edit/Preferences/Midi set a Midi-Output 
to 'Akai Internal MIDI'.

Run script/exe in command window and then switch back to MPC
'''
import sys
import mido

print("MPC Key Check")
inport = None

mido.set_backend('mido.backends.rtmidi_python')
print(mido.get_input_names())

for port in mido.get_input_names():
  if port[:6]==b'Public':
    inport = port
    print("Using:", inport)
    break

if inport == None:
  sys.exit("Unable to find MPC 'Public'")

with mido.open_input(inport) as port:
  for message in port:
    print(message)
Ejemplo n.º 35
0
from threading import Thread

import mido
import pygame
from pygame import midi

import config
import music

# from pygame import midi

pygame.init()
midi.init()

print "using midi backend {}".format(config.mido_backend)
mido.set_backend(config.mido_backend)

path = os.path.realpath(__file__)
dir_path = os.path.dirname(os.path.realpath(__file__))

# noinspection PyUnresolvedReferences
input_names = mido.get_output_names()

REFACE = 'reface DX'
MPX = 'MPX16'
USB_MIDI = 'USB Midi'
SIMPLE_SYNTH = 'SimpleSynth virtual input'

CHANNEL_PARTITION = 8

VOLUME_MAX = 1.0
Ejemplo n.º 36
0
import pygame.midi
pygame.midi.init()

import mido
#print(mido.get_input_names())
mido.set_backend('mido.backends.pygame')

#inport = mido.open_input()
print( mido.get_input_names())
inport = mido.open_input()
Ejemplo n.º 37
0
"""
Try out the new printer port backend.

It also works with MIDO_BACKEND, so you can do:

    $ MIDO_BACKEND=printer python
    >>> import mido
    >>> mido.get_output_names()
    ['The Printer Port']
"""
import mido

mido.set_backend('printer')

print('Available outputs: {!r}'.format(mido.get_output_names()))

with mido.open_output() as port:
    print('Using {}.'.format(port))

    port.send(mido.Message('program_change', program=10))
    for i in [1, 2, 3]:
        port.send(mido.Message('control_change', control=1, value=i))
Ejemplo n.º 38
0
_DEFAULT_METRONOME_PROGRAM = 117  # Melodic Tom
_DEFAULT_METRONOME_MESSAGES = [
    mido.Message(type='note_on', note=44, velocity=64),
    mido.Message(type='note_on', note=35, velocity=64),
    mido.Message(type='note_on', note=35, velocity=64),
    mido.Message(type='note_on', note=35, velocity=64),
]
_DEFAULT_METRONOME_CHANNEL = 1

# 0-indexed.
_DRUM_CHANNEL = 9

try:
    # The RtMidi backend is easier to install and has support for virtual ports.
    import rtmidi  # pylint: disable=unused-import,g-import-not-at-top
    mido.set_backend('mido.backends.rtmidi')
except ImportError:
    # Tries to use PortMidi backend by default.
    tf.logging.warn('Could not import RtMidi. Virtual ports are disabled.')


class MidiHubError(Exception):  # pylint:disable=g-bad-exception-name
    """Base class for exceptions in this module."""
    pass


def get_available_input_ports():
    """Returns a list of available input MIDI ports."""
    return mido.get_input_names()

Ejemplo n.º 39
0
 def __init__(self, rnn):
     mido.set_backend('mido.backends.rtmidi')
     self.rnn = rnn
     self.thread = Thread( target = self.listenToMidi )
     self.thread.start()