# Java frequency analysis efficiency

I am working on an application that samples audio and requires real-time processing (FFT and harmonic product spectrum) of this data.

I need to use a sample rate of 44100Hz and require a frequency resolution of 0.5Hz, i.e. I need 88200 pre-FFT samples. It takes about 2 seconds to capture because it is twice the sample rate; however, after the first sample, I significantly improve the situation by using a circular fetch buffer and only read half the number of samples from now on.

Unfortunately, performance is still pretty slow and there is a fairly small latency. This is a big problem as the application has to respond in a timely manner to input as it happens.

Does anyone have any suggestions for improving performance? I think the main problem is the requirement for large samples and it would be nice if I could reduce the amount of audio read while keeping the same precision. Is it possible to use streams?

** EDIT**

If it helps to find out, I'm trying to make a realtime F0 estimate from the electric guitar input, as well as a few F0 estimates for chord matching. I have methods to do this, work and is pretty accurate, but this is for a uni project and I really don't have enough time to look too much into other methods besides FFT. In fact, I'm just hoping for some way to speed up the sampling process.

source to share

Since you need to record 2s of audio first, this will set the lower latency limit. Even with 50% overlap, you will still have a minimum delay of 1 second. FFT and other processing will only complement this, but hopefully not by a significant amount (otherwise use the faster FFT library). The only way to reduce this latency is to sacrifice frequency resolution.

source to share

Using the FFT method gives you a time-frequency tradeoff. If you want lower latency, you will have to use less data, which with FFTs (shorter or zero) gives you a less accurate estimate of frequency.

Zero-padding will just give you high quality interpolation. But this can provide a better estimate of the peak frequency than simply using the center of the peak buffer of the shorter FFT.

source to share