Reputation: 926
So I have a AudioRecord set up working with a FFT to determine frequencies for note determination.
During the set up I ask for
AudioRecord.getMinBufferSize(rate, channelConfig, audioFormat)
Then I have some if statements that set it to the next greater power of two. For my phone it is typically 2048(2^11). The purpose being that the next thing I perform is a FFT for which the algorithm requires a buffer length that is a power of two.
Correct me if I'm wrong but I was under the impression that the reason you find the minimum buffer size was because it would decrease latency.
This was all fine until I was reading that in order to determine specific notes with accuracy, especially those that have lower frequency, you must have a larger sample size to feed to the FFT; Preferably a sample size greater than 16384 (2^14).
I guess the question that I'm having is. When I create the AudioRecord:
AudioRecord recorder = new AudioRecord(MediaRecorder.AudioSource.DEFAULT,
rate, channelConfig, audioFormat, bufferSize1);
can I use one buffer size, smaller for less latency, then when I read the buffer:
AudioRecord().read(thisbuffer, 0, bufferSize2);
use a different buffer size, of longer length, before sending it to the FFT? Or is there a better way to do this?
Upvotes: 1
Views: 550
Reputation: 70733
First, an FFT is a poor choice for "note" determination, as for musical notes one normally wants to estimate pitch, not spectral frequency, which are two very different things due to psychoacoustics.
For a windowed FFT, the spectral frequency is most accurately determined near the middle of the FFT window. Thus, using a longer FFT, even if repeating them by overlapping after a very short input buffer size, will incur a latency on the order of half the FFT length.
But repeating the FFT more often (by overlapping them after a short input buffer latency) will give you better time resolution, if not faster latency. For real lower latency, you need to use a shorter FFT, and lose frequency resolution, or use another frequency or pitch estimator, which will also have other time-frequency-robustness tradeoffs.
Upvotes: 2