how to make the spectrum of sound on smartphone
<p>I have a project 
Purpose: building the spectrum of sound with the microphone (on smartphone)
I use the FFT algorithm with samplerate = 44100Hz, processing 512 samples once
but the result which i receive after FFT have the very small value 
and i think  it's probably wrong</p>

<p>enter code here</p>

<p>public class show extends Activity{</p>

<pre><code>int N = 512;
int NumOverlapSample, NumNewSample;
private static float[] input = new float[512];
private static float[] output = new float[512];
private static int Fs = 44100;
int recorderBufferSize = AudioRecord.getMinBufferSize(Fs, 
        AudioFormat.CHANNEL_CONFIGURATION_MONO, AudioFormat.ENCODING_PCM_16BIT);
private byte recorderAudiobuffer[] = new byte[1024];
AudioRecord recorder = new  AudioRecord(AudioSource.DEFAULT, Fs, 
        AudioFormat.CHANNEL_CONFIGURATION_MONO, AudioFormat.ENCODING_PCM_16BIT, recorderBufferSize);
Timer timer = new Timer();


@Override
protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    setContentView(R.layout.show);
    Bundle receiveBundle = this.getIntent().getExtras();
    int kieu = receiveBundle.getInt("kieu");
    NumOverlapSample = (int) (N*1.5625);
    NumNewSample = N*2-NumOverlapSample;
}

@Override
protected void onStart() {
    // TODO Auto-generated method stub
    super.onStart();

}

@Override
protected void onResume() {
    // TODO Auto-generated method stub
    super.onResume();
    recorder.startRecording();
    timer.schedule(new task_update(), 1000, 1000);

}

class task_update extends TimerTask
{

    @Override
    public void run() {
        // TODO Auto-generated method stub

        for(int i=0;i&lt;NumOverlapSample;i++)
             recorderAudiobuffer[i] = recorderAudiobuffer[i+NumNewSample];
        int bufferRead = recorder.read(recorderAudiobuffer,NumOverlapSample,NumNewSample);
        convert.decode(recorderAudiobuffer,N,input);

        fft.FFT(input, output);

        for(int i = 0;i&lt;512;i++)
        {
            load_text.ghifile("D:/list.text", output[i]);
        }
    }
}

private float getLog(int i){
    //float a= output[i]/NumPoint22;
    float a= output[i];
    //float b= mlog10(a);
    //b=-b;
    //return b*10;
    return (float) (10*Math.log10(a/(N/2)));
}


private float getSqrt(int i){
     return (float) (Math.sqrt(output[i]));
 }


@Override
protected void onStop() {
    // TODO Auto-generated method stub
    super.onStop();
    timer.cancel();
}
</code></pre>

<p>and code FFT algorithm</p>

<p>public class fft {</p>

<pre><code>private static  float[] W_real;
private static float[] W_img;
private static  float[] input_real;
private static  float[] input_img = new float[512];




public static void FFT(float[] input_real1, float[] output)
{
    input_real = input_real1;
    W_real = define512.W_IMAG;
    W_img = define512.W_IMAG;
    fftradix2(0,7);
    for(int i =0;i&lt;512;i++)
    {
        output[i] = (input_real[i]*input_real[i] + input_img[i]*input_img[i]);
    }


}
private static  void fftradix2(int dau,int cuoi)
{
    int check = cuoi - dau;
    if (check == 1)
    {


        input_real[dau] = input_real[dau] + input_real[cuoi];
        input_img[dau] = input_img[dau] + input_img[cuoi];

        input_real[cuoi] = input_real[dau] -2* input_real[cuoi];
        input_img[cuoi] = input_img[dau] -2* input_img[cuoi];


    }
    else
    {
        int index = 8/(cuoi - dau + 1);         
        int tg = (cuoi - dau)/2;
        fftradix2(dau,(dau+tg));
        fftradix2((cuoi-tg),cuoi);
        for(int i = dau;i&lt;=(dau+tg);i++)
        {

             input_real[i] = input_real[i] + input_real[i+tg+1]*W_real[(i-dau)*index] - input_img[i+tg+1]*W_img[(i-dau)*index];
             input_img[i] = input_img[i] + input_real[i+tg+1]*W_img[(i-dau)*index] + input_img[i+tg+1]*W_real[(i%(tg+1))*index];

             input_real[i+tg+1] = input_real[i] -2* input_real[i+tg+1]*W_real[(i-dau)*index] +2* input_img[i+tg+1]*W_img[(i-dau)*index];
             input_img[i+tg+1] = input_img[i] -2* input_real[i+tg+1]*W_img[(i-dau)*index] -2* input_img[i+tg+1]*W_real[(i-dau)*index];

        }
    }
}
</code></pre>

<p>}</p>

<p>and my source 
<a href="http://www.mediafire.com/?dcc6hav7bbabtaa" rel="nofollow">http://www.mediafire.com/?dcc6hav7bbabtaa</a>
thanks for all</p>
