From 1dbd14b30daad1e5541d641da2e97163e328200a Mon Sep 17 00:00:00 2001 From: Seppo Ingalsuo Date: Fri, 18 Oct 2019 15:12:17 +0300 Subject: [PATCH] Testbench: Improve test begin and end marker tones find Chirp test signals confused the test signal begin marker position seek and caused false test fails. The test stimulus may produce stronger cross correlation level than the actual marker. Also the check omitted that the cross correlation max could be negative so the test was changed into power domain and use first/last cross correlation peak above threshold as test begin/end position. Signed-off-by: Seppo Ingalsuo --- tools/test/audio/test_utils/find_test_signal.m | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/tools/test/audio/test_utils/find_test_signal.m b/tools/test/audio/test_utils/find_test_signal.m index 89d4af23b..c4002bef8 100644 --- a/tools/test/audio/test_utils/find_test_signal.m +++ b/tools/test/audio/test_utils/find_test_signal.m @@ -34,8 +34,10 @@ n_seek = round(test.fs*(test.idle_t + test.mark_t)); n = min(max(round(test.fs*test.sm), n_seek), nx); y = x(1:n); [r, lags] = xcorr(y, s); -[r_max, idx] = max(r); -d_start = lags(idx); +r2 = r.^2; +r2_thr = 0.1 * max(r2); +idx = find(r2 > r2_thr); +d_start = lags(idx(1)); %% Find end marker fprintf('Finding test end marker...\n'); @@ -44,8 +46,10 @@ n_seek = round(test.fs*(test.idle_t + test.mark_t)); n = min(max(round(test.fs*test.em),n_seek), nx); y = x(end-n+1:end); [r, lags] = xcorr(y, s); -[r_max, idx] = max(r); -d_end = nx-n+lags(idx); +r2 = r.^2; +r2_thr = 0.1 * max(r2); +idx = find(r2 > r2_thr); +d_end = nx-n+lags(idx(end)); %% Check correct length of signal len = d_end-d_start;