Das "Musical Instrument Digital Interface" ist ein Protokoll das für den Umgang mit digitalen Instrumenten und Controllern entwickelt wurde.
Tools
- MIDI Monitor - Debugging Applikation für OSX.
- SimpleSynth - Einfacher Synthesizer.
Processing Beispiel
Für die Übergabe der Werte von Processing zu anderen Programmen über MIDI verwenden wir die Library “TheMidiBus” (http://www.smallbutdigital.com/themidibus.php). Die Library kann über den Library-Manager bequem installiert werden.
Folgend Ein Programm das eingehende Nachrichten ausgibt und ein Synthesizer per Maus und Tastatur steuert:
import themidibus.*; // MIDI Library importieren
MidiBus myBus; // Kontrollobjekt erstellen
int note, velocity;
void setup() {
size(800, 800);
background(0);
MidiBus.list(); // Liste aller Geräte ausgeben
myBus = new MidiBus(this, "PORT A", "SimpleSynth virtual input"); // "PORT A" als Input auswählen
}
void draw() {}
void mousePressed() {
note = int(map(mouseX, 0, width, 0, 127));
velocity = int(map(mouseY, 0, height, 0, 127));
myBus.sendNoteOn(0, note, velocity); // Note einschalten senden
}
void mouseDragged() {
myBus.sendNoteOff(0, note, velocity);
note = int(map(mouseX, 0, width, 0, 127));
velocity = int(map(mouseY, 0, height, 0, 127));
myBus.sendNoteOn(0, note, velocity); // Note ausschalten senden
}
void mouseReleased() {
myBus.sendNoteOff(0, note, velocity); // Note ausschalten senden
}
void keyPressed() {
myBus.sendControllerChange(0, 50, 64); // Controller change senden
}
void noteOn(int channel, int pitch, int velocity) {
// Eingehen Nachricht ausgeben
println("Note On: " + channel + " - " + pitch + " - " + velocity);
}
void noteOff(int channel, int pitch, int velocity) {
// Eingehen Nachricht ausgeben
println("Note Off: " + channel + " - " + pitch + " - " + velocity);
}
void controllerChange(int channel, int number, int value) {
// Eingehen Nachricht ausgeben
println("Controller Change: " + channel + " - " + number + " - " + value);
}