Skip to content

Commit fcf9238

Browse files
committed
Tools: Add more robustness to check_volume_levels.m measure
This patch delays the check window if the gain settling seems to be still happening in the beginning of level check window. The settling is detected with differential of gain. The delay in gain settling can be caused by random alsamixer controls apply delay. Also a long gain ramp makes the settling to appear later. Signed-off-by: Seppo Ingalsuo <[email protected]>
1 parent 2423009 commit fcf9238

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

tools/check_volume_levels.m

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,14 +187,36 @@ function plot_levels(meas, tc, lm)
187187

188188
function pass = check_levels(meas, tc, lm, verbose)
189189
pass = 1;
190+
dg_tol = 0.1;
190191
gains = meas.levels - lm.sine_dbfs;
191192
sv = size(tc.volumes);
192193
for j = 1:sv(2)
193194
for i = 1:sv(1)
195+
% Initial location to test
194196
ts = tc.vctimes(i)+tc.meas(1);
195197
te = tc.vctimes(i)+tc.meas(2);
196198
idx0 = find(meas.t < te);
197199
idx = find(meas.t(idx0) > ts);
200+
201+
% Delay if settled gain is later in the window,
202+
% this adds more robustness to test for controls
203+
% apply delay.
204+
dg = diff(gains(idx,j));
205+
if max(abs(dg)) > dg_tol
206+
n_idx = length(idx);
207+
dg_rev = dg(end:-1:1);
208+
idx_add = length(dg) - find(abs(dg_rev) > 0.1, 1, 'first') + 1;
209+
idx = idx + idx_add;
210+
if idx(end) > size(gains, 1)
211+
idx = idx(1):size(gains,1);
212+
end
213+
if idx(1) > size(gains, 1) || length(idx) < 0.5 * n_idx
214+
fprintf(1, 'Channel %d controls impact is delayed too much ', j);
215+
fprintf(1, 'from %4.1f - %4.1fs\n', ts, te);
216+
pass = 0;
217+
return;
218+
end
219+
end
198220
avg_gain = mean(gains(idx, j));
199221
max_gain = tc.volumes(i,j) + tc.vtol;
200222
min_gain = tc.volumes(i,j) - tc.vtol;

0 commit comments

Comments
 (0)