1function test = g_test_measure(test) 2 3% SPDX-License-Identifier: BSD-3-Clause 4% Copyright(c) 2017 Intel Corporation. All rights reserved. 5% Author: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com> 6 7%% Reference: AES17 6.2.2 Gain 8% http://www.aes.org/publications/standards/ 9 10default_result = NaN * ones(1,length(test.ch)); 11test.g_db = default_result; 12 13%% Load output file 14[x, nx] = load_test_output(test); 15 16if nx == 0 17 test.fail = 1; 18 return 19end 20 21%% Standard low-pass 22y0 = stdlpf(x, test.fu, test.fs); 23 24%% Find sync 25[d, nt, nt_use, nt_skip] = find_test_signal(y0, test); 26if isempty(d) 27 test.fail = 1; 28 return 29end 30 31%% Trim sample by removing first 1s to let the notch to apply 32i1 = d+nt_skip; 33i2 = i1+nt_use-1; 34y = y0(i1:i2, :); 35 36%% Gain, SNR 37level_in = test.a_db; 38level_out = level_dbfs(y); 39test.g_db = level_out - level_in + test.att_rec_db; 40for i = 1:length(test.g_db) 41 fprintf('Gain = %6.3f dB (expect %6.3f dB)\n', test.g_db(i), test.g_db_expect(i)); 42end 43 44%% Check pass/fail 45test.fail = 0; 46delta_abs = abs(test.g_db_expect - test.g_db); 47idx = find(delta_abs > test.g_db_tol); 48for i = 1:length(idx) 49 fprintf('Failed ch%d gain %f dB (max %f dB)\n', test.ch(i), test.g_db(i), test.g_db_tol); 50 test.fail = 1; 51end 52 53end 54