Anybody figure out MIDI?

Anyone able to get midi to work? I haven’t been successful.

I haven’t found documentation on how to do it but here’s what I tried…

I assume we have to explicitly start midi

sapf> midiStart
midi sources 3 destinations 2
MIDI Source  0 'USB MIDI Device', 'USB MIDI Device' UID: 1663710136
MIDI Source  1 'IAC Driver', 'Bus 1' UID: -266997711
MIDI Source  2 'MidiKeys', 'MidiKeys' UID: -372221106
MIDI Destination  0 'USB MIDI Device', 'USB MIDI Device' UID: -1774984544
MIDI Destination  1 'IAC Driver', 'Bus 1' UID: -1619847629

Now if I send some midi CC messages and notes on IAC Driver Bus 1, channel 1 (confirmed by checking in MIDI Monitor), I try

sapf>1 1 mlastkey1
0
sapf>1 1 74 1 255 mctl1
1

Those values never change no matter what I try. Okay, maybe I have to use this midiConnectInput command?

sapf>1 1 midiConnectInput

Still same result when retrying mlastkey1 / mctl1.

Anyone know what I’m doing wrong?

Here’s what I see in MIDI Monitor:

Answering my own question…

The first argument to midiConnectInput needs to be the “UID” (the long number), NOT the “midi source number”:

-266997711 0 midiConnectInput

Once you’ve done that, use “0” for “srcIndex” in the various midi-related functions to access the input of that device.

Note that the “channel” parameter is 1-based , not 0-based (at least I think…)

1 Like