Skip to content

Commit

Permalink
Changes as requested by Anthony.
Browse files Browse the repository at this point in the history
Issue #451
  • Loading branch information
towsey committed Mar 1, 2021
1 parent be61baa commit a92319b
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 17 deletions.
14 changes: 14 additions & 0 deletions src/Acoustics.Shared/Extensions/EnumerableExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -316,5 +316,19 @@ public static string Join<T>(this IEnumerable<T> items, string delimiter = " ")
// return one delimiter length less because we always add a delimiter on the end
return result.ToString(0, result.Length - delimiter.Length);
}

public static string JoinFormatted<T>(this IEnumerable<T> items, string delimiter = " ")
{
var result = new StringBuilder();
foreach (var item in items)
{
string number = string.Format("{0:f2}", item);
result.Append(number);
result.Append(delimiter);
}

// return one delimiter length less because we always add a delimiter on the end
return result.ToString(0, result.Length - delimiter.Length);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,10 @@ PostProcessing:

# 5: Filter the events for excess activity in their sidebands, i.e. upper and lower buffer zones
#SidebandAcousticActivity:
LowerSidebandWidth: 150
UpperSidebandWidth: 400
MaxBackgroundDecibels: 12
MaxActivityDecibels: 12
# LowerSidebandWidth: 150
# UpperSidebandWidth: 400
# MaxBackgroundDecibels: 12
# MaxActivityDecibels: 12

# Options to save results files
# 1: Available options for saving spectrograms (case-sensitive): [False/Never | True/Always | WhenEventsDetected]
Expand Down
6 changes: 3 additions & 3 deletions src/AnalysisPrograms/Recognizers/GenericRecognizer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -159,10 +159,10 @@ public override RecognizerResults Recognize(

// Running profiles with multiple dB thresholds produces nested (Russian doll) events.
// Remove all but the outermost event.
Log.Debug($"\nFLATTEN RUSSIAN DOLL EVENTS.");
Log.Debug($"## Event count BEFORE removing enclosed events = {postEvents.Count}.");
Log.Debug($"\nREMOVE EVENTS ENCLOSED BY LONGER EVENTS.");
Log.Debug($"Event count BEFORE removing enclosed events = {postEvents.Count}.");
results.NewEvents = CompositeEvent.RemoveEnclosedEvents(postEvents);
Log.Debug($"## Event count AFTER removing enclosed events = {postEvents.Count}.");
Log.Debug($"Event count AFTER removing enclosed events = {postEvents.Count}.");

// Write out the events to log.
if (postEvents.Count > 0)
Expand Down
16 changes: 6 additions & 10 deletions src/AudioAnalysisTools/Events/EventFilters.cs
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ public static List<EventCommon> FilterEventsOnSyllableCountAndPeriodicity(List<E
if (ev is CompositeEvent == false)
{
filteredEvents.Add(ev);
Log.Debug($" Event{count} accepted one syllable.");
Log.Debug($" Event[{count}] accepted one syllable.");
continue;
}

Expand All @@ -256,16 +256,12 @@ public static List<EventCommon> FilterEventsOnSyllableCountAndPeriodicity(List<E
}
}

string strArray = DataTools.Array2String(actualPeriodSeconds.ToArray());
Log.Debug($" Event{count} actual periods: {strArray}");

// don't use following line because does not format decimal places.
//Log.Debug($" Event{count} actual periods: {actualPeriodSeconds.Join(",")}");
Log.Debug($" Event[{count}] actual periods: {actualPeriodSeconds.JoinFormatted(", ")}");

// reject composite events whose total syllable count exceeds the user defined max.
if (syllableCount > maxSyllableCount)
{
Log.Debug($" Event{count} rejected: Actual syllable count > max: {syllableCount} > {maxSyllableCount}");
Log.Debug($" Event[{count}] rejected: Actual syllable count > max: {syllableCount} > {maxSyllableCount}");
continue;
}

Expand All @@ -275,7 +271,7 @@ public static List<EventCommon> FilterEventsOnSyllableCountAndPeriodicity(List<E
// there was only one event - the multiple events all overlapped as one event
// accept this as valid outcome. There is no interval on which to filter.
filteredEvents.Add(ev);
Log.Debug($" Event{count} accepted - only one syllable");
Log.Debug($" Event[{count}] accepted - only one syllable");
}
else
{
Expand All @@ -291,12 +287,12 @@ public static List<EventCommon> FilterEventsOnSyllableCountAndPeriodicity(List<E
// Require that the actual average period or interval should fall between required min and max period.
if (actualAvPeriod >= minExpectedPeriod && actualAvPeriod <= maxExpectedPeriod)
{
Log.Debug($" Event{count} accepted: Actual average syllable interval = {actualAvPeriod:F3}");
Log.Debug($" Event[{count}] accepted: Actual average syllable interval = {actualAvPeriod:F3}");
filteredEvents.Add(ev);
}
else
{
Log.Debug($" Event{count} rejected: Actual average syllable interval = {actualAvPeriod:F3}");
Log.Debug($" Event[{count}] rejected: Actual average syllable interval = {actualAvPeriod:F3}");
}
}
}
Expand Down

0 comments on commit a92319b

Please sign in to comment.