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 10debug = 0; 11 12%% Load output file 13[x, nx] = load_test_output(test); 14if nx == 0 15 test.g_db = NaN; 16 test.fail = 1; 17 return 18end 19 20%% Find sync 21[d, nt, nt_use, nt_skip] = find_test_signal(x, test); 22 23%% Measure all test frequencies 24t_skip = 1.0; 25ml = zeros(test.nf,1); 26mn = zeros(test.nf,1); 27b_lpf = stdlpf_get(test.fu, test.fs); % Get LPF coef 28b_hpf = stdhpf_get(test.fu, test.fs); % Get HPF coef 29for n=1:test.nf 30 if debug 31 fprintf('Measuring %.0f Hz ...\n', test.f(n)); 32 end 33 % Get notch coef for this frequency 34 [b_notch, a_notch] = stdnotch_get(test.f(n), test.fs); 35 i1 = d+(n-1)*nt+nt_skip; 36 i2 = i1+nt_use-1; 37 x_lpf = filter(b_lpf, 1, x(i1:i2)); % Standard LPF, need for 997 Hz only 38 x_notch = filter(b_notch, a_notch, x(i1:i2)); % Standard notch 39 x_hpf = filter(b_hpf, 1, x_notch); % Standard HPF 40 ml(n) = level_dbfs(x_lpf(round(t_skip*test.fs):end)); 41 mn(n) = level_dbfs(x_hpf(round(t_skip*test.fs):end)); 42end 43 44%% Calculate levels relative to first 997 Hz frequency, 45% remove it from result, sort to ascinding order for plot 46test.f = test.f(2:end); 47test.m = mn(2:end)-ml(1); 48test.aip = max(test.m); % Worst-case 49if test.aip > test.aip_max 50 test.fail = 1; 51else 52 test.fail = 0; 53end 54 55test.fh = figure('visible', test.plot_visible); 56semilogx(test.f, test.m); 57grid on; 58xlabel('Frequency (Hz)'); 59ylabel('Relative level (dB)'); 60grid on; 61 62end 63