Syntax for sending a MIDI sysex

Hey Folks!

So I’ve got this lovely APC40 mkii that I’d like to put into Ableton User Mode1, as opposed to the User Mode 0 that it starts in when Ableton isn’t running and connected to the device on start. This can be achieved by opening Bomes SendSX ( ) copying this string :

F0 47 00 29 60 00 04 41 08 04 01 F7

into the outgoing area and pressing “send”, works great, but obviously not as ideal as just opening my TD system and having it send that automatically. The 41 is the code for user mode 1 ( 40, 41 and 42 being the 3 modes)

So, I noodled around with the python sendExclusive method of the midiOutCHOP but I can’t seem to understand the format needed to send. it seems like i need to take the F0 and F7 hex codes, and send them as the start and end bytes of the message ( 0xF0 and 0xF7), and then encode the rest of the hex into a string as the “message” but having a hard time parsing that out. I think I don’t quite get the hex > bytes > string process…

Here is the script I have right now to try this, but no luck right now, can anyone advise?:

[code]import binascii
m = op(‘midiout1’)

startByte = 0xF0
endByte = 0xF7
msgHex = ‘47002960000441080401’
msgBytes = bytes.fromhex(msgHex)
msgString = msgBytes.decode(‘utf-8’)

m.sendExclusive(startByte, msgString, endByte)

print(startByte, endByte)

m.sendExclusive() already tacks the F0 and F7 onto the beginning and ends of your messages, so you don’t need to include startByte and endByte; or you can keep the start and end byte stuff and just use m.send() instead of m.sendExclusive() if you want.

For anyone wanting to play around with the apc40 mkII. Here is a small script to toggle different modes :

m = op("midiout1")
mode = 1

if mode == 0:
	### standard ableton mode
	m.sendExclusive(71, 1, 41, 96, 0, 4, 64, 8, 2, 7) 
elif mode == 1:
	### control over buttons / automated knobs
	m.sendExclusive(71, 1, 41, 96, 0, 4, 65, 8, 2, 7)
elif mode == 2:
	### full control
	m.sendExclusive(71, 1, 41, 96, 0, 4, 66, 8, 2, 7)
1 Like

Nice! This helped me out.

Thanks, this was very useful. Pulling my hair out why I couldn’t make it not flash green when I pressed a button.