Skip to content

Commit

Permalink
Tools: Remove dependency to SOF from check_volume_levels.m
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
singalsu committed Mar 3, 2023
1 parent 9239986 commit 1218c95
Showing 1 changed file with 26 additions and 3 deletions.
29 changes: 26 additions & 3 deletions tools/check_volume_levels.m
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@ function check_volume_levels(cmd, fn1, fn2, fn3, do_plot)
do_plot = 0;
end

addpath('../../sof/tools/test/audio/std_utils');
addpath('../../sof/tools/test/audio/test_utils');

if exist('OCTAVE_VERSION', 'builtin')
pkg load signal
end
Expand Down Expand Up @@ -282,3 +279,29 @@ function plot_levels(meas, tc, lm)
y(:,j) = filter(b, a, x(:,j));
end
end

% This function is copy of
% sof/tools/test/audio/test_utils/multitone.m
function x = multitone( fs, f, amp, tlength )
n = round(fs*tlength);
t = (0:n-1)/fs;
nf = length(f);
if nf > 1
ph = rand(nf, 1)*2*pi;
else
ph = 0;
end

x = zeros(n, 1);
for i=1:length(f)
x = x + amp(i)*sin(2*pi*f(i)*t+ph(i))';
end
end

% This function is copy of
% sof/tools/test/audio/std_utils/level_dbfs.m
function dbfs = level_dbfs(x)
%% Reference AES 17 3.12.3
level_ms = mean(x.^2);
dbfs = 10*log10(level_ms + 1e-20) + 20*log10(sqrt(2));
end

0 comments on commit 1218c95

Please sign in to comment.