How to develop a Spectrum Analyser from a realtime audio?

Víctor Martín picture Víctor Martín · Aug 18, 2013 · Viewed 28.8k times · Source

I am developing an app that get a source audio from mic in realtime, with no file storage. Basically, I use:

mRecorder = new MediaRecorder();
mRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
mRecorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
mRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
mRecorder.setOutputFile("/dev/null");

How I can do a spectrum graphic from this realtime audio, with no files?

All post that I read are analyzing a buffered file.

Answer

Dr. Andrew Burnett-Thompson picture Dr. Andrew Burnett-Thompson · Apr 21, 2017

There is an open source Android spectrum analyzer on Github which computers FFT on audio from the microphone and displays a 2D spectrogram.

The Spectrum Analyzer project is found in the v2.x/Showcase app

You can see a video of it in action at https://youtu.be/yU05fsgOYO4

You can see a video with build instructions here: https://youtu.be/tVgn30uss2k?t=1m37s

enter image description here

The charting is provided by the SciChart Android chart library which is a commercial control, but the source code to read the mic, compute the FFT and spectrogram is free & open source under MIT License.

As a disclosure: I am the tech lead on the SciChart project