示例#1
0
# try to connect to the first device using MIDI protocol
remote_midi_device = ossia.MidiDevice("remoteMidiDevice", midi_devices[0])

# iterate on remote MIDI device namespace
#print("\nREMOTE MIDI DEVICE NAMESPACE")
#iterate_on_children(remote_midi_device.root_node)

# create a message queue to focus on a MIDI parameter
remote_midi_messageq = ossia.MessageQueue(remote_midi_device)
remote_midi_parameter = remote_midi_device.find_node("/1/control/32").parameter
remote_midi_messageq.register(remote_midi_parameter)

# MAIN LOOP
print("\nMAIN LOOP ...")
# observe all local device messages
local_device_messageq = ossia.GlobalMessageQueue(local_device)

# wait and change the value remotely
while True:

    message = remote_midi_messageq.pop()
    if message != None:
        parameter, value = message
        print("remote_midi_messageq : " + str(parameter.node) + " " +
              str(value))

    message = local_device_messageq.pop()
    if (message != None):
        parameter, value = message
        print("local_device_messageq : " + str(parameter.node) + " " +
              str(value))
import ossia_python as ossia
import time

dev = ossia.MinuitDevice("score-remote", "127.0.0.1", 6666, 9999)
dev.update()
globq = ossia.GlobalMessageQueue(dev)
while (True):
    res = globq.pop()
    while (res != None):
        parameter, value = res
        print("globq: Got " + str(parameter.node) + " => " + str(value))
        res = globq.pop()

    time.sleep(0.1)