Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I already found the answer... :)</p> <p>I create method to calculate array value from audio...</p> <pre><code>public double[] calculateFFT(byte[] signal) { final int mNumberOfFFTPoints =1024; double mMaxFFTSample; double temp; Complex[] y; Complex[] complexSignal = new Complex[mNumberOfFFTPoints]; double[] absSignal = new double[mNumberOfFFTPoints/2]; for(int i = 0; i &lt; mNumberOfFFTPoints; i++){ temp = (double)((signal[2*i] &amp; 0xFF) | (signal[2*i+1] &lt;&lt; 8)) / 32768.0F; complexSignal[i] = new Complex(temp,0.0); } y = FFT.fft(complexSignal); // --&gt; Here I use FFT class mMaxFFTSample = 0.0; mPeakPos = 0; for(int i = 0; i &lt; (mNumberOfFFTPoints/2); i++) { absSignal[i] = Math.sqrt(Math.pow(y[i].re(), 2) + Math.pow(y[i].im(), 2)); if(absSignal[i] &gt; mMaxFFTSample) { mMaxFFTSample = absSignal[i]; mPeakPos = i; } } return absSignal; } </code></pre> <p>Then I called it in class Write Audio..</p> <pre><code>private void writeAudioDataToFile(){ byte data[] = new byte[bufferSize]; String filename = getTempFilename(); FileOutputStream os = null; try { os = new FileOutputStream(filename); } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } int read = 0; if(null != os){ while(isRecording){ read = recorder.read(data, 0, bufferSize); if(read &gt; 0){ absNormalizedSignal = calculateFFT(data); // --&gt; HERE ^__^ } if(AudioRecord.ERROR_INVALID_OPERATION != read){ try { os.write(data); } catch (IOException e) { e.printStackTrace(); } } } try { os.close(); } catch (IOException e) { e.printStackTrace(); } } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload