I'm currently working on an end of semester project and my project uses an AudioPlayer[] so that I can play multiple tracks at the press of a key. However, I'm trying to run an oscillator alongside the AudioPlayer[], but my current code for the oscillator lags my sketch to a snail's pace. Any suggestions on what I should do? My current code runs 70 different for loops to run the oscillator, I would like it to run easier.
for(int i = 0; i < playlist[1].bufferSize() - 1; i++){
float a1 = map(i,0,playlist[1].bufferSize(), 0, width);
float a2 = map(i+1,0,playlist[1].bufferSize(),0,width);
line(a1, height/2 + playlist[1].left.get(i)*100, a2, height/2 + playlist[1].left.get(i)*100);
line(a1, height/2 + playlist[1].right.get(i)*100, a2, height/2 + playlist[1].right.get(i)*100);
}
This is the current code I'm using with minim. There is 70 other of these loops in my sketch. Is there any way to make this code work for all 70 AudioPlayer[] arrays, in a shorter less laggy way?
I would post more of this code, but there are over 5000 lines of my sketch.