-
Notifications
You must be signed in to change notification settings - Fork 325
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
Audio: Enhancing audio quality tests for device testing #6056
base: main
Are you sure you want to change the base?
Conversation
33e93b4
to
e1525df
Compare
249e58e
to
40c6875
Compare
40c6875
to
8225cea
Compare
@singalsu pls review. |
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.
Please split this PR to multiple commits. E.g. commit per test case and split common test framework changes to topics/issues.
106f443
to
4519c84
Compare
4519c84
to
dc55e7c
Compare
@btian1 pls also review |
test = remote_test_run(test); | ||
|
||
% Measure | ||
test = dr_test_measure(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.
possible have more var name? instead of use test always, it may make confused or generate unexpected result, what do you think?
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.
Hi, Seppo, Malldi
I know those test's basic idea is get loopback data and compare with matlab reference(or input) with some point, but when look into it, still feel hard to fully understand.
My request is: can you pick one .m file and add detailed explain for the mechanism and each line to make us understand more better? sorry, just feel can't understand well and want to understand well, :)
Thanks
Tim
If you have a more detailed question, I'm happy to try to answer it. However, I recommend using debug breakpoints to help with comprehension. |
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.
@singalsu I cant review the matab, but I will merge after you are happy with the PR.
@ShriramShastry Fred's patches are now merged. Please check the conflicts in process_test.m. |
Sure, Thanks a lot |
1a833ed
to
2b2a57a
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.
@ShriramShastry I cant really review matlab, my only comment is that this PR makes a lot of changes and I would break these changes down into several patches (probably one for each matlab feature/test/file). This way it's easier and faster for reviewers.
Yep, please split this to topics. E.g. one topic is compatibility with Matlab for scripts those have been apparently used with Octave. One commit per bug fixed. One commit per test improvement etc. |
For the purpose of remote device testing, this check-in adds a correction to the scripts that evaluate gain,frequency responsiveness, total harmonic distortion plus noise Signed-off-by: shastry <[email protected]>
The threshold scale has been defined and the decibel full scale computation has been made easier using new scripts. The dynamic range test is included in the test suite Relax the marker position for fr and thdn. Signed-off-by: shastry <[email protected]>
… testing The check-in overcomes Octave and Matlab compatibility issues. The performance of matlab and octave is now comparable. Signed-off-by: shastry <[email protected]>
2b2a57a
to
4060f44
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.
@ShriramShastry this is all matlab and needs @singalsu to review. I can merge when you are both aligned.
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.
Comments for first commit
n_pass = r.n_pass; | ||
n_na = r.n_na; | ||
if r.n_fail < 1 && r.n_pass < 1 | ||
fprintf('\nERROR: No test results.\n'); |
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'd like to keep the error message about no tests executed. What problem did this cause?
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 don't believe there is a problem . Test not run
should be the interpretation.
I am OK, I'II include back No test results case.
if isempty(test.thdnf_max) | ||
error('Set either thdnf_max or thdnf_mask_f & thdnf_mask_hi but not both'); | ||
elseif isempty(test.thdnf_mask_hi) | ||
error('thdnf_mask_hi must be set when thdnf_mask_f is defined'); |
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.
There's many different changes in this commit "Audio: BugFix : Enhancing audio quality tests for device testing". I'd split this further to topics (process_test, perf_test, thd+n, ...) and explain in commit message why it's done.
This change needs an own commit and explanation. To me it looks like 2nd if is wrong. What is the problem that is being fixed here?
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.
To me it looks like 2nd if is wrong.
Ahaah, Good catch . I will make the correction, This should be if
instead of elseif
crossover_quant.lp_coef(i) = [lp_a lp_b 0 16384]; | ||
crossover_quant.hp_coef(i) = [hp_a hp_b 0 16384]; | ||
crossover_quant.lp_coef{i} = [lp_a lp_b 0 16384]; | ||
crossover_quant.hp_coef{i} = [hp_a hp_b 0 16384]; |
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.
This crossover chang seems to be for Matlab compatibility patch.
measfn = sprintf('mls-%s.wav', id); | ||
csvfn = sprintf('mls-%s.txt', id); | ||
measfn = sprintf('mls-%d.wav', id); | ||
csvfn = sprintf('mls-%d.txt', id); |
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.
id is supposed to be text, why number?
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.
%s
should have returned id
, but what we get instead is a strange character, which suggests that the id
character has been lost.
sprintf('mls-%s.wav', 'id'
) and NOT sprintf('mls-%s.wav', id
) should be used if you are expecting a character id.
The second option is to set id = 'id'
and then use sprintf("mls-%s.wav", id)
to produce mls-id.wav
output
I don't think having a name is useful, hence I think a number is preferable.
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 preferred a name like id = 'notebook_x' to have more meaningful file names. Especially the .csv that is a report is useful to be an easy name to remember.
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.
fine, I will provide a name . Thanks
@@ -101,10 +101,10 @@ | |||
recfn = 'recch.wav'; | |||
y = []; | |||
if selftest | |||
labels = cell(play_cfg.nch * rec_cfg.nch + 1, 1); | |||
labels = cellstr(char(play_cfg.nch * rec_cfg.nch + 1, 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.
Next three look like Matlab compatibility changes
@@ -200,7 +200,7 @@ | |||
legend(labels); | |||
|
|||
if selftest | |||
idx = find(f < f_hi); | |||
idx = f < f_hi; |
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 personally like more find to not let this confuse idx to be a boolean. What's the benefit, I don't think this caused issues?
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.
Line Number 204, f(idx)
is an array
or `cell array' . The performance is improved using logical indexing instead of FIND. If we are not considering boolean or logical array indexing , then shape of the output vector f(idx) could change . To retain the same output shape, we should replace find(f(idx)) by 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.
Comments for 2nd commit
@@ -46,8 +46,6 @@ | |||
test = get_config(test); | |||
|
|||
%% Run tests |
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.
The topic of this commit is too generic, this looks like "Add dynamic range test to sof_test_perf.m".
@@ -88,7 +88,7 @@ | |||
test.tr = 10e-3; % Gain ramp time for tones | |||
test.sm = 3; % Seek start marker from 3s from start | |||
test.em = 3; % Seek end marker from 3s from end | |||
test.mt = 0.1; % Error if marker positions delta is greater than 0.1s | |||
test.mt = 2; % Error if marker positions delta is greater than 2s |
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.
Put this to own commit and describe (add robustness for real-device test?).
@@ -33,15 +33,17 @@ | |||
% Author: Seppo Ingalsuo <[email protected]> | |||
|
|||
%% Check if upper and lower mask is defined | |||
if length(test.fr_mask_flo) || length(test.fr_mask_fhi) | |||
if ~isempty(test.fr_mask_flo) || ~isempty(test.fr_mask_fhi) |
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.
This to first cleanup patch if this is not fixing anything, does it? Personally I find length() easier to understand than "not is empty?"
test.fr_lo = 0; | ||
test.fr_hi = 0; | ||
end | ||
if test.fr_lo > 0 || test.fr_hi > 0 | ||
test.fr_mask_flo = []; |
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.
This to separate commit, e.g. use default frequency response mask.
@@ -109,7 +111,7 @@ | |||
mask_hi = interp1(log(test.fr_mask_fhi), ... | |||
test.fr_mask_mhi(:,j), f_log, 'linear'); | |||
over_mask = test.m(:,j)-mask_hi'; | |||
idx = find(isnan(over_mask) == 0); | |||
idx = ~isnan(over_mask); |
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.
this and next to cleanup commit
@@ -6,15 +6,14 @@ | |||
% x - signal | |||
% | |||
% Output | |||
% dbfs - sigmal level in dBFS | |||
% dbfs - signal level in dBFS |
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.
to cleanup commit
% | ||
|
||
% SPDX-License-Identifier: BSD-3-Clause | ||
% Copyright(c) 2017 Intel Corporation. All rights reserved. | ||
% Author: Seppo Ingalsuo <[email protected]> | ||
|
||
%% Reference AES 17 3.12.3 | ||
level_ms = mean(x.^2); | ||
dbfs = 10*log10(level_ms + 1e-20) + 20*log10(sqrt(2)); | ||
dbfs = 20*log10(rms(x) * sqrt(2)); |
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.
cleanup
@@ -59,7 +59,7 @@ | |||
test.tr = 10e-3; % Gain ramp time for tones | |||
test.sm = 3; % Seek start marker from 3s from start | |||
test.em = 3; % Seek end marker from 3s from end | |||
test.mt = 0.1; % Error if marker positions delta is greater than 0.1s | |||
test.mt = 2; % Error if marker positions delta is greater than 2s |
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.
This is 2nd for "improve real device tests robustness"?
@@ -21,7 +21,7 @@ | |||
nt = []; | |||
nt_use = []; | |||
nt_skip = []; | |||
|
|||
trace_en = false; % Enable to trace algorithm -analysis |
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.
Find_test_signal() change to own commit and describe what the changes do.
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.
Comments for 3rd commit
@@ -57,7 +57,7 @@ | |||
level_in = test.a_db; | |||
level_out = level_dbfs(y); | |||
level_final = level_dbfs(y_n); | |||
test.dr_db = level_out-level_final-test.a_db; | |||
test.dr_db = level_out - level_final - test.a_db; |
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.
This is not compatibility but a code cleanup, goes to first commit.
fidx = find(test.thdnf(idx, 1) > mask_hi); | ||
if length(fidx) > 0 | ||
fidx = find(test.thdnf(idx, 1) > mask_hi, 1); | ||
if ~isempty(fidx) |
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.
Is this for Matlab compatibility? Looks more like cleanup, though I'm not 100% sure. Please check.
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.
isempty
is faster than comparing length
to 0
. Since it is a general performance improvement, compatibility section does not apply to it.
@@ -4,7 +4,7 @@ | |||
% Copyright(c) 2017 Intel Corporation. All rights reserved. | |||
% Author: Seppo Ingalsuo <[email protected]> | |||
|
|||
%% Adjust tone lengt to integer number of samples | |||
%% Adjust tone length to integer number of samples |
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.
To cleanup
@@ -29,13 +29,13 @@ | |||
|
|||
% Generate the a,b coefficients for a second order | |||
% low pass butterworth filter | |||
function lp = lp_iir(fs, fc, gain_db) | |||
function lp = lp_iir(fs, fc, ~) |
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.
Please explain why gain_db is removed? It does not look like Matlab compatibility change.
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.
Yes, I agree that I don't see the compatibility between Octave and Matlab as a problem, more as a general coding error.
If you recommend more commits for general improvement, I'm happy to integrate them.
First option: Input argument gain_db
is unused, so this is OK, to be replaced with ~
i.e. avoid addition text label. There is a typographical error in the declaration. The body of the function does not use specified input argument.
or
Second option: lp_iir()
should be 2 input argument instead of 3. but this need change across the all files across the code base. In the current code, the calling routines are filled with 0
all over for 3rd input argument.
So I opted first option
blob_fn = "../../ctl/crossover_coef.blob" % Blob binary file | ||
alsa_fn = "../../ctl/crossover_coef.txt" % ALSA CSV format file | ||
blob_fn = "../../ctl/crossover_coef.blob"; % Blob binary file | ||
alsa_fn = "../../ctl/crossover_coef.txt"; % ALSA CSV format file |
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.
These are cleanup, not compatibility.
@@ -41,7 +41,7 @@ | |||
|
|||
%% Define target (e.g. speaker) response as parametric filter. This could also | |||
% be numerical data interpolated to the grid. | |||
if length(eq.parametric_target_response) > 0 | |||
if ~isempty(eq.parametric_target_response) |
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.
Are these length() vs. ~isempty() cleanup or Matlab compatibility?
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.
The execution speed of isempty
is faster then comparing length
to 0
, therefore the proposal is replace length
with isempty
@@ -342,13 +342,13 @@ | |||
%% Find zeros inside unit circle | |||
myeps = 1e-3; | |||
hdzeros = roots(blin); | |||
ind1 = find( abs(hdzeros) < (1-myeps) ); | |||
ind1 = abs(hdzeros) < (1-myeps) ; |
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.
Extra blanks before ; in this and next ones.
b = [A * A, 0, 0]; | ||
a = [1, 0, 0]; | ||
return; | ||
end |
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.
cleanup, not a compatibility change
b = [0, 0, 0]; | ||
a = [1, 0, 0]; | ||
return; | ||
end |
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.
cleanup, not compatibility. Also no point to change indent by 8 to 4. Since FW code uses 8 with tab, we could default to it for Matlab. The indents are well visible with 8, and a huge accumulated indent indicates issue in code.
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, I will change my editor indent settings with 8. Thanks !!
eq.fir_length = 63; | ||
eq.fir_autoband = 0; | ||
eq.fmin_fir = 900; | ||
eq.fmax_fir = 10700; |
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.
Please set up your Matlab to indent by 8, also prefer tab if possible. Unnecessary change.
@@ -139,18 +139,15 @@ | |||
fprintf('Number of skipped tests = %d\n', r.n_skipped); | |||
fprintf('============================================================\n'); | |||
|
|||
n_fail = r.n_fail; |
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.
Please prefix all your commit titles with Tools: Test: So that reviewers and and other git log viewers know what these are about. These do not contain changes for audio components.
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 have included my comments. For other's comments, I'll make the necessary changes for the code check-in.
measfn = sprintf('mls-%s.wav', id); | ||
csvfn = sprintf('mls-%s.txt', id); | ||
measfn = sprintf('mls-%d.wav', id); | ||
csvfn = sprintf('mls-%d.txt', id); |
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.
%s
should have returned id
, but what we get instead is a strange character, which suggests that the id
character has been lost.
sprintf('mls-%s.wav', 'id'
) and NOT sprintf('mls-%s.wav', id
) should be used if you are expecting a character id.
The second option is to set id = 'id'
and then use sprintf("mls-%s.wav", id)
to produce mls-id.wav
output
I don't think having a name is useful, hence I think a number is preferable.
@@ -200,7 +200,7 @@ | |||
legend(labels); | |||
|
|||
if selftest | |||
idx = find(f < f_hi); | |||
idx = f < f_hi; |
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.
Line Number 204, f(idx)
is an array
or `cell array' . The performance is improved using logical indexing instead of FIND. If we are not considering boolean or logical array indexing , then shape of the output vector f(idx) could change . To retain the same output shape, we should replace find(f(idx)) by f(:).
Can one of the admins verify this patch? |
For the purpose of remote device testing, this check-in adds a correction to the scripts that evaluate gain,
frequency responsiveness, total harmonic distortion plus noise, and dynamic range.
The threshold scale has been defined and the decibel full scale computation has been made easier using new scripts.
You require Octave or Matlab. The scripts now operate properly in both Matlab and octave.
The user account, audio device, audio format, and capture sound card audio device and audio format for the remote device must be modified in the configuration file sof test perf config.m.
Signed-off-by: shastry [email protected]