예제 #1
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()
예제 #2
0
 def start(self):
     try:
         self.midiout = rtmidi.MidiOut()
         self.midiout.open_virtual_port(self.port_name)
         self.midiin.open_port(self.inport)
         self.midiin.callback = self.callback
     except KeyboardInterrupt:
         raise KeyboardInterrupt
     except:
         self.stop()
예제 #3
0
    def __init__(self, port):
        self.notes = _np.zeros((127, ), dtype=int)
        self.mask = _np.zeros((127, ), dtype=int)
        self.mask[60:90] = 1
        self.midiout = rtmidi.MidiOut()
        self.midiout.open_port()
        self.midiin = rtmidi.MidiIn('keyb', 1000)
        if isinstance(port, str):
            port = match_port(port)

        self.midiin.open_port(port)
        self.midiin.callback = self.callback
예제 #4
0
 def start(self):
     try:
         if self.outport:
             self.midiout = rtmidi.MidiOut()
             self.midiout.open_virtual_port(self.outport)
         else:
             self.midiout = DummyMidiOut()
         self.midiin.open_port(self.inport)
         self.midiin.callback = self.callback
     except KeyboardInterrupt:
         raise KeyboardInterrupt
     except:
         self.stop()
     return self
예제 #5
0
    def __init__(self):
        self.midi_in = rtmidi2.MidiIn()
        self.midi_out = rtmidi2.MidiOut()

        # Enable sysex return
        self.midi_in.ignore_types(midi_sysex=False)

        device_name = "Launchpad MK2"
        try:
            index = self.midi_in.ports_matching(device_name + "*")[0]
            self.midi_in.open_port(index)
            self.midi_out.open_port(index)
            print("Port opened.")
        except IndexError:
            raise (IOError("Port not found."))
예제 #6
0
파일: main.py 프로젝트: gaecom/twiz
 def build(self):
     # uncomment these lines to use profiling
     # if __name__ != '__main__':
     #     self.root = Builder.load_file('ble.kv')
     self.scanner = None
     self.init_ble()
     self.set_scanning(True)
     self.osc_socket = socket(AF_INET, SOCK_DGRAM)
     if rtmidi2:
         self.midi_out = rtmidi2.MidiOut().open_virtual_port(':0')
     Clock.schedule_interval(self.clean_results, 1)
     if '--simulate' in sys.argv:
         if NO_SIMULATE:
             raise NO_SIMULATE
         Clock.schedule_once(self.simulate_twiz, 0)
     return super(BLEApp, self).build()
예제 #7
0
 def start(self):
     self.inports = []
     for index in self.inport_indexes:
         port = rtmidi.MidiIn()
         port.open_port(index)
         port.callback = self.callback
         self.inports.append(port)
     self.outport = rtmidi.MidiOut()
     if self.outport_name:
         self.outport.open_virtual_port(self.outport_name)
     else:
         # check if we are doing a loop
         inportnames = get_ports()
         if get_outports()[0] in inportnames:
             self.outport_name = 'MERGE'
             self.outport.open_virtual_port(self.outport_name)
         else:  # open the default port
             self.outport.open_port()
예제 #8
0
import rtmidi2

print("##------------------------------ initialize-ports")

midi_in = rtmidi2.MidiIn().open_virtual_port("test-In-port")
midi_out = rtmidi2.MidiOut().open_virtual_port("test-Out-port")

print("#in-ports: ", rtmidi2.MidiIn().ports)
print("#out-ports: ", rtmidi2.MidiOut().ports)

print("##----------------------- import custom modules")
import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk, Gdk

import midisw.mididefs
import midisw.gtk3.piano

print("##------------------------------------ open port")

virt_out_port = midi_out.open_port()
last_pressed = None

print("##------------------------------------ def GUI and loop")


def do_note_on(widget, ev):
    global virt_out_port, last_pressed

    note = widget.get_note()
예제 #9
0
from collections import namedtuple as _namedtuple
import atexit as _atexit
import fnmatch as _fnmatch
from numbers import Number as _Number
import numpy as _np
import rtmidi2 as rtmidi

_INPORT_GLOBAL = rtmidi.MidiIn(clientname='tmp', queuesize=1000)
_OUTPORT_GLOBAL = rtmidi.MidiOut()
"""
Reference: these values should not be used as globals in a tight loop since there is
a global lookup involved. unless python has a way of inlining. use the value directly
"""

CC = 176
NOTEON = 144
NOTEOFF = 128


def match_port(portname: str):
    """
    return the index of the port matching the given port-name

    Example
    -------

    >>> get_ports()
    ['IAC Driver IAC Bus 1', 'Caps Lock Keyboard']
    >>> match_port('IAC*')
    0
    """
예제 #10
0
    def setUp(self):
        self.midi_out = rtmidi.MidiOut()
        self.midi_out.open_virtual_port(self.TEST_PORT_NAME)

        self.midi_in = rtmidi.MidiIn()
        self.midi_in.open_port(self.TEST_PORT_NAME)