xxxxxxxxxx
47
let midiOut;
let note;
function setup() {
createCanvas(400, 400);
}
function draw() {
background(220);
}
WebMidi.enable(function (err) {
if (err) {
console.log("WebMidi could not be enabled.", err);
} else {
console.log("WebMidi enabled!");
}
});
WebMidi.enable(function (err) {
console.log(WebMidi.inputs);
console.log(WebMidi.outputs);
midiOut = WebMidi.getOutputByName("IAC Driver Bus 1");
});
function mousePressed(){
note = int(map(mouseX,0,width, 36, 100));
midiOut.playNote( note, 1);
console.log(note);
}
function mouseReleased(){
midiOut.stopNote(note, 1);
}