Created
June 29, 2013 01:20
-
-
Save jordanorelli/5889236 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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