title: Real time audio processing in Android
body: <p>I am using AudioRecord.read to capture PCM data to bytes.
  However, I found that it restricted to initialize the AudioRecord object with at least 3904 buffers. Where the sampling rate is 44100.
  Since I need to perform FFT of the data so I increased the samples to 4096.
  As a result, the callback runs every 40-60ms by setPositionNotificationPeriod to 500. Since a further decrease the duration doesn't make any changes.
  I'm wondoring if it is the fastest callback time with below configuration?</p>
  
  <p>Sampling Rate: 44100</p>
  
  <p>Channel: Mono</p>
  
  <p>Encoding: PCM 16 BIT</p>
  
  <p>BufferSize: 4096</p>
  
  <p>(Im not sure if it is 4096 or 2048 since I read 4096 bytes every time and it can only fill 2048 2bytes buffer)</p>
  
  <p>even 40-60ms is acceptable, I then perform FFT which eventually block each callback around 200-300ms. And there is still many noise affecting the accuracy.
  I'm using these source code: <a href="http://introcs.cs.princeton.edu/java/97data/FFT.java.html" rel="nofollow">FFT in Java</a> and <a href="http://introcs.cs.princeton.edu/java/97data/Complex.java.html" rel="nofollow">Complex class</a></p>
  
  <p>Is there any other choice that perform fast, reliable and consume less memory processing FFT?
  I found that the above classes new too much objects and pop up loads of gragarbage collection's messages.</p>
  
  <p>In conclude, I have 3 questions:</p>
  
  <ol>
  <li>Is the initial bufferSize equal to the buffers that I can read from the .read method?</li>
  <li>Is 40-60ms the limitation to capture audio data with 44100 sampling rate?</li>
  <li>Could you suggest some FFT library so that I can have a better performance in processing FFT? (I think if it is better to use C code library?)</li>
  </ol>
  
  <p>Sorry for my bad english, also thank you for spending your time on my question.</p>
  
  <p>P.S I tried it on iOS and it can just take 512 samples with 44100 sampling rate. So every callback takes around 10ms only.</p>