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?
Sampling Rate: 44100
Channel: Mono
Encoding: PCM 16 BIT
BufferSize: 4096
(Im not sure if it is 4096 or 2048 since I read 4096 bytes every time and it can only fill 2048 2bytes buffer)
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: FFT in Java and Complex class
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.
In conclude, I have 3 questions:
- Is the initial bufferSize equal to the buffers that I can read from the .read method?
- Is 40-60ms the limitation to capture audio data with 44100 sampling rate?
- 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?)
Sorry for my bad english, also thank you for spending your time on my question.
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.