live incoming midi
in
Contributed Library Questions
•
2 years ago
I am trying to make a sketch that visualizes midi data sent from Ableton Live, using the proMidi library. Every midi note is represented by a little ball that moves across the screen. However, I can't seem to write it in a way as to have it deal well with the real-time and potentially infinite nature of the incoming midi data. I've been trying to do this by using ArrayList and adding objects on the fly, but I keep getting an "IndexOutOfBoundsException" error. Any ideas?
My code:
My code:
- import promidi.*;
MidiIO midiIO;
int notecount = 0;
List<Ball> balls;
void noteOn(
Note note,
int deviceNumber,
int midiChannel
){
pitch = note.getPitch();
notecount = notecount + 1;
}
void setup() {
size(640, 200);
noStroke();
smooth();
midiIO = MidiIO.getInstance(this);
println("printPorts of midiIO");
midiIO.printDevices();
midiIO.openInput(0,0);
balls = new ArrayList();
for (int i = 0; i < notecount; ++i) {
Ball freshBall = new Ball(width, pitch, 20);
balls.add(freshBall);
}
}
void draw()
{
background(0);
for (int i = 0; i < notenum; i++) {
Ball ball = (Ball) balls.get(i);
ball.display();
}
}
class Ball {
float x, y;
Ball(float xin, float yin) {
x = xin;
y = yin;
diameter = din;
}
void display() {
if (x > -50) {
x = x - 1;
}
fill(255, 204);
ellipse(x, y, diameter, diameter);
}
}
1