Closed vibber closed 8 years ago
You have an error in your code. The third parameter is the MIDI output device you want to use. For instance, if you wanted to send the Control Change command to all channels of the first MIDI device, you would use:
WebMidi.sendControlChange(1, 127, WebMidi.outputs[0], "all");
I have my example from your article, so maybe you should correct your example in your article:
// Send control change value 127 to controller 1 (modulation) on channel
// 12 of all devices
WebMidi.sendControlChange(1, 127, "all", 12);
http://tangiblejs.com/posts/web-midi-music-and-show-control-in-the-browser
Thank you for getting back to me...
Oh, I see. Thanks for pointing it out. The example code has been fixed. Cheers!
There is still an error here. When I run the amended code, I get:
Uncaught (in promise) TypeError: WebMidi.sendControlChange is not a function.
The syntax you are using is from legacy version 1. If you are using version 2+ (which I recommend you do), please use the current syntax:
WebMidi.enable(function(err) {
if (err) console.log("An error occurred", err);
console.log(WebMidi.outputs);
WebMidi.outputs[0].sendControlChange("expressioncoarse", 123);
});
The latest documentation can be found here.
Aha. It's working now, yes! I think i did indeed have a version mismatch originally.
I tried this sample code:
but in a fresh Chrome (v49.0) it fails with the following message: Uncaught (in promise) ReferenceError: There is no such output device. webmidi.js 1380