midi in problems

edited February 2016 in Library Questions

Hi, I want to visualize some music, coming in to processing from ableton. The idea is: I would like to make circles for each note received, using pitch for it's x value from the point of origin, and velocity for it's radius, then rotate the whole thing around to form a circle.

The whole thing works cool, but:

-somehow other circles start to appear for some reason that I don't want.

-it would be nice to avoid the delay as like this some notes are missed, but without it nothing appears.

-can't export pdf because of unknown exception. (image works) (???)

here is the code and image

thanks for your help!

import themidibus.*;
import processing.pdf.*;

boolean record=false;

MidiBus myBus; // The MidiBus

void setup() {
  size(800, 800);
  background(255);

  MidiBus.list();
  myBus = new MidiBus(this, 1, 0);

}
float x;
float y;
float t;
float time;

void draw() {
  if (record) {
    save("pic.tif");
    record = false;
  }
  t = millis()/10000.0f;
  delay(10);

}
void noteOn(int channel, int pitch, int velocity) {
  // Receive a noteOn
  float velo = map (velocity, 0, 127, 1, 20);
  translate(400, 400);
  rotate(t);
  translate(10,0);
  fill(255,0);
  ellipse(50+(pitch*3), 0, velo, velo);
  println(t);
}

void noteOff(int channel, int pitch, int velocity) {
  // Receive a noteOff
}

void controllerChange(int channel, int number, int value) {
  // Receive a controllerChange
}

void delay(int time) {
  int current = millis();
  while (millis () < current+time) Thread.yield();
}

void keyPressed() {
  if (key == 'q') {
    record=true;
  }
}

(

Answers

Sign In or Register to comment.