1function test = aap_test_input(test) 2 3%% t = aap_test_input(t) 4% 5% Create frequency sweep data file for playback & record on real device or 6% for algorithm simulation. 7% 8% Input parameters 9% t.f_start - start frequency 10% t.f_end - end frequency 11% t.fs - sample rate 12% t.bits_in - number of bits in signal 13% t.ch - mix test signal to channel ch 14% t.nch - total number of channels in data 15% 16% Output parameters 17% t.fn_in - created input file name 18% t.fn_out - proposed output file name for captured output 19% t.f - frequencies in sweep 20% t.nf - number of frequencies 21% t.tl - tone length in seconds 22% t.ts - tone start times 23% t.tr - tone gain ramp length in seconds 24% t.ti - ignore time from tone start and end, must be ti > tr 25% t.a - tone amplitude (lin) 26% t.a_db - tone amplitude (dB) 27% t.mark_t - length of marker tone in seconds 28% t.mark_a - amplitude max of marker tone (lin) 29% t.mark_a_db - amplitude max of marker tone (dB) 30% 31 32%% 33% Copyright (c) 2017, Intel Corporation 34% All rights reserved. 35% 36% Redistribution and use in source and binary forms, with or without 37% modification, are permitted provided that the following conditions are met: 38% * Redistributions of source code must retain the above copyright 39% notice, this list of conditions and the following disclaimer. 40% * Redistributions in binary form must reproduce the above copyright 41% notice, this list of conditions and the following disclaimer in the 42% documentation and/or other materials provided with the distribution. 43% * Neither the name of the Intel Corporation nor the 44% names of its contributors may be used to endorse or promote products 45% derived from this software without specific prior written permission. 46% 47% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 48% AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 49% IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 50% ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 51% LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 52% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 53% SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 54% INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 55% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 56% ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 57% POSSIBILITY OF SUCH DAMAGE. 58% 59% Author: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com> 60% 61 62%% Reference: AES17 6.6.6 Attenuation of alias products 63% http://www.aes.org/publications/standards/ 64 65if nargin < 1 66 error('This function must be called with argunment.'); 67end 68 69if test.ch == 0 70 test.ch = 1+round(rand(1,1)*(test.nch-1)); % Test random channel 1..Nch 71end 72 73fprintf('Using parameters Fstart=%d Hz, Fend=%d Hz, Fs=%.1f kHz, bits_in=%d, ch=%d, nch=%d\n', ... 74 test.f_start, test.f_end, test.fs, test.bits_in, test.ch, test.nch); 75 76 77test.fn_in = sprintf('aap_test_in.%s', test.fmt); 78test.fn_out = sprintf('aap_test_out.%s', test.fmt); 79f_first = 997; 80f_max = max(test.f_start, test.f_end); 81f_min = min(test.f_start, test.f_end); 82n_third = ceil(log(f_max/f_min)/log(2)*3); % max 1/3 octave step 83steps = max(n_third, 50); % Min 50 steps 84test.f = [f_first logspace(log10(test.f_start), log10(test.f_end), steps) ]; 85 86%% Tone sweep parameters 87test.is = 20e-3; % Ignore signal from tone start 88test.ie = 20e-3; % Ignore signal from tone end 89test.tr = 10e-3; % Gain ramp time for tones 90test.sm = 3; % Seek start marker from 3s from start 91test.em = 3; % Seek end marker from 3s from end 92test.mt = 0.3; % Error if marker positions delta is greater than 0.3s 93test.tc = 20; % Min. 20 cycles of sine wave for a frequency 94t_min = 0.2; 95test.a_db = -20; 96test.a = 10^(test.a_db/20); 97% Use t_min or min cycles count as tone length 98test.tl = max(test.tc*1/min(test.f),t_min); 99 100%% Mix the input file for test and write output 101test = mix_sweep(test); 102 103end 104