Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Callback function fails if doesn't have short execution time #640

@stefanwebb

Description

@stefanwebb

Describe the bug
I send a sysex message to my Roland D-05 synthesizer to request a memory dump and intercept the MIDI input message with a callback function.

I've noticed that when the callback function contains any non-trivial code it doesn't finish running and the program can hang. Is this the intended behavior or am I doing something wrong?

To Reproduce
Here's the relevant bits of code:

def print_message(message):
    # Roland system exclusive messages
    if message.type == 'sysex' and message.data[0] == id_roland and message.data[2] == model_name_to_id['D-05']:
        channel = message.data[1]
        cmd = message.data[3]
        body = message.data[4:]

        print(cmd_to_str(cmd))

with mido.open_input('D-05', callback=print_message) as inport:
    with mido.open_output('D-05') as outport:
        outport.send(msg)
        input()

Expected behavior
The expected behavior is that this will print Data set 1, instead nothing is output.

If I change the print statement to print(message) then it outputs sysex data=(...) so I am definitely receiving a MIDI in sysex message.

Context (please complete the following information):

  • MacOS 26.2
  • Python 3.12.12
  • mido 1.3.3
  • backend used: python-rtmidi

Additional context
Experimenting with MIDI messages to program sounds on Roland synthesizers.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions