Themidibus + python

Hey folks, I have the following code, but still can’t get the noteOn to be called (even though the note is played), did you manage to get it working?

add_library('themidibus')
    
def setup():
    global myBus
    size(400, 600)
    
    MidiBus.list()
    myBus = MidiBus(this, -1, "IAC_MIDI")

    
def draw():
    channel = 0
    pitch = 64
    velocity = 127

    myBus.sendNoteOn(channel, pitch, velocity)
    delay(2000)
    myBus.sendNoteOff(channel, pitch, velocity)
    
    
def noteOn(channel, pitch, velocity):
    print("here")
    print(channel)
    print(pitch)
    print(velocity)

EDIT: Just noticed that in order for the callbacks to work, we need to set an input on the MidiBus like MidiBus(this,"IAC_MIDI", "IAC_MIDI"). Now it’s working fine :sweat_smile:

EDIT 2: For some reason it just stopped working, so I still need help :confused:

EDIT 3: I noticed that it works when I first open processing, but if I stop my sketch and run again, it doesn’t work anymore.

2 Likes