04-02-2020, 03:56 PM
Well, we went for the fast but not exactly easy route. Phyphox uses the fftw library (as it is GNU GPL, this is only possible since phyphox is open source, too) through Android NDK. So fftw is written in c and compiled into native code for all the different architectures. This should be one of the fastest ways to do it, but it is not necessarily simple to set up. The interface between Java and C++ (NDK) can be seen in https://github.com/Staacks/phyphox-andro...alysis.cpp and https://github.com/Staacks/phyphox-andro...lysis.java. (Sorry, the latter is one of the older ugly parts of phyphox.)
However, I am not entirely sure if you want to use FFT for what you plan to do. The resolution of the Fourier transform is the inverse of the duration of the recording that you transform. So, if you want to resolve two decimal places, let's say 0.05 Hz, you need to analyze 1/0.05Hz = 20s. Not sure if that is what you want and if your tone is stable for 20s - and that is certainly not realtime. Depending on what you already know about your signal and depending on other trade-offs (you don't need the entire spectrum, do you? You do not expect low frequencies on top of your tone?), there are better methods to detect the frequency, but you need to research them as I only have "implementing a better frequency detection" on my todo list without having done the research yet.
However, I am not entirely sure if you want to use FFT for what you plan to do. The resolution of the Fourier transform is the inverse of the duration of the recording that you transform. So, if you want to resolve two decimal places, let's say 0.05 Hz, you need to analyze 1/0.05Hz = 20s. Not sure if that is what you want and if your tone is stable for 20s - and that is certainly not realtime. Depending on what you already know about your signal and depending on other trade-offs (you don't need the entire spectrum, do you? You do not expect low frequencies on top of your tone?), there are better methods to detect the frequency, but you need to research them as I only have "implementing a better frequency detection" on my todo list without having done the research yet.