Example #1
0
 def getDeviceList(self):
     midiin = MidiIn()
     midiout = MidiOut()
     try:
         return (midiin.get_ports(), midiout.get_ports())
     except Exception as e:
         if DEBUG == True:
             print(e)
         return False
Example #2
0
 def list_ports():
     midi_in = None
     midi_out = None
     try:
         api_out = MidiOut()
         api_in = MidiIn()
         ports = api_in.get_ports()
         return ports
     except:
         print("Unable to open MIDI ports")
     return
Example #3
0
def read_midi():
    alsa_midi = MidiIn(API_LINUX_ALSA)
    print(alsa_midi.get_ports())
    selected_port = int(input("Select port: "))
    with alsa_midi.open_port(selected_port) as open_port:
        timer = time.time()
        try:
            while True:
                message = open_port.get_message()
                if message:
                    message, deltatime = message
                    timer += deltatime
                    print(" @%0.6f %r" % (timer, message))
                    print(message)
        except KeyboardInterrupt:
            print('')
        finally:
            print("Exit.")
Example #4
0
def get_ports(port_name: str,
              *,
              clock_source: bool = False) -> Tuple[MidiIn, MidiOut]:
    midi_in = MidiIn()
    midi_out = MidiOut()
    midi_in_ports = midi_in.get_ports()
    midi_out_ports = midi_out.get_ports()
    try:
        midi_in.open_port(midi_in_ports.index(port_name))
    except ValueError:
        raise ValueError(port_name) from None

    if clock_source:
        midi_in.ignore_types(timing=False)
    try:
        midi_out.open_port(midi_out_ports.index(port_name))
    except ValueError:
        raise ValueError(port_name) from None

    return midi_in, midi_out
Example #5
0
            if name == 'data':
                vars(self)['data'] = SysexData(value)
            else:
                vars(self)[name] = value

    __setattr__ = _setattr

    def bytes(self):
        """Encode message and return as a list of integers."""
        return encode_message(vars(self))


midi_in = MidiIn()
midi_out = MidiOut()

in_ports = midi_in.get_ports()
out_ports = midi_out.get_ports()

print("IN ports:", in_ports)
print("OUT ports:", out_ports)

def call_obs_api(command='pause-toggle'):
    url = f'http://localhost:28000/{command}'
    print("Calling:", url)
    response = requests.get(url).json()
    print("OBS RESPONSE:", response)


def __callback(msg_data, data):
    print("GOT DATA")
    note_in = Message.from_bytes(msg_data[0])