Sending Sysex messages to a midi controller


#1

Hi,
I have a Novation Launch Control who’s LED’s I am trying to control. Based on the documentation for the controller, I should be able to turn my first button red with the following sysex messages:

240, 0, 32, 41, 2, 10, 120, 8, 0, 15, 247

When I first start my SC server, I do a:

MIDIClient.init

… Which gives me this:

MIDI Sources:

MIDIEndPoint("System", "Timer")

MIDIEndPoint("System", "Announce")

MIDIEndPoint("Midi Through", "Midi Through Port-0")

MIDIEndPoint("Launch Control", "Launch Control MIDI 1")

MIDIEndPoint("io|2", "io|2 MIDI 1")

MIDIEndPoint("SuperCollider", "out0")

MIDIEndPoint("SuperCollider", "out1")

MIDIEndPoint("SuperCollider", "out2")

MIDI Destinations:

MIDIEndPoint("Midi Through", "Midi Through Port-0")

MIDIEndPoint("Launch Control", "Launch Control MIDI 1")

MIDIEndPoint("io|2", "io|2 MIDI 1")

MIDIEndPoint("SuperCollider", "in0")

MIDIEndPoint("SuperCollider", "in1")

MIDIEndPoint("SuperCollider", "in2")

MIDIEndPoint("SuperCollider", "in3")

MIDIEndPoint("SuperCollider", "in4")

So my novation is listed in the destinations, I then try the following code to turn on the red LED based on the documentation:

var lc; lc = MIDIOut.newByName("Launch Control","Launch Control MIDI 1"); lc.sysex(Int8Array[ 0xF0, 0, 32, 41, 2, 10, 120, 8, 0, 15, 0xF7 ]);

I’ve also tried the following, based on the documentation saying the latency being set above zero creates problems in linux:
var lc; lc = MIDIOut.newByName("Launch Control","Launch Control MIDI 1"); lc.latency = 0; lc.sysex(Int8Array[ 0xF0, 0, 32, 41, 2, 10, 120, 8, 0, 15, 0xF7 ]);

And finally I’ve tried removing the beginning and end sysex flags like so:
var lc; lc = MIDIOut.newByName("Launch Control","Launch Control MIDI 1"); lc.sysex(Int8Array[ 0, 32, 41, 2, 10, 120, 8, 0, 15 ]);

I recieve no errors, and the device does nothing. I don’t think it’s my device, can anyone see something wrong with my code? I am new to supercollider


#2

Most likely there’s a problem with the contents of the sysex.
You definitely need to keep the 0xf0 and 0xf7.

In one document I found online (but maybe it’s not the same controller you have), I saw a difference in one of the bytes in the sysex (where you use 10, the document uses 0x11=17).


#3

Ok,
Thanks for letting me know that I need those sysex headers and enders.
First off, I have a launchcontrol (not XL). I’ve posted the MIDI reference which refers to my actual device:

I tried your above code anyway (since mine did not work) to no avail. I’ve also cycled through the factory template button over 7 times, running the command each time (to make sure that the device is on the template being defined by the sysex message)

Am I suppose to be doing any aconnect stuff after launching SuperCollider? The fact that SuperCollider is reporting the device on the MIDIOut.init command, I assumed that SuperCollider is automatically interacting with the midi device. But I have to use aconnect on other programs, so let me know if I need to do any of that action.


#4

Ok, so in the attempt to debug, I tried to see if SuperCollider would read any input. I’ve tried the following line of code:
var lc; lc = MIDIIn.connectAll(true); lc.noteOn({ arg uid, midich, keynum, velocity; "some midi messages came in".postln; });

After waiting a second, the console prints this (consistent with the “verbose mode” thing described in the documentation):

MIDI Sources:
MIDIEndPoint("System", "Timer")
MIDIEndPoint("System", "Announce")
MIDIEndPoint("Midi Through", "Midi Through Port-0")
MIDIEndPoint("Launch Control", "Launch Control MIDI 1")
MIDIEndPoint("io|2", "io|2 MIDI 1")
MIDIEndPoint("2PedalPiano1.0", "2PedalPiano1.0 MIDI 1")
MIDIEndPoint("SuperCollider", "out0")
MIDIEndPoint("SuperCollider", "out1")
MIDIEndPoint("SuperCollider", "out2")
MIDIEndPoint("SuperCollider", "out3")
MIDI Destinations:
MIDIEndPoint("Midi Through", "Midi Through Port-0")
MIDIEndPoint("Launch Control", "Launch Control MIDI 1")
MIDIEndPoint("io|2", "io|2 MIDI 1")
MIDIEndPoint("2PedalPiano1.0", "2PedalPiano1.0 MIDI 1")
MIDIEndPoint("SuperCollider", "in0")
MIDIEndPoint("SuperCollider", "in1")
MIDIEndPoint("SuperCollider", "in2")
MIDIEndPoint("SuperCollider", "in3")
MIDIEndPoint("SuperCollider", "in4")
MIDIEndPoint("SuperCollider", "in5")
-> nil

If I press any of the pad buttons on the Launch Control I get nothing. Furthermore, I also tried hitting notes on my “2PedalPiano1.0”, and got nothing (I have used that piano many times on other software on the same system). Assuming that I typed the code correctly, it seems to me that SuperCollider is not communicating at all with any of my midi devices, despite being able to list the names correctly of my device. Do I need to do some aconnect stuff?


#5

OK,
Update: I got the standard midi input to work from both my midi keyboard and the Novation launch control. I was using the command line sclang, and didn’t have the proper server boot and midiclient initialization in the code block.
Here is my current code:

s.waitForBoot{ 
    var lc, on;
    MIDIClient.init;
    lc = MIDIOut.newByName("Launch Control","Launch Control MIDI 1");
    lc.connect;
    lc.sysex(Int8Array[ 240, 0, 32, 41, 2, 10, 120, 8, 0, 15, 247 ]);
    MIDIIn.connectAll;
    on = MIDIFunc.noteOn({ |veloc, num, chan, src|
	    "Some midi note was pressed".postln;
    });	
}

So, upon running this, the midi input stuff sends the messages it’s suppose to on my keyboard and launch control. However, the systemex message is still not lighting up the button as it is suppose to. You can see that I’ve added lc.connect, I am not sure that is necessary, but I am trying everything I can. Anyone see anything wrong with this code, or anything missing? I will keep posting updates until I find a resolution, in the event that more people on the internet can’t find a solution and can use google to find my (hopefully) eventual resolution.