From 041342ebbcd735e752014031e3bb26173faf7cb1 Mon Sep 17 00:00:00 2001 From: Anthony Truskinger Date: Tue, 8 Dec 2020 15:00:35 +1000 Subject: [PATCH] Fixes bug in GetEventsAroundMaxima --- src/AudioAnalysisTools/AcousticEvent.cs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/AudioAnalysisTools/AcousticEvent.cs b/src/AudioAnalysisTools/AcousticEvent.cs index 47196e2e2..b1da3309c 100644 --- a/src/AudioAnalysisTools/AcousticEvent.cs +++ b/src/AudioAnalysisTools/AcousticEvent.cs @@ -1052,7 +1052,15 @@ public static List GetEventsAroundMaxima( i = maxFrame; while (values[i] > thresholdValue) { - i++; + // AT: added this condition otherwise index can grow larger than values array + if (i + 1 < values.Length) + { + i++; + } + else + { + break; + } } endFrame = i;