Share My Creation FFT Test w/ source

I've uploaded a test program I use to detect sound.

It acquires audio data from the microphone, performs an FFT and magnitude squared, then graphs the "bin" output.

On the top half I have a few test labels that show some performance parameters:
buf len is the number of bytes returned by the audio record callback.
buf cnt is a counter showing the total number of audio record buffers received.
cbuf cnt is the number of Shorts in my circular buffer. I convert Bytes received from audio record to Shorts and store them in a circular buffer waiting to be processed.
Fft time is the amount of time required to compute the FFT, magnitude squared, and update the graph. For real-time operation this number should be smaller than the time represented by data acquisition. In this example I use a 64 point FFT and 11025 sample rate. That means I need to perform FFT's faster than (64/11025) about 5.8 milliseconds. I use Steve105's NanoTime library to adjust the rate of FFT processing to, sort of, match real-time.
Max is the maximum magnitude squared bin value. I used this number to arbitrarily scale the graph.

I used two third-party libraries which you might need to download:
NanoTime from Steve105
ByteConverter from Agraham

The APK executes in real time on my Pixel 3a phone and Samsung Galaxy Tab S5e tablet. It runs, but bogs down because the processor is too slow, on my LG G6.

I arbitrarily set the maximum scaling for the graph at 30,000. This works on my 3a and 5Se but may need to be changed depending on the specific device.

1578274442462.png


The source code, along with the APK and screenshot, is in the attached zip file.

The source includes a very fast FFT module. The FFT is oriented toward real-time processing – it uses a table of pre-computed of sine/cosine lookup coefficients.
It also includes a circular buffer class that I use.

Barry.
 

Attachments

  • FftTest.zip
    169.1 KB · Views: 534
Last edited:

freedom2000

Well-Known Member
Licensed User
Longtime User
Excellent !

I used an old FFT library (which works really well) and threading library to keep the real time !

@klaus wrote this library : FFT library

I don't know if yours is better, but well done :)
 
Top