Hello, I tried to contact Krister directly but his email is not valid, so I am posting my issue here in the event that anyone has any ideas.
I am making a music visualizer using Krister's Ess library and his Input FFT class. Every so often, the program throws an error. I am pretty sure that the error being thrown in my patch comes from his end in the myFFT.getSpectrum(myInput) class. The error that the Processing throws is: ArrayIndexOutOfBounds Exception: 4096 . The code is copied below.
Thank you very much!
----------- BEGIN CODE--------------
class InputFFTAnalysis
{
FFT myFFT;
FFT levelFFT;
AudioInput myInput;
int bufferSize;
int steps;
float limitDiff;
int numAverages=32;
float myDamp=.1f;
float maxLimit,minLimit;
float wavesamples[];
float frequency[];
float frequencies;
float level;
float getDamp;
float sum_total;
float sum[];
float sum_16;
float sum_32;
float sum_48;
float sum_64;
float sum_80;
float sum_96;
InputFFTAnalysis()
{
// set up our AudioInput
bufferSize=512;
myInput=new AudioInput(bufferSize*4); //
// set up our FFT
myFFT=new FFT(bufferSize*2); // 512*2 = 1024
levelFFT=new FFT();
myFFT.equalizer(true);
wavesamples=new float[512];
frequency=new float[512];
frequencies = 0;
level = 0;
sum = new float[24];
// set up our FFT normalization/dampening // **** WHAT DOES THIS DO in actuality? ***
minLimit=.005;
maxLimit=.05;
myFFT.limits(minLimit,maxLimit);
myFFT.damp(myDamp); // .1f
myFFT.averages(numAverages); // 32
// get the number of bins per average
steps=bufferSize/numAverages; // 512/32 = 16
// get the distance of travel between minimum and maximum limits
limitDiff=maxLimit-minLimit; // .05 - .005
myInput.start();
}
void UpdateData()
{
// draw the waveform
// time it takes for music to start? / length of song? * 512?
int interp=(int)max(0,(((millis()-myInput.bufferStartTime)/(float)myInput.duration)*myInput.size)); // what does this translate to in actuality?
// Does this number change or is it instanitated one time only?
// for example 1 millli sec/ 180 million sec * 512 = .00284
for (int i=0;i<bufferSize;i++) { //for i up to 512
float wave=0;
if (i+interp+1<myInput.buffer2.length) {
wave-=myInput.buffer2[i+interp]*1000.0;
}
wavesamples[i]=wave;
}
myFFT.getSpectrum(myInput); //*******THIS IS WHERE THE ARRAY OUT OF BOUNDS COMES FROM!!
Hi, I am needing to access variables from different classes in a several tabbed processing program. I do not know how to use the data I am generating in an FFT analysis (inputFFAnalysis) to effect the background variables in main tab that has void setup(). Also, I tried to separate a Knob class (not sure if properly, but does not seem to be throwing errors), which I can also use to effect the base color values for the background. Does anyone know how I can manipulate the code to use the data in separate areas of the program? Thank you!
Below is most of the MAIN tab:
-----------------------------
import krister.Ess.*;
import controlP5.*;
UFDWlib dw;
ControlP5 cp5;
Knob myKnobA;
Knob myKnobB;
Knob myKnobC;
InputFFTAnalysis sound;
Ground myground;
//Tree mytrees[];
int num_of_trees=10;
// draw the waveform //waveform is how loud the sound is?
stroke(255,0,0); // time it takes for music to start? / length of song? * 512?
int interp=(int)max(0,(((millis()-myInput.bufferStartTime)/(float)myInput.duration)*myInput.size)); // what does this translate to in actuality?
// Does this number change or is it instanitated one time only?
// for example 1 millli sec/ 180 million sec * 512 = .00284
for (int i=0;i<bufferSize;i++) { //for i up to 512
float left=160; // what does the left and right stuff meen?
float right=160;
float wave=0;
if (i+interp+1<myInput.buffer2.length) {
left-=myInput.buffer2[i+interp]*50.0;
right-=myInput.buffer2[i+1+interp]*50.0;