From 14e041dbe86daa32a86769e8f0829f40b5695338 Mon Sep 17 00:00:00 2001 From: towsey Date: Fri, 12 Jun 2020 18:15:22 +1000 Subject: [PATCH] Update AnthusNovaeseelandiae.cs Issue #321 Removed unused method. --- .../Birds/AnthusNovaeseelandiae.cs | 67 +------------------ 1 file changed, 3 insertions(+), 64 deletions(-) diff --git a/src/AnalysisPrograms/Recognizers/Birds/AnthusNovaeseelandiae.cs b/src/AnalysisPrograms/Recognizers/Birds/AnthusNovaeseelandiae.cs index 5409435e9..1c70b0e3e 100644 --- a/src/AnalysisPrograms/Recognizers/Birds/AnthusNovaeseelandiae.cs +++ b/src/AnalysisPrograms/Recognizers/Birds/AnthusNovaeseelandiae.cs @@ -146,6 +146,9 @@ public static List FilterEventsOnFrequencyProfile(List var componentEvents = ev.ComponentEvents; var points = EventExtentions.GetCompositeTrack(componentEvents).ToArray(); + // Uncomment this line when want to see the composite track profile. + //WriteFrequencyProfile(points); + // For Pipit require minimum of four frames duration. var length = points.Length; if (length < 4) @@ -153,8 +156,6 @@ public static List FilterEventsOnFrequencyProfile(List continue; } - //WriteFrequencyProfile(points); - // Only select events having strong downward slope in spectrogram. var avFirstTwoEvents = (points[0].Hertz.Minimum + points[0].Hertz.Minimum) / 2; var avLastTwoEvents = (points[length - 1].Hertz.Minimum + points[length - 2].Hertz.Minimum) / 2; @@ -167,70 +168,8 @@ public static List FilterEventsOnFrequencyProfile(List return returnEvents; } - /// - /// The Boobook call syllable is shaped like an inverted "U". Its total duration is close to 0.15 seconds. - /// The rising portion lasts for 0.06s, followed by a turning portion, 0.03s, followed by the decending portion of 0.06s. - /// The constants for this method were obtained from the calls in a Gympie recording obtained by Yvonne Phillips. - /// - /// An event containing at least one forward track i.e. a chirp. - public static void SetFrequencyProfileScore(ChirpEvent ev) - { - const double risingDuration = 0.06; - const double gapDuration = 0.03; - const double fallingDuration = 0.06; - - var track = ev.Tracks.First(); - var profile = track.GetTrackFrequencyProfile().ToArray(); - - // get the first point - var firstPoint = track.Points.First(); - var frameDuration = firstPoint.Seconds.Maximum - firstPoint.Seconds.Minimum; - var risingFrameCount = (int)Math.Floor(risingDuration / frameDuration); - var gapFrameCount = (int)Math.Floor(gapDuration / frameDuration); - var fallingFrameCount = (int)Math.Floor(fallingDuration / frameDuration); - - var startSum = 0.0; - if (profile.Length >= risingFrameCount) - { - for (var i = 0; i <= risingFrameCount; i++) - { - startSum += profile[i]; - } - } - - int startFrame = risingFrameCount + gapFrameCount; - int endFrame = startFrame + fallingFrameCount; - var endSum = 0.0; - if (profile.Length >= endFrame) - { - for (var i = startFrame; i <= endFrame; i++) - { - endSum += profile[i]; - } - } - - // set score to 1.0 if the profile has inverted U shape. - double score = 0.0; - if (startSum > 0.0 && endSum < 0.0) - { - score = 1.0; - } - - ev.FrequencyProfileScore = score; - } - - /// - /// . - /// - /// List of spectral points. public static void WriteFrequencyProfile(ISpectralPoint[] points) { - /* Here are the frequency profiles of some events. - * Note that the first five frames (0.057 seconds) have positive slope and subsequent frames have negative slope. - * The final frames are likely to be echo and to be avoided. - * Therefore take the first 0.6s to calculate the positive slope, leave a gap of 0.025 seconds and then get negative slope from the next 0.6 seconds. - */ - if (points != null) { var str = $"Track({points[0].Seconds.Minimum:F2}):";