Sending Sysex in MIDI Remote API

Hi everyone

I’m totally confused. I am trying to send a sysex message to my control surface using the API.
Apparently I can only send it via the sendSysexFile method (note that sendMidi is not applicable because the timing is too fast and the message gets corrupted…)
But the messages I need to send are not constant: I cannot use pre-saved files.
I am assuming I am missing something, as I don’t see why we should have to use external files (especially in a js project!).
Anyone there to enlighten me ?
Thanks !!


You should use the sendMidi() method.

You can slow down the rate that sendMIDI sends by splitting the SysEx array into arrays and applying a delay between each? Wrap it into it’s own JS function and set the delay (ms) as a parameter to aid debugging it.

Knowing how your device prefers the data to be sent is of course the most important factor in this.

Be careful testing with the debug window open though, as that can cause the MIDI Remote to run a little slower than normal.

note that sendMidi is not applicable because the timing is too fast and the message gets corrupted

Enlighten us and tell us how that sysex looks or what this sysex should provide.
Martin is not wrong with his statement, i have seen it with my own eyes, that this works all the time, even on really timebased things like VU-meters. It should not be a problem.


As JS is single-thread, this would make the whole Remote thread frozen. Or am I wrong?

Single thread, but can be asynchronous too. I’ve not tried it with the MIDI Remote but in JS you can easily wrap a function within setTimeout() to break it down into separate stacks.

As long as you’re not expecting anything back, should be easy to do (in my mind at least lol).

i.e. AJAX calls have to be asynchronous, if not most websites would be causing your browser to pause as it fetches external lookups. Going async:false is very much frowned upon so asynchronous methods are a common staple of JS development.

Thank you all for your replies. I do appreciate :slight_smile:
I will double-check using sendMidi later today (not at my desk) and if I can’t make it work I will send you my code (which actually is based on a Martin’s example code…)

1 Like

OK… good news… :slight_smile:
It turns out the problem came from the MIDI Monitor app which I was using and gave me false results (incomplete sysex messages).
I did manage to use sendMidi to send sysex messages.
I do hope that the API will be expanded to provide better tools than the sendSysexFile method :wink:
In any case I will probably make a couple of videos to explain how to use the tools for non-programmers, as you only learn from examples with such tools…

1 Like

Could you post a code snippet please? I need to send a simple byte sequence to the controller to set it’s initial mode, but I can’t figure out the structure of the MidiMessage parameter that sendMIDI takes.

Hi @MrSoundman,

The MidiMessage parameter is a plain old JavaScript array of numbers.

deviceDriver.mOnActivate = function (activeDevice) {
   // just a stupid example of sending a note on and off again when the midi controller gets detected and activated in Cubase.
   midiOutput.sendMidi (activeDevice, [0x90, 64, 127])
   midiOutput.sendMidi (activeDevice, [0x00, 64, 0])

So I can just do something like this?

midiOutput.sendMidi (activeDevice, [0xf0, 0x7e, 0, 6, 1, 0xf7])


yes :+1:


If you want to send longer (init) SysEx Message, you can also do:

midiOutput.sendSysexFile(activeDevice, 'your_SYX_file.syx', 5)

From the documentation:

sendSysexFile (activeDevice : ActiveDevice, fileName : string, delayMilliseconds : number)

Then make the *.syx file with the SysEx message.

1 Like