DER FFT-ALGORITHMUS DEN ICH VERWENDE:
class Fft02{
public static void main(String[] args){
Transform transform = new Transform();
int sampleAnzahl=8000;
float sampleINFloat = 8000F;
final double seconds = 0.5;
AudioFormat audioFormat = new AudioFormat(AudioFormat.Encoding.PCM_SIGNED,sampleINFloat,8,1,1,sampleINFloat,false);
targetDataLIne Soundhandler = new targetDataLIne();
byte[] recArray = Soundhandler.getSound(audioFormat, seconds);
System.out.println("Case A");
double[] realInA=new double[sampleAnzahl];
int count=0;
for(int i = 0;i<recArray.length;i++)
{
//System.out.println(""+recArray[i]);
realInA[count] = recArray[i];
count++;
}
System.out.println("Case B");
double[] imagInA = new double[sampleAnzahl];
double[] realOutA = new double[sampleAnzahl];
double[] imagOutA = new double[sampleAnzahl];
transform.doIt(realInA,imagInA,2.0,realOutA,
imagOutA);
display(realOutA,imagOutA);
}//end main
//===========================================//
}//end class Fft02
//=============================================//
class Transform{
void doIt(double[] realIn,double[] imagIn,
double scale,double[] realOut,
double[] imagOut){
for(int cnt = 0;cnt < realIn.length;cnt++){
correctAndRecombine(realIn[cnt],
imagIn[cnt],
cnt,
realIn.length,
scale,
realOut,
imagOut);
}//end for loop
}//end doIt
//===========================================//
void correctAndRecombine(
double realSample,double imagSample,
int position,int length,double scale,
double[] realOut,double[] imagOut){
for(int cnt = 0; cnt < length; cnt++){
double angle =
(2.0*Math.PI*cnt/length)*position;
realOut[cnt] +=
realSample*Math.cos(angle)/scale;
imagOut[cnt] +=
realSample*Math.sin(angle)/scale;
realOut[cnt] -=
imagSample*Math.sin(angle)/scale;
imagOut[cnt] +=
imagSample*Math.cos(angle)/scale;
}//end for loop
}//end correctAndRecombine
}//end class transform