Ejemplo n.º 1
0
 def midi_devices_loop():
     global prev_ports, first_loop
     while True:
         no_playing_sounds = False
         for channel in xrange(16):
             if not gv.playingnotes[channel + 1]:
                 no_playing_sounds = True
         if no_playing_sounds:  # only check when there are no sounds
             curr_ports = rtmidi2.get_in_ports()
             if (len(prev_ports) != len(curr_ports)):
                 print '\n==== START GETTING MIDI DEVICES ===='
                 midi_in.close_ports()
                 prev_ports = []
                 for port in curr_ports:
                     if port not in prev_ports and 'Midi Through' not in port and (
                             len(prev_ports) != len(curr_ports)
                             and 'LoopBe Internal' not in port):
                         midi_in.open_ports(port)
                         midi_in.callback = gv.midicallback.callback
                         if first_loop:
                             print 'Opened MIDI port: ' + port
                         else:
                             print 'Reopening MIDI port: ' + port
                 print '====  END GETTING MIDI DEVICES  ====\n'
             prev_ports = curr_ports
             first_loop = False
         time.sleep(0.5)
Ejemplo n.º 2
0
    def __init__(self):
        self._keyboard = Controller()

        self.in_ports = rtmidi2.get_in_ports()
        self.out_ports = rtmidi2.get_out_ports()

        self._midi_in = rtmidi2.MidiIn()
        self._midi_out = rtmidi2.MidiOut()
Ejemplo n.º 3
0
#            midi_in.append(rtmidi.MidiIn())
#            midi_in[-1].callback = MidiCallback
#            midi_in[-1].open_port(port)
#            print 'Opened MIDI: ' + port
#    previous = midi_in[0].ports
#    time.sleep(2)

stopit = False
midi_in = rtmidi2.MidiInMulti()
curr_ports = []
prev_ports = []
first_loop = True
while True:
    if stopit:
        break
    curr_ports = rtmidi2.get_in_ports()
    if (len(prev_ports) != len(curr_ports)):
        midi_in.close_ports()
        prev_ports = []
        for port in curr_ports:
            if port not in prev_ports and 'Midi Through' not in port and (
                    len(prev_ports) != len(curr_ports)):
                midi_in.open_ports(port)
                midi_in.callback = MidiCallback
                if first_loop:
                    print 'Opened MIDI port: ' + port
                else:
                    print 'Reopening MIDI port: ' + port
                    prev_ports = curr_ports
                    first_loop = False
                    time.sleep(2)
Ejemplo n.º 4
0
 def start(self):
     self._read_ticks_task = asyncio. async (self._read_ticks())
     #self._rtmin.open_virtual_port("RtMidi In Sync")
     print(rtmidi2.get_in_ports())
     print(rtmidi2.get_out_ports())
     self._rtmin.open_port(1)