Created
February 23, 2016 18:26
-
-
Save dandaka/5c4853ac13325664c643 to your computer and use it in GitHub Desktop.
This file contains 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 hype.*; | |
HCanvas canvas; | |
HRect rect; | |
import themidibus.*; //Import the library | |
MidiBus myBus; // The MidiBus | |
int knobsNum = 8; | |
float knobValues[] = new float[knobsNum+1]; | |
void setup() { | |
size(640,640); | |
H.init(this).background(#242424); | |
MidiBus.list(); // List all available Midi devices on STDOUT. This will show each device's index and name. | |
myBus = new MidiBus(this, 0, 3); // Create a new MidiBus using the device index to select the Midi input and output devices respectively. | |
canvas = new HCanvas().autoClear(false).fade(5); | |
H.add(canvas); | |
canvas.add( rect = new HRect(10).rounding(5) ).noStroke().fill(#FF3300).rotate(45).stroke(#ffffff, 200); | |
} | |
void draw() { | |
rect.loc( (int)random(width), (int)random(height)); | |
rect.strokeWeight(knobValues[0]*45); | |
H.drawStage(); | |
} | |
void controllerChange(int channel, int number, int value) { | |
// Receive new value on knob modification | |
knobValues[number] = value/127.000; | |
print(channel + " - channel - "); | |
print(knobValues[number] + "\n"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment