Hi, I'm working on a project interpreting a live camera feed, with each image rendered off of the camera (30fps) I am sending 4 midi notes.
Sometimes it can run for 10 minutes or so, but eventually it will generate the following error:
Exception in thread "Thread-6" java.lang.ArrayIndexOutOfBoundsException: 40
at java.util.AbstractCollection.toArray(AbstractCollection.java:126)
at promidi.MidiOut$NoteBuffer.run(MidiOut.java:293)
I used to get a similar error but instead of ArrayIndexOutOfBoundsException, it used to be a NullPointerException. In both scenarios it was Exception in thread "Thread-6" and at promidi.MidiOut$NoteBuffer.run(MidiOut.java:293)
Here is the code for the sound executed each draw():
Code:
void generateSound() {
int[] brightnessAverages = getAverageBrightnessOfQuads();
int[] MIDIAverages = new int[4];
for(int i=0;i<brightnessAverages.length;i++)
{
MIDIAverages[i] = brightnessAverages[i] /2;
}
activeSum1 /= 19;
activeSum2 /= 19;
activeSum3 /= 19;
activeSum4 /= 19;
if(activeSum1 > 127) activeSum1 = 127;
if(activeSum2 > 127) activeSum2 = 127;
if(activeSum3 > 127) activeSum3 = 127;
if(activeSum4 > 127) activeSum4 = 127;
midiout.playNote(MIDIAverages[0],activeSum1,int(random(1000)));
midiout.playNote(MIDIAverages[1],activeSum2,int(random(1000)));
midiout.playNote(MIDIAverages[2],activeSum3,int(random(1000)));
midiout.playNote(MIDIAverages[3],activeSum4,int(random(1000)));
resetAverages();
}
Here is the code sending the note in my MIDIOut class:
Code:
public void playNote(int pitch, int velocity, int order) {
Note note = new Note(pitch, velocity, order);
midiOut.sendNote(note);
}
Some times it causes SimpleSynth to hang on a note and then it needs to re-started... Im not sure if that is a cause or effect.
Any ideas whats causing the crash?
thanks!