Skip to content

Commit

Permalink
Fix sliding window indices
Browse files Browse the repository at this point in the history
Previously, sliding window indices excluded some final indices. New approach ensures all indices are returned, but an extra clipping step is necessary to prevent reading beyond the end of the feature matrix.

Closes #1.
  • Loading branch information
nathanntg committed Apr 29, 2017
1 parent bb486b6 commit 4d154e1
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion find_audio.m
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,18 @@

function idx = sliding_window_indices(length, win_length, win_step)
win = 0:(win_length - 1);
idx = bsxfun(@plus, 1:win_step:(length - win_length + 1), win');

% length - win_length + 1 provides all valid indices (but misses
% some at the end of the length)

% length - win_step + 1 provides all indices (as well as a few past
% the end of length; as result, clip indices past length)

idx = bsxfun(@plus, 1:win_step:(length - win_step + 1), win');

if idx(end) > length
idx(idx > length) = length;
end
end

function [match_starts, match_ends, match_scores] = match_via_dtw(feat_template, feat_audio, thresh_score)
Expand Down

0 comments on commit 4d154e1

Please sign in to comment.