1function test = aip_test_measure(test) 2 3% SPDX-License-Identifier: BSD-3-Clause 4% Copyright(c) 2019 Intel Corporation. All rights reserved. 5% Author: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com> 6 7%% Reference: AES17 6.6.7 Attenuation of image products 8% http://www.aes.org/publications/standards/ 9 10%% Load output file 11[x, nx] = load_test_output(test); 12if nx == 0 13 test.g_db = NaN; 14 test.fail = 1; 15 return 16end 17 18%% Find sync 19[d, nt, nt_use, nt_skip] = find_test_signal(x, test); 20 21%% Measure all test frequencies 22t_skip = 1.0; 23ml = zeros(test.nf,1); 24mn = zeros(test.nf,1); 25b_lpf = stdlpf_get(test.fu, test.fs); % Get LPF coef 26b_hpf = stdhpf_get(test.fu, test.fs); % Get HPF coef 27for n=1:test.nf 28 fprintf('Measuring %.0f Hz ...\n', test.f(n)); 29 % Get notch coef for this frequency 30 [b_notch, a_notch] = stdnotch_get(test.f(n), test.fs); 31 i1 = d+(n-1)*nt+nt_skip; 32 i2 = i1+nt_use-1; 33 x_lpf = filter(b_lpf, 1, x(i1:i2)); % Standard LPF, need for 997 Hz only 34 x_notch = filter(b_notch, a_notch, x(i1:i2)); % Standard notch 35 x_hpf = filter(b_hpf, 1, x_notch); % Standard HPF 36 ml(n) = level_dbfs(x_lpf(round(t_skip*test.fs):end)); 37 mn(n) = level_dbfs(x_hpf(round(t_skip*test.fs):end)); 38end 39 40%% Calculate levels relative to first 997 Hz frequency, 41% remove it from result, sort to ascinding order for plot 42test.f = test.f(2:end); 43test.m = mn(2:end)-ml(1); 44test.aip = max(test.m); % Worst-case 45if test.aip > test.aip_max 46 test.fail = 1; 47else 48 test.fail = 0; 49end 50 51test.fh = figure('visible', test.plot_visible); 52semilogx(test.f, test.m); 53grid on; 54xlabel('Frequency (Hz)'); 55ylabel('Relative level (dB)'); 56grid on; 57 58end 59