cielle wrote:You mystify me! All I did was to go to towards the root of the web page YOU posted!
I have tried to download the jar file from the Webpage that u shown me..
Now can import the package already...My advice - stop right now. You don't have the Java and maths and signal processing and software engineering and research and study skills to do this project. To do this project you needs some basic background knowledge. You need to understand basic Java. You need to understand basic Java sound. You need to understand basic complex numbers. You need to understand basic signal processing. You don't need to be an expert at any of these but you MUST MUST MUST have a basic understanding of all of them. You don't seem to have a basic understanding of any of them and don't seem to be willing to obtain any understanding by studying. You are just thrashing around and have re-enforced my view that those posting here about how to use an FFT for processing sound are just far to far outside of their comfort zone.
And now working on how to use the fft and hamming features that are provided by Minim...
Hope to have your advise later on...
void correctAndRecombine(
double realSample,double imagSample,
int position,int length,double scale,
double[] realOut,double[] imagOut){
//Calculate the complex transform values for
// each sample in the complex output series.
for(int cnt = 0; cnt < length; cnt++){
double angle = (2.0*Math.PI*cnt/length)*position;
//Calculate output based on real input
realOut[cnt] += realSample*Math.cos(angle)/scale;
imagOut[cnt] += realSample*Math.sin(angle)/scale;
//Calculate output based on imag input
realOut[cnt] -= imagSample*Math.sin(angle)/scale;
imagOut[cnt] += imagSample*Math.cos(angle)/scale;
}//end for loop
}//end correctAndRecombine
I noticed that the result from this algorithm sometimes has the sign difference between the MATLAB result.. The magnitude is the same...诸葛 wrote:That is not an FFT! It is a Discrete Fourier Transform (DFT) implementation using just about the most inaccurate and slow approach possible.
1) Belwo is the FFT algorthm that i am studying...
诸葛 wrote:There are mixed radix FFT out there! For example, mine allows mixed radix 2,3 and 5. The C FFT implementation FFTW can transform any number of data points. You could always write a JNI wrapper for FFTW if you really do need to transform any number of data points but I doubt if you need to. I can't be sure because I don't have access to your project requirements.
I noticed mostly FFT works with Radix 2.. the FFT buffer has to be in power of 2.
Sound data array is lengthy.. Says as 441000 (10s 44100kHz sampling).It is unusual to transform the whole of the data at one go unless the data is just one single frequency. Easy enough though with 441,000 points as long as you use an FFT that works on 'double' and not 'float' since 'float' tends not to be accurate enough for around half a million data points.
If I starts by buffer as 262144 (2 power of 18) .. I will loop the buffer for only one time.
Then (441000-262144=178856) the remaining 178856 sampled data is not a power of 2...
What should i do for this circumstances? Should i add perform zero padding? fill in all the remaining buffer space with zero before perform with FFT?Since you have ignored the list of steps I posted earlier it seems you are not trying to do what I thought. Therefore I can't say what you need to do since you still have not specified what your input is (just saying it is an audio file is not enough, the characteristics of the audio are important) and what you are trying to extract from that input. You need to stop thrashing around with code, start studying and make sure you have a clear set of requirements.
public static void Analyze(int[] soundSample,float sample_rate ) {
int N = (int)sample_rate/5;
int Number_Sample = soundSample.length;
Complex[] fftBuffer = new Complex [2*N];
Complex[] fftResult = new Complex [2*N];
Complex [] lastN = new Complex [N]; // The array to save the last N sample
int delay = 0;
double delta = 2*Math.PI/(2*N);
// I have no idea how can i convert my sample array to double so that it will be in the range of [-1,+1]
while(delay <=soundSample.length){
//Extract the 2N sample for FFT analysis and convert the data to complex number.
for (int z=0; z<2*N; z++){
fftBuffer[z] = new Complex(soundSample[z+delay],0) ;
}
for (int i=N-1;i>=N/2; i-- ){
lastN[N-1-i] = fftBuffer;
}
for (int z=0; z<2*N; z++){
fftBuffer[z] = fftBuffer[z].times(0.54-0.46*Math.cos(z*delta));
}
fftResult = FFT1.fft(fftBuffer);
delay = 2*N + delay;
}
}
1) I was trying to perform FFT with 2N samples then keep on looping the FFT method until 2N reaches the ends of sampled data.
But the FFT that i am working with is radix 2... It doesn't work with my 2N samples... Please teach me how should i work out FFT regardless the number of sample?
2) The hamming window coefficient i m using is based on http://www.mathworks.com/help/toolbox/signal/hamming.html . I am working on index [0:2N] ..
Is it appropriate?
3) According to your No1 steps, the acceptable frequency resolution is 5Hz. May i know what is this representing? And is it application for most of the FFT application? How can i determine the frequency resolution that i should used in my project?
Sorry for late reply as i was trying to work out the thing..
Hereby attach to your the my coding.. and hopes to have your guidance and tutorial how to extract the pitch for recording audio file with Java.
I have done the pitch extraction with MATLAB.. but Matlab as built-in FFT function...
So i m now get stucked how to perform FFT on audio sound sample regardless the N value of sound sample for FFT buffer.
Many thanks for your former advise... and
Looking forward for your replies again.
Happy New Year 2011 :)
Edited by: 诸葛 on Dec 31, 2010 9:29 AM
诸葛 wrote:<snip>
Below is the coding that i have done by referring to the provided steps:
My FFT class:I have to admire your nerve - http://www.cs.princeton.edu/introcs/97data/FFT.java.html.public static Complex[] fft(Complex[] x) { // removed }