dtczhl / dtc-acoustic-spectrumer

display spectrum of ambient sounds

Home Page:http://www.huanlezhang.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

dtc-acoustic-spectrumer

License: MIT  Codacy Badge

A simple android app to display the spectrum of received sounds

Screenshot

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].

  1. 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
  1. stop frequency analysis
  if (mFftAnalysis != null) {
      mFftAnalysis.stop();
      mFftAnalysis = null;
  }

Some critical steps to create this Android app from scratch.

  1. 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

  2. extract the downloaded file. Goes to commons-math3-***/src/main/java/org/apache/commons/math3, remove the geometry folder which is not compatible with Android.

  3. goes to commons-math3-***/src/main/java/ and copy the org folder to your Android project app/src/main/

  4. enable Android permission <uses-permission android:name="android.permission.RECORD_AUDIO" />

Phones Tested

  • Huawei Mate 20
  • Google Pixel 2

About

display spectrum of ambient sounds

http://www.huanlezhang.com

License:MIT License


Languages

Language:Java 100.0%