Problem with ArrayIndexOutOfBoundsException: 14
in
Programming Questions
•
7 months ago
Hi, I´m newer in processing and I have some problems with a code, if someone could help me, the problem is that when I run the code works once, and then appears a message of ArrayIndexOutOfBoundsException: 14, I want to comunicate with the Arduino, so I need the pitches, Thanks
import arb.soundcipher.*;
import arb.soundcipher.constants.*;
import processing.serial.*; //llama a todas las intruccionnes con todas las extenciones
Serial mipuerto; // declaramos el puerto serial para abilitar el puerto donde se le enviara informacion a arduino esto es una variable de tipo serial
SoundCipher part1 = new SoundCipher(this);
float[] pitches = {69, 69, 76, 76, 78, 78, 76, 74, 74, 73, 73, 71, 71, 69};
float[] dynamics = new float[pitches.length];
float[] durations = {1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 2};
float y;
int n = 0;
float xLoc = 0.0;
boolean test = false;
void setup(){
println(Serial.list());
String Puerto = Serial.list()[1];
mipuerto = new Serial(this,Puerto,9600);
for (int i=0; i<pitches.length; i++) {
dynamics[i] = random(40) + 70;
}
background(0);
size(640, 360);
stroke(255);
frameRate(2);
}
void draw()
{
if (n >= pitches.length) {
n = 0;
}
if (xLoc > width) {
background(0);
xLoc = 0.0;
}
line(xLoc, height-3*pitches[n], xLoc + 15.0 , height-3*pitches[n]);
part1.playNote(pitches[n], dynamics[n], durations[n]);
n += 1;
xLoc += 20.0;
int newNotas = int(pitches[n]);
mipuerto.write(newNotas);
println(newNotas);
}
1