How to use MIDIMAN controller to make ellipses
in
Integration and Hardware
•
2 years ago
So I am really new to Processing and I want to hook up my MIDIMAN controller to Processing. I have this code for making colored ellipses that fade. I want to connect this code to the keys on the MIDI but I can not figure out how to get Processing to recognize the controller. Is it difficult assigning certain keys on the controller to activate instances of objects? Here is my code that works with the mouse so far.
- ArrayList ballslist;
- void setup() {
- size(800, 800);
- smooth();
- noStroke();
- ballslist = new ArrayList();
- }
- void draw() {
- background(255);
- smooth();
- for (int i = ballslist.size()-1; i >= 0; i--) {
- BallClass dball = (BallClass) ballslist.get(i);
- dball.display();
- if (dball.finished()) {
- ballslist.remove(i);
- }
- }
- }
- void mousePressed() {
- int ballred = mouseX;
- int ballgreen = 100;
- int ballblue = mouseY;
- float ballalpha = 256;
- int ballwidth = int(random(20,80));
- ballslist.add(new BallClass(mouseX, mouseY, ballwidth, ballred, ballgreen, ballblue, ballalpha));
- }
- class BallClass {
- float x;
- float y;
- color ballColor;
- int Bred;
- int Bgreen;
- int Bblue;
- float Balpha;
- int BallWidth;
- BallClass(float tempX, float tempY, int tempball, int tempR, int tempG, int tempB, float tempA) {
- x = tempX;
- y = tempY;
- Bred = tempR;
- Bgreen = tempG;
- Bblue = tempB;
- Balpha = tempA;
- BallWidth = tempball;
- }
- boolean finished() {
- Balpha -= .5;
- if (Balpha < 1) {
- return true;
- }
- else {
- return false;
- }
- }
- void display() {
- ballColor = color(Bred, Bgreen, Bblue, Balpha);
- fill(ballColor);
- ellipse(x,y,BallWidth,BallWidth);
- fill(255, 255, 255);
- }
- }
1