xxxxxxxxxx
39
function setup() {
createCanvas(400, 400);
WebMidi
.enable()
//.then(() => console.log("WebMidi enabled!"))
.then(onEnabled)
.catch(err => alert(err));
}
function draw() {
background(220);
}
function onEnabled() {
// Inputs
WebMidi.inputs.forEach(input => console.log(input.manufacturer, input.name));
// Outputs
WebMidi.outputs.forEach(output => console.log(output.manufacturer, output.name));
const myInput = WebMidi.getInputByName("Akai MPK 49");
const mySynth = myInput.channels[1]; // <-- the MIDI channel (10)
myInput.addListener("noteon", e => {
console.log(e.note.identifier);
})
mySynth.addListener("noteon", e => {
console.log(e.note.identifier, e.message.channel);
})
let output = WebMidi.outputs[0];
let channel = output.channels[1];
channel.playNote("C3");
}