08 - MIDI
Prezentácia
Setup
Demo
Setup
Pridaj WEBMIDI.js cez CDN:
function setup() {
WebMidi.enable(function(err) {
if (err) {
console.log("WebMidi could not be enabled.", err);
} else {
console.log("WebMidi enabled!");
// Check if there are any MIDI inputs available
if (WebMidi.inputs.length < 1) {
console.log("No MIDI input devices found.");
} else {
let input = WebMidi.inputs[0]; // Use the first available MIDI input
console.log("Connected to:", input.name);
// Listen for noteOn events
input.addListener('noteon', "all", function(e) {
console.log("Note On -", e.note.name, e.note.octave, "Velocity:", e.velocity);
});
// Listen for noteOff events
input.addListener('noteoff', "all", function(e) {
console.log("Note Off -", e.note.name, e.note.octave, "Velocity:", e.velocity);
});
// Listen for controlChange events
input.addListener('controlchange', "all", function(e) {
console.log("Control Change - Controller:", e.controller.number, "Value:", e.value);
});
}
}
});
}
Key Concepts
MIDI Messages: MIDI communicates using messages. The most common ones include:
Note On/Off: Indicates when a key is pressed or released.
Velocity: Measures how hard a key is pressed.
Control Change: Modifies various parameters like volume, pitch bend, or instrument effects.
Channels and Instruments: MIDI supports 16 channels per device, each capable of controlling a different instrument or sound.
Nápady
MIDI controller vieme použiť už na ktorýkoľvek existujúci sketch.
Napr:
Random objekt + sample pre noteOn
Video sampler + midi
MIDI input cez webcam napr. pomocou ML5:
Last updated