We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSound,  Music Libraries › putting my fft data inside an object
Page Index Toggle Pages: 1
putting my fft data inside an object (Read 1197 times)
putting my fft data inside an object
Aug 21st, 2009, 8:22am
 
Hello , im using the ess library , i been trying to calculate my fft data inside an object , but my code doesnt work, im getting the message arrayindexoutofboundsexception... Is there any special way of using this function when i put my fft inside an object?
public void audioInputData(AudioInput theInput) {
 myFFT.getSpectrum(myInput);
}

?

or any idea of what am i doing wrong?


here is the code:


Code:


import processing.opengl.*;
import codeanticode.glgraphics.*;
import javax.media.opengl.GL;
import krister.Ess.*;


AudioInput myInput;

fourier object_fourrier;

void setup()
{
size(384, 768);
Ess.start(this);
myInput=new AudioInput(512);
myInput.start();
object_fourrier = new fourier();
}

void draw()
{

background(250,0,0);
object_fourrier.fft();
print(object_fourrier.furier);

}
//public void audioInputData(AudioInput theInput) {
// fufi.getSpectrum(myInput);
// }

public void audioInputData(AudioInput theInput) {
object_fourrier.myFFT.getSpectrum(myInput);
}

class fourier{
float furier;
float[] fft;
//**************<FFT>******************
int bufferSize;
int steps;
float limitDiff;
int numAverages=32;
float myDamp=.1f;
float maxLimit,minLimit;
FFT myFFT;
AudioInput myInput;
//**************</FFT>******************



fourier() {
fft = new float[500];
Ess.start(fft_clase.this);
// set up our AudioInput

bufferSize=512;
myInput=new AudioInput(bufferSize);
// set up our FFT
myFFT=new FFT(bufferSize*2);
myFFT.equalizer(true);
// set up our FFT normalization/dampening
minLimit=0;
maxLimit=1;
myFFT.limits(minLimit,maxLimit);
myFFT.damp(myDamp);
myFFT.averages(500);
myInput.start();
}
void fft() {
audioInputData(myInput);
for (int i = 400; i<500 ; i++){
if (myFFT.spectrum[i]<0.1) furier = furier;
else furier += myFFT.spectrum[i];
}
furier = furier/100;
fft[499] = furier;
for (int j = 0; j < 499; j ++){
fft[j] = fft[j+1];
}
}


}




Re: putting my fft data inside an object
Reply #1 - Aug 21st, 2009, 1:41pm
 
> im getting the message arrayindexoutofboundsexception...

> any idea of what am i doing wrong?

you're not telling us where you're getting the error - the exception should give you a line number which will help track it down. (if that's not happening use a try / catch and print the stack trace in the catch)

normally it'd just be a case of running the code ourselves but i don't have half the libraries you're using so...
Re: putting my fft data inside an object
Reply #2 - Aug 21st, 2009, 9:47pm
 
hi i get the error in this line:
object_fourrier.myFFT.getSpectrum(myInput);

you dont need the libraries to try the code, i forget to delete the libraries, please try this one:

ps. you need to save you sketch as fot.pde

bye

Code:


import krister.Ess.*;


AudioInput myInput;

fourier object_fourrier;

void setup()
{
size(384, 768);
Ess.start(this);
myInput=new AudioInput(512);
myInput.start();
object_fourrier = new fourier();
}

void draw()
{

background(250,0,0);
object_fourrier.fft();
print(object_fourrier.furier);

}
//public void audioInputData(AudioInput theInput) {
// fufi.getSpectrum(myInput);
// }

public void audioInputData(AudioInput theInput) {
object_fourrier.myFFT.getSpectrum(myInput);
}

class fourier{
float furier;
float[] fft;
//**************<FFT>******************
int bufferSize;
int steps;
float limitDiff;
int numAverages=32;
float myDamp=.1f;
float maxLimit,minLimit;
FFT myFFT;
AudioInput myInput;
//**************</FFT>******************



fourier() {
fft = new float[500];
Ess.start(fot.this);
// set up our AudioInput

bufferSize=512;
myInput=new AudioInput(bufferSize);
// set up our FFT
myFFT=new FFT(bufferSize*2);
myFFT.equalizer(true);
// set up our FFT normalization/dampening
minLimit=0;
maxLimit=1;
myFFT.limits(minLimit,maxLimit);
myFFT.damp(myDamp);
myFFT.averages(500);
myInput.start();
}
void fft() {
audioInputData(myInput);
for (int i = 400; i<500 ; i++){
if (myFFT.spectrum[i]<0.1) furier = furier;
else furier += myFFT.spectrum[i];
}
furier = furier/100;
fft[499] = furier;
for (int j = 0; j < 499; j ++){
fft[j] = fft[j+1];
}
}


}



Page Index Toggle Pages: 1