1%% Run test with remote/local playback and capture 2% 3% remote_test_run(test); 4% 5% Inputs: 6% test.play_cfg - configuration for playback device 7% test.fn_in - filename for audio input 8% test.length_t - length of audio input in seconds 9% test.rec_cfg - configuration for audio capture device 10% test.fn_out - filename for audio output 11% 12% Outputs: 13% 14 15% SPDX-License-Identifier: BSD-3-Clause 16% Copyright(c) 2019 Intel Corporation. All rights reserved. 17% Author: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com> 18 19function test = remote_test_run(test) 20 21remote_copy_playback(test.fn_in, test.play_cfg); 22tcap = floor(3 + test.length_t); 23remote_capture(test.fn_out, test.rec_cfg, tcap); 24remote_play(test.fn_in, test.play_cfg); 25pause(3); 26remote_copy_capture(test.fn_out, test.rec_cfg); 27 28end 29 30function remote_copy_playback(fn, cfg) 31if cfg.ssh 32 cmd = sprintf('scp %s %s:%s/', fn, cfg.user, cfg.dir); 33 fprintf('Remote copy: %s\n', cmd); 34 system(cmd); 35else 36 cmd = sprintf('cp %s %s/', fn, cfg.dir); 37 fprintf('Local copy: %s\n', cmd); 38end 39end 40 41function y = remote_copy_capture(fn, cfg) 42if cfg.ssh 43 cmd = sprintf('scp %s:%s/%s %s', cfg.user, cfg.dir, fn, fn); 44 del = sprintf('ssh %s rm %s/%s', cfg.user, cfg.dir, fn); 45 fprintf('Remote copy: %s\n', cmd); 46else 47 cmd = sprintf('cp %s/%s %s', cfg.dir, fn, fn); 48 del = sprintf('rm %s/%s', cfg.dir, fn); 49 fprintf('Local copy: %s\n', cmd); 50end 51system(cmd); 52system(del); 53end 54 55function remote_play(fn, cfg) 56if cfg.ssh 57 cmd = sprintf('ssh %s aplay -D%s %s/%s', cfg.user, cfg.dev, cfg.dir, fn); 58 del = sprintf('ssh %s rm %s/%s', cfg.user, cfg.dir, fn); 59 fprintf('Remote play: %s\n', cmd); 60else 61 cmd = sprintf('aplay -D%s %s/%s', cfg.dev, cfg.dir, fn); 62 del = sprintf('rm %s/%s', cfg.dir, fn); 63 fprintf('Local play: %s\n', cmd); 64end 65system(cmd); 66system(del); 67end 68 69function remote_capture(fn, cfg, t) 70if cfg.ssh 71 cmd = sprintf('ssh %s arecord -q -D%s %s -d %d %s/%s &', ... 72 cfg.user, cfg.dev, cfg.fmt, t, cfg.dir, fn); 73 fprintf('Remote capture: %s\n', cmd); 74else 75 cmd = sprintf('arecord -q -D%s %s -d %d %s/%s &', ... 76 cfg.dev, cfg.fmt, t, cfg.dir, fn); 77 fprintf('Local capture: %s\n', cmd); 78end 79system(cmd); 80end 81