spatialaudio / jackclient-python

🂻 JACK Audio Connection Kit (JACK) Client for Python :snake:
https://jackclient-python.readthedocs.io/
MIT License
135 stars 26 forks source link

Jack keeps sending last MIDI messages #103

Closed polygon closed 3 years ago

polygon commented 3 years ago

I am trying to send MIDI messages using jackclient-python and I am seeing the issue that JACK repeats outgoing messages. I've managed to break this down to this minimal example:

import jack

cl = jack.Client('Test')
mo = cl.midi_outports.register('p2')
sent = False

@cl.set_process_callback
def process(frames):
    global sent
    if not sent:
        mo.write_midi_event(1, b'\x80\x2f\x32')
        mo.write_midi_event(2, b'\x80\x2f\x33')
        print("Sent!")
        sent = True

with cl:
    input()

The write_midi_event code is indeed only called once, but when I attach a MIDI analyzer (midisnoop in my case) I see that the two messages are rapidly repeated:

image

Am I doing something wrong here in the usage of the library?

polygon commented 3 years ago

Of course I find out about clear_buffer five minutes after posting this :)