简体   繁体   中英

Java frequency analysis performance

I'm working on an application that samples audio and needs to do real time processing (FFT and harmonic product spectrum) of this data.

I need to use a sampling rate of 44100Hz and need a frequency resolution of 0.5Hz, meaning I need 88200 samples pre-FFT. This takes about 2 seconds to capture since it's twice the sampling rate; however, after the first sample, I do improve things significantly by using a circular buffer for the sampling and read only half as many samples from then on.

Unfortunately, the performance is still quite low and there is quite a bit of latency. This is a big problem since the application needs to be responding in a timely manner to input as it happens.

Does anyone have any suggestions for how I might improve the performance of this? I think the main problem lies in the requirement for large samples and it would be good if there was some way I could reduce how much audio is read while still maintaining the same accuracy. Would threading perhaps help here?

EDIT

If it helps to know, I am trying to do real-time F0 estimation from electric guitar input, along with multiple F0 estimation for chord matching. I have methods of doing this that work and are quite accurate, but it's for a uni project and I don't really have enough time left to look too far into other methods than the FFT. Really, I'm just hoping for some kind of way to speed up the sampling process.

Since you need to capture 2s of audio initially, this will set a lower bound on latency. Even with your 50% overlap you will still have a minimum latency of 1s. The FFT and other processing will only add to this, but hopefully not by a significant amount (otherwise use a faster FFT library). The only way you will be able to reduce this latency is by sacrificing frequency resolution.

Using an FFT method gives you a time-frequency trade-off. If you want lower latency, you will have to use less data, which with an FFT (either shorter or zero-padded) will give you a less accurate frequency estimate.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM