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 <seppo.ingalsuo@linux.intel.com>
This commit is contained in:
Seppo Ingalsuo 2019-10-18 15:12:17 +03:00 committed by Tomasz Lauda
parent 0324516ec3
commit 1dbd14b30d
1 changed files with 8 additions and 4 deletions

View File

@ -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;