Skip to content

Instantly share code, notes, and snippets.

@jordanorelli
Created June 29, 2013 01:20
Show Gist options
  • Save jordanorelli/5889236 to your computer and use it in GitHub Desktop.
Save jordanorelli/5889236 to your computer and use it in GitHub Desktop.
import themidibus.*;
MidiBus myBus;
int y = 0;
int vel = 0;
void setup() {
size(1024, 768);
background(0);
myBus = new MidiBus(this, 0, -1);
}
void draw() {
background(0);
float ny = pow(norm(y, 36, 98), 2) * height;
stroke(255, 255, 255, vel);
strokeWeight(norm(vel, 0, 127) * 40);
line(0, height - ny, width, height - ny);
}
void noteOn(int channel, int pitch, int velocity) {
y = pitch;
}
void controllerChange(int channel, int number, int value) {
if (channel == 0 && number == 2) {
vel = value * 2;
return;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment