bewantbe / audio-analyzer-for-android

A fork of audio-analyzer-for-android in Google code, with a lot of enhancement.
Apache License 2.0
286 stars 117 forks source link

Improve music note detection below 100Hz and #28

Open tymbark opened 2 years ago

tymbark commented 2 years ago

Hi. Thank you for giving this cool project to the community.

I have compiled it and used the app with my piano to see how note detection works. I've seen two problems.

  1. Notes below G2 (~98Hz) are not recognised.
  2. Often one note is mistaken for the same note one octave higher. For example Im pressing A3 on the keyboard and app says A4.

I'm thinking if note recognition could be improved. So A3 is not shown as A4 and few more low frequency notes are recognised. Can you suggest some improvement that I can do? I'm using stft.maxAmpFreq to see what note is it.

bewantbe commented 2 years ago

Hi, tymbark. Thank you for using the app.

In my experience, the environmental noise & thermal noise (roughly brown noise, i.e. 6 dB per octave) will interference the peak detection algorithm. Because the algorithm detect only the highest point in the spectrum. In a typical brown noise, the highest point is the lowest frequency.

In my mind, we have two ways to overcome it:

(a) auto or manually draw a line of noise, then feed the peak detection algorithm only the signal spectrum, i.e. the spectrum subtracted by the noise line. (b) let the algorithm detect only the local maximum.

But, as a "workaround", we can actually pick the dBA mode (the "dB" button below), which will strongly suppress the spectrum below 100Hz, and the peak measurement will be slightly more reliable.