Themidibus + python

Hi everyone —

I converted this java sample of themidibus in to python: https://github.com/sparks/themidibus/blob/master/examples/Basic/Basic.pde

I first made sure it worked with my midi device connected and responded in the java sample.

No technical issues in retooling the code but it won’t recognise any change in midi state. The main myBus object is recognised by printing in draw(). Looks like controllerChange() or notOn/Off() isn’t activating.

Is this a known bug? Any recommendations including alternative libs?

Thanks!!!

1 Like
2 Likes

Feck. The above info sounds beyond my knowledge at present.

Odd thing is it sometimes (after relaunching processing) gets as far as returning a callback print but stops short of the actual data - stops here: print("--------"). Then it seems to basically crash without crashing as nothing is called back. Then I have to relaunch processing to get that far again.

Do you know of any midi library tried and trusted in py mode?

SmallButDigital.com/docs/themidibus/index.html?themidibus/package-summary.html

1 Like

…so, according to that issue, jdf included MidiBus callback support in Processing.py in

The specific methods for noteOn / noteOff / controllerChange are at the bottom of the commit.

1 Like

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