QutEcoacoustics / audio-analysis

The audio analysis code (AnalysisPrograms.exe) for the QUT Ecoacoustics Research Group
https://ap.qut.ecoacoustics.info/
Apache License 2.0
52 stars 12 forks source link

Issue471 check formant gap #498

Closed towsey closed 3 years ago

towsey commented 3 years ago

Title of PR

Detection of Harmonic Events.

What is the purpose of this PR? Fix error in detection of Harmonic Events.

Fixes #471

Changes

There are three major changes: 1: I detrended the array of dct coefficients before determining the maximum coefficient. 2: I removed coefficients 0 to 3 from contention as maximum coefficients. We expect there to be a minimum of three formants and three or more formants can only be detected by coefficients 4 and above. 3: I fill in gaps of one or two frames in a sequence of harmonics. This is a hack. -> this is the new SmoothingWindow parameter

I also made various other changes to unit tests and refactoring of methods.

Issues

Detection of stacked harmonics still requires careful consideration of the appropriate parameter values.

Visual Changes

There are no visual changes to the spectrograms produced by this recognizer.

Final Checklist

codecov[bot] commented 3 years ago

Codecov Report

Merging #498 (35bbc6c) into master (2099caf) will decrease coverage by 38.01%. The diff coverage is 0.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #498       +/-   ##
==========================================
- Coverage   38.72%   0.70%   -38.02%     
==========================================
  Files         482     481        -1     
  Lines       67466   48881    -18585     
  Branches     7870    7659      -211     
==========================================
- Hits        26123     344    -25779     
- Misses      41252   48487     +7235     
+ Partials       91      50       -41     
Impacted Files Coverage Δ
...coustics.Shared/Extensions/EnumerableExtensions.cs 0.00% <0.00%> (-67.91%) :arrow_down:
.../AnalysisPrograms/Recognizers/GenericRecognizer.cs 0.00% <0.00%> (-78.36%) :arrow_down:
src/AudioAnalysisTools/CrossCorrelation.cs 0.00% <ø> (-45.55%) :arrow_down:
src/AudioAnalysisTools/DSP/MFCCStuff.cs 0.00% <0.00%> (-74.00%) :arrow_down:
...c/AudioAnalysisTools/Events/Types/HarmonicEvent.cs 0.00% <0.00%> (ø)
...AudioAnalysisTools/Harmonics/HarmonicParameters.cs 0.00% <0.00%> (-67.65%) :arrow_down:
...AudioAnalysisTools/Ocillations/Oscillations2010.cs 0.00% <0.00%> (-14.25%) :arrow_down:
...AudioAnalysisTools/Ocillations/Oscillations2012.cs 0.00% <ø> (-92.97%) :arrow_down:
src/TowseyLibrary/ImageTools.cs 0.00% <0.00%> (-38.28%) :arrow_down:
src/TowseyLibrary/MatrixTools.cs 0.00% <ø> (-40.73%) :arrow_down:
... and 470 more

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 2099caf...35bbc6c. Read the comment docs.

towsey commented 3 years ago

I believe the two failing tests are to do with ProcessRunner.

towsey commented 3 years ago

Concerning your comment - "I don't like that we define a harmonic as 3 or more formants (technically only one other frequency is needed other than the fundamental)". The harmonic detection relies upon a DCT which can give spurious results where there are other components contributing to the spectrum. The justification for requiring a minimum of three formants is that this gives two intervals. It is very difficult for a DCT to determine the presence of harmonics given only one interval. Requiring two intervals narrows down the possibility for a spurious result. You previously had to set a high formant gap because the DCT was picking up background components at the low index end of the DCT coefficient array. I have had this problem before but not had time to fix it. The things I have done in this round of fixes has helped a lot. But harmonic detection remains prone to error in presence of background noise.

towsey commented 3 years ago

I have just committed a few more changes including changes to the md documentation. I think this is it for this issue.??