MIDI SysEx with TidalCycles

Hi, I'm writing a piece for live-coded organ. The pitch works with regular MIDI messages, but the organ stops are activated with SysEx. Does anyone know how I can send SysEx?

This is an example SysEx message I've sent to the organ that works via MIDI-Ox. 22 means turn the register on, and 5A is the number of the register:

F0 2B 01 01 22 00 5A 00 F7

image

from what I see in the definition of addMIDI, you should be able to write your own MIDI event, such as one using Sysex, which you would then call as a sound on Tidal

It would go something like this:

~midiOut = MIDIOut.new(0)

(
~sysexEvent = ( 
	play: #{
		var midiout = ~midiout.value;
		if(midiout.isNil) {
			~midiOutNotFoundError.throw
		};
		midiout.sysex(Int8Array[0xF0, 0x2B, 0x01, 0x01, 0x22, 00, 0x5A, 00, 0xF7]);
	} 
)
);

~dirt.soundLibrary.addMIDI(\mydevice, ~midiOut, ~sysexEvent);

Note that addMIDI can also take an appendToExisting argument, so you could have a single sysex sound and different messages on different n.

(
~sysexEvent2 = ( 
	play: #{
		// same as above but another message
	} 
)
);

~dirt.soundLibrary.addMIDI(\mydevice, ~midiOut, ~sysexEvent, false);
~dirt.soundLibrary.addMIDI(\mydevice, ~midiOut, ~sysexEvent2, true);

Note that I haven't tested this at all and it might not work. If it doesn't work as expected I'd suspect the events might need to implement the lag part of the default MIDI event:

Also note that Tidal technically can send an array of Word8 argument to SuperDirt so maybe you could send the sysex message entirely from Tidal but tbh if there's a specific set of sysex messages you can send it's probably easier to do it in a similar fashion as above