dtc-acoustic-spectrumer
A simple android app to display the spectrum of received sounds
Screenshot
Screenshot from Huawei Mate 20. You can see that there is a spike around 19 KHz when I send sounds of that frequency. See my dtc-frequency-player about how to send sounds of a specific frequency.
Ranges:
- x-axis (horizontal): [0Hz, 24 KHz]
- y-axis (vertical): strength of frequency in dB
Source Code
The interface to the spectrum analysis is the AnalyzeFrequency.java
class. The spectrum range is [0 Hz, 24 KHz].
- start frequency analysis
AnalyzeFrequency mFftAnalysis = new AnalyzeFrequency(mHandler, mRun);
mFftAnalysis.start();
// FFT magnitude for current frame of received sound.
// Default length: 4096/2-1
mFftAnalysis.mMagnitude
- stop frequency analysis
if (mFftAnalysis != null) {
mFftAnalysis.stop();
mFftAnalysis = null;
}
Some critical steps to create this Android app from scratch.
-
download the source code of Apache Commons Math library for Java that includes Fast-Fourier-Transform (FFT). http://commons.apache.org/proper/commons-math/download_math.cgi
-
extract the downloaded file. Goes to
commons-math3-***/src/main/java/org/apache/commons/math3
, remove thegeometry
folder which is not compatible with Android. -
goes to
commons-math3-***/src/main/java/
and copy theorg
folder to your Android projectapp/src/main/
-
enable Android permission
<uses-permission android:name="android.permission.RECORD_AUDIO" />
Phones Tested
- Huawei Mate 20
- Google Pixel 2