Skip to content

Commit fcbd150

Browse files
committed
Tools: Add option to plot levels with check_volume_levels.m
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 <seppo.ingalsuo@linux.intel.com>
1 parent b3c3446 commit fcbd150

1 file changed

Lines changed: 17 additions & 8 deletions

File tree

tools/check_volume_levels.m

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
function check_volume_levels(cmd, fn1, fn2, fn3)
1+
function check_volume_levels(cmd, fn1, fn2, fn3, do_plot)
22

33
% check_volume_levels(cmd, fn1, fn2, fn3)
44
%
@@ -7,15 +7,21 @@ function check_volume_levels(cmd, fn1, fn2, fn3)
77
% fn1 - File name for sine wave to generate or first record file name to analyze
88
% fn2 - File name to analyze 2nd
99
% fn3 - File name to analyze 3rd
10+
% do_plot - Plot figure of levels if 1, defaults to 0
1011
%
1112
% E.g.
1213
% check_volume_levels('generate','sine.wav');
1314
% check_volume_levels('measure','rec1.wav','rec2.wav','rec3.wav');
15+
% check_volume_levels('measure','rec1.wav','rec2.wav','rec3.wav', 1);
1416

1517
% SPDX-License-Identifier: BSD-3-Clause
1618
% Copyright(c) 2016 Intel Corporation. All rights reserved.
1719
% Author: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
1820

21+
if nargin < 5
22+
do_plot = 0;
23+
end
24+
1925
addpath('../../sof/tools/test/audio/std_utils');
2026
addpath('../../sof/tools/test/audio/test_utils');
2127

@@ -32,7 +38,7 @@ function check_volume_levels(cmd, fn1, fn2, fn3)
3238
error('FAIL');
3339
end
3440
case 'measure'
35-
pass = measure(fn1, fn2, fn3);
41+
pass = measure(fn1, fn2, fn3, do_plot);
3642
if pass
3743
fprintf(1, 'PASS\n');
3844
else
@@ -64,7 +70,7 @@ function check_volume_levels(cmd, fn1, fn2, fn3)
6470
end
6571

6672

67-
function pass = measure(fn1, fn2, fn3)
73+
function pass = measure(fn1, fn2, fn3, do_plot)
6874

6975
% General test defaults
7076
lm.tgrid = 5e-3; % Return level per every 5ms
@@ -87,7 +93,7 @@ function check_volume_levels(cmd, fn1, fn2, fn3)
8793
t1.vtol = 0.5; % Pass test with max +/- 0.5 dB mismatch
8894

8995
% Check test 1
90-
pass1 = level_vs_time_checker(fn1, t1, lm, '1/3');
96+
pass1 = level_vs_time_checker(fn1, t1, lm, '1/3', do_plot);
9197

9298
% Default gains for test 2
9399
m1 = [vmut vnom vnom vmut];
@@ -100,7 +106,7 @@ function check_volume_levels(cmd, fn1, fn2, fn3)
100106
t2.vtol = t1.vtol; % Same as previous
101107

102108
% Check test 2
103-
pass2 = level_vs_time_checker(fn2, t2, lm, '2/3');
109+
pass2 = level_vs_time_checker(fn2, t2, lm, '2/3', do_plot);
104110

105111
% Default gains for test 3
106112
vol_ch1 = [ vmut vmut m2(1) vnom ];
@@ -111,7 +117,7 @@ function check_volume_levels(cmd, fn1, fn2, fn3)
111117
t3.vtol = t1.vtol; % Same as previous
112118

113119
% Check test 3
114-
pass3 = level_vs_time_checker(fn3, t3, lm, '3/3');
120+
pass3 = level_vs_time_checker(fn3, t3, lm, '3/3', do_plot);
115121

116122
if pass1 == 1 && pass2 == 1 && pass3 == 1
117123
pass = 1;
@@ -121,11 +127,13 @@ function check_volume_levels(cmd, fn1, fn2, fn3)
121127

122128
end
123129

124-
function pass = level_vs_time_checker(fn, tc, lm, id)
130+
function pass = level_vs_time_checker(fn, tc, lm, id, do_plot)
125131
fprintf(1, 'File %s:\n', fn);
126132

127133
lev = level_vs_time(fn, lm);
128-
%plot_levels(lev, tc, lm);
134+
if do_plot
135+
plot_levels(lev, tc, lm);
136+
end
129137
pass = check_levels(lev, tc, lm, 1);
130138
if pass
131139
fprintf(1, 'pass (%s)\n', id);
@@ -183,6 +191,7 @@ function plot_levels(meas, tc, lm)
183191
hold off;
184192
xlabel('Time (s)');
185193
ylabel('Gain (dB)');
194+
grid on;
186195
end
187196

188197
function pass = check_levels(meas, tc, lm, verbose)

0 commit comments

Comments
 (0)