From d3c092431e5d973242ad7a0baeedc0b8ea2c4677 Mon Sep 17 00:00:00 2001 From: Nathan Perkins Date: Sat, 29 Apr 2017 09:37:04 -0400 Subject: [PATCH] Improve match single to use length constraint Calculate the threshold for match_single respecting the length constraint. Produces better matches. --- find_audio.m | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/find_audio.m b/find_audio.m index bf3180f..87641fd 100644 --- a/find_audio.m +++ b/find_audio.m @@ -251,12 +251,7 @@ % single extraction mode if match_single - t = sort(scores); - if isempty(thresh_score) - thresh_score = t(4); - else - thresh_score = t(thresh_score); - end + thresh_score = Inf; end % threshold @@ -286,10 +281,18 @@ if match_single % match single... short circuit sliding window logic - [~, potential_ends] = min(scores); + [s, potential_ends] = min(scores); + + % no score + if isnan(s) + potential_ends = []; + end % update start index - cor(cor == 0) = 1; + if any(cor(potential_ends) == 0) + warning('Matches at boundary, may be clipped.'); + cor(cor == 0) = 1; + end else % no zero starts scores(cor == 0) = nan;