-
Notifications
You must be signed in to change notification settings - Fork 48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tools: Add more robustness to check_volume_levels.m measure #985
Tools: Add more robustness to check_volume_levels.m measure #985
Conversation
@aiChaoSONG @marc-hb I still get these "[WARNING] SOF_TEST_TOP_PID=1531 already defined, multiple lib.sh inclusions?". I see only one line |
5c10589
to
06fd766
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good !!
06fd766
to
cf00256
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am fine with the changes. Thank you!!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not clear with below statement:
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.
Could you use short sentence to describe?
sof-test will write PID to a lock file in case you run multiple test case at the same time. maybe you interrupt the test, and the lock file not deleted? try manually delete the lock file /tmp/sof-test-cardX.lock, X is the sof card ID. |
By window I mean an acceptance criteria over time and gain in decibels. E.g. x milliseconds to y milliseconds, measured gain within a +/- b decibels. Actually I'm not evaluating every point in window but compute average gain from that measure window and compare to required. Any fail will fail the entire test. By computing the differential of measured gain, I see from the values if the gain is constant or changing. The added code is shifting the measurement window to later in time if the gain is not constant in in the beginning. Did this explain better - should I add this to commit message? |
No, that would be a different error message. I don't see how this could be related to matlab changes though. @singalsu is that independent of this PR? Can you reproduce with the current main branch and if yes please share how exactly in a new, different sof-test issue. |
The error is not printed if I remove from test end line |
@singalsu if you have a deterministic reproduction without this PR please file a new sof-test bug with complete reproduction steps. |
I will but it requires merge of this PR. The script does not proceed to last line where sof-kernel-log-check.sh is called if there is a test fail. Or in other words the Matlab part of test always fails without this improvement. Somehow things (controls) happen in DUT slower than before and failure rate is 100%. Also we don't have tests for control latencies trend, as an idea for future. |
7ca9e2d
cf00256
to
7ca9e2d
Compare
@btian1 I improved the commit text of first commit, no other changes, is it OK now? All, can you please re-review. The previous accepts were dropped from force push. |
7ca9e2d
to
83bb3fa
Compare
The PR update adds 4th commit that avoids need for parallel SOF repo checkout. |
dae511d
to
d79bf2a
Compare
@ShriramShastry you approve got cleared, can you please check again. There's only the one " " add to 1st commit. |
@marc-hb I just checked that this passed with SOF v2.2 on UP2. I had to make a small change to the shell wrapper since the loopback I2S device in sof-apl-nocodec.tplg is no more hw:0,0 but hw:0,2:
I'd like to make fixes incrementally and address the finding of loopback I2S a separate patch. Its not impacting the Matlab code of this PR. Also need to make the test to work with a test subset if there is no more mute switch, since those have been removed from IPC4 topologies. |
tools/check_volume_levels.m
Outdated
x = zeros(n, 1); | ||
x(:,1) = amp(1)*sin(2*pi*f(1)*t); | ||
for i=2:length(f) | ||
x(:,1) = x(:,1) + amp(i)*sin(2*pi*f(i)*t+ph(i))'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think x(:,1) is no longer needed , Just x is sufficient
I am thinking it's like below snippet
x = zeros(10,1);
y = linspace(-10,10,10);
x = y + 102.34
y assigns some linearly separated data to replace the loop x equation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep,
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's now simplified to just x
. I was apparently worried about vector orientations when doing this and did not clean up afterwards. The mixing of sine preserved the vector and did not make it a 2D matrix (a pitfall with Matlab language with column and row vectors).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A minor comment !! If it is fine with you.
tools/check_volume_levels.m
Outdated
|
||
x = zeros(n, 1); | ||
x(:,1) = amp(1)*sin(2*pi*f(1)*t); | ||
for i=2:length(f) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is the loop initialized from 2 rather than 1?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's because the first frequency f(1) sine wave is mixed before the loop. Any additional frequencies f(2) to f(end) are mixed in the loop. But yes, it can be simplified to e.g.
x = zeros(n, 1);
for i=1:length(f)
x(:,1) = x(:,1) + amp(i)*sin(2*pi*f(i)*t+ph(i))';
end
d79bf2a
to
1218c95
Compare
@ShriramShastry I updated the tone generator function as you proposed. Can you please review again? I just checked on UP2 sof-apl-nocodec.tplg that the updated code works and test passes so the change was OK. Next PR for volume checker should be to add support for IPC4 topologies without switch control, and solve the discovery of looped back I2S PCMs, or get the PCM IDs externally. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few sanity-related comments have been added.
Kindly include space where it is needed. The implementation looks to have improved significantly.
Thank you
tools/check_volume_levels.m
Outdated
if max(abs(dg)) > dg_tol | ||
n_idx = length(idx); | ||
dg_rev = dg(end:-1:1); | ||
idx_add = length(dg) - find(abs(dg_rev) > 0.1, 1, 'first') + 1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can 0.1
be superseded by dg_tol
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, it can be the same
gains = meas.levels - lm.sine_dbfs; | ||
sv = size(tc.volumes); | ||
for j = 1:sv(2) | ||
for i = 1:sv(1) | ||
% Initial location to test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could you please add a space between ts = tc.vctimes(i)+tc.meas(1);
as ts = tc.vctimes(i) + tc.meas(1);
tools/check_volume_levels.m
Outdated
% sof/tools/test/audio/test_utils/multitone.m | ||
function x = multitone( fs, f, amp, tlength ) | ||
n = round(fs*tlength); | ||
t = (0:n-1)/fs; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you please add space for the operation t = (0:n-1)/fs; like t = (0:n-1) / fs;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, but wouldn't then this be more consistent with even more spaces t = (0 : n - 1) / fs;
?
I admit I'm lazy to type spaces and this kind of not-all-spaces typed equations are everywhere. There is no Matlab style guide and e.g. "indent code" in Matlab IDE is not touching these. Also Octave Mode in Emacs differs from Matlab's indentations. But we can when applicable use SOF C style.
tools/check_volume_levels.m
Outdated
t = (0:n-1)/fs; | ||
nf = length(f); | ||
if nf > 1 | ||
ph = rand(nf, 1)*2*pi; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can do a space for rand(nf, 1)2pi; like rand(nf, 1) * 2 * pi;
tools/check_volume_levels.m
Outdated
|
||
x = zeros(n, 1); | ||
for i=1:length(f) | ||
x = x + amp(i)*sin(2*pi*f(i)*t+ph(i))'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you please a space for the equation x = x + amp(i) * sin(2 * pi *f(i) * t + ph(i))';
There seems to be a couple matlab beautifiers available, @ShriramShastry can you please recommend one? If no formatter is good then at least some codestyle document reference. Consistency is good but it needs to be well defined, we cannot have codestyle discussions repeats in every pull request. Also: please do NOT reformat every matlab file and destroy git history. We need a reference for new and modified code, not for old, unchanged code. Too late. |
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 window means acceptance criteria over time as gain in decibels. E.g. x milliseconds to y milliseconds, measured gain within a +/- b decibels. The average gain from the measure window is computed and compare to required. Any fail will fail the entire test. The differential of measured gain shows if the gain is constant or changing. The added code is shifting the measurement window to later in time if the gain is not constant in in the beginning. The delay in gain settling can be caused by random alsamixer controls apply delay. Also a very long gain ramp makes the settling to appear later. Signed-off-by: Seppo Ingalsuo <[email protected]>
If a test fails, it's easiest to examine the result graphically. Pass to command line the failed wav files names and last argument set to one to see the observed levels. Signed-off-by: Seppo Ingalsuo <[email protected]>
Matlab requires switch - end, endswitch is not accepted. Signed-off-by: Seppo Ingalsuo <[email protected]>
This patch adds local functions multitone() and level_dbfs() to script check_volume_levels.m to avoid need for SOF repository. The added functions are small and simple so the duplication is not an issue. Signed-off-by: Seppo Ingalsuo <[email protected]>
There's no functional changes, only added blanks between arithmetic operations, comma separated lists, and ":" operator. Signed-off-by: Seppo Ingalsuo <[email protected]>
1218c95
to
5eec116
Compare
@ShriramShastry The last commit contains the style changes for non-impacted code. Sine generator style changes are in the commit that adds it. |
https://www.google.com/search?q=matlab+beautify |
@ShriramShastry all good now? Only suspend/resume failures on one device in https://sof-ci.01.org/softestpr/PR985/build164/devicetest/index.html, everything else OK. |
I learned that @ShriramShastry has been out of office. I looked at the changes since he last approved: https://github.com/thesofproject/sof-test/compare/d79bf2af7aeae751ff728c2585d37677f0663424..5eec1168b4ad26f19a744d69a00ea0fbe620eacf I found only whitespace changes + this Merging. |
@singalsu can you still reproduce? |
|
No description provided.