Search code examples
javascriptweb-midi

Sending a MIDI tuning request with the WebMIDI API results in error


I'm trying to send a MIDI tune request message (246 or 0xF6) with the Web MIDI API and I keep getting a Message is incomplete error in Chrome and Opera. Here is the problematic code:

navigator.requestMIDIAccess().then(function (interface) {

  var outputs = [];

  var iter = interface.outputs.values();
  for (var i = iter.next(); i && !i.done; i = iter.next()) {
    outputs.push(i.value);
  }

  outputs[0].send(246);
  
});

If I substitute the 246 for a similar message number that also does not require additional parameters (248, for example), it works without any problem.

Am I missing something obvious?


Solution

  • MIDI messages require a 3-byte array. Try this :

    outputs[0].send([246, 0, 0]);