X-posted from here
Hi all, I'm using the spectrum data from an FFT i'm performing to control the speed of the audio file as well as the delay between frames being drawn. This is what creates the avg. The issue is that i'm not sure how to make this work for a range of different files. Sometimes there'll be 1440 frames to play, othertimes there's 1700 and the audio is similarly varied.
How can a build this so that it'll always playback in the right amount of time, which is currently 1 minute but could be 2 or 3.
Thanks.
Apologies for the state of the code.
Full project here
A folder that the program needs to process here
FFT function was taken from here
code snippet that i'm using to control the playback and delay:
if (tConnectSound) {
if (avg > height/6+height/6*4 && avg < height) {
//rateControl.value.setLastValue(frameSkipLoad/32);
cp5.getController("sDelay").setValue(frameSkipLoad/32);
}//
else if (avg > height/6+height/6*3 && avg < height/6+height/6*4) {
//rateControl.value.setLastValue(frameSkipLoad/16);
cp5.getController("sDelay").setValue(frameSkipLoad/16);
}//
else if (avg > height/6+height/6*2 && avg < height/6+height/6*3) {
//rateControl.value.setLastValue(frameSkipLoad/8);
cp5.getController("sDelay").setValue(frameSkipLoad/8);
}//
else if (avg > height/6+height/6 && avg < height/6+height/6*2) {
//rateControl.value.setLastValue(frameSkipLoad/4);
cp5.getController("sDelay").setValue(frameSkipLoad/4);
}//
else if (avg > height/6 && avg < height/6+height/6) {
//rateControl.value.setLastValue(frameSkipLoad/2);
cp5.getController("sDelay").setValue(frameSkipLoad/2);
}//
else if (avg > 0 && avg < height/6) {
//rateControl.value.setLastValue(frameSkipLoad);
cp5.getController("sDelay").setValue(frameSkipLoad);
}
delay = cp5.getController("sDelay").getValue();
}