1% bf_export(bf) 2% 3% Inputs 4% bf.sofctl_fn ..... filename of ascii text format blob 5% bf.tplg_fn ....... filename of topology m4 format blob 6% bf ............... the design procedure output 7 8% SPDX-License-Identifier: BSD-3-Clause 9% 10% Copyright (c) 2020, Intel Corporation. All rights reserved. 11% 12% Author: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com> 13 14function bf = bf_export(bf) 15 16% Use functionc from EQ tool, test utils 17addpath('../eq'); 18addpath('../../test/audio/test_utils'); 19 20%% Add needed default controls if missing 21 22% Num of filters same as number of microphones 23if isempty(bf.num_filters) 24 bf.num_filters = bf.mic_n; 25end 26 27% Use all inputs linearly 28if isempty(bf.input_channel_select) 29 bf.input_channel_select = 0:bf.num_filters - 1; 30end 31 32% Mix all filters to all output channels 33if isempty(bf.output_channel_mix) 34 bf.output_channel_mix = sum(2.^(0:(bf.num_output_channels - 1))) * ... 35 ones(1, bf.num_filters); 36end 37 38% Mix all filters to all output channels 39if isempty(bf.output_channel_mix_beam_off) 40 if (bf.num_output_channels == bf.num_filters) 41 bf.output_channel_mix_beam_off = 2.^(0:(bf.num_output_channels - 1)); 42 else 43 fprintf(1, 'Number of output channels: %d\n', bf.num_output_channels); 44 fprintf(1, 'Number of filters: %d\n', bf.num_filters); 45 error('Need to specify output_channel_mix_beam_off'); 46 end 47end 48 49% All to first output stream 50if isempty(bf.output_stream_mix) 51 bf.output_stream_mix = zeros(1, bf.num_filters); 52end 53 54 55%% Quantize filters 56filters = []; 57for j=1:bf.num_angles 58 for i=1:bf.num_filters 59 coefs = squeeze(bf.w(:,i,j)); 60 bq = eq_fir_blob_quant(coefs, 16, 0); 61 filters = [filters bq ]; 62 end 63end 64 65%% Add beam-off preset 66if bf.beam_off_defined 67 b_pass = [1]; 68 bq = eq_fir_blob_quant(b_pass, 16, 0); 69 for i=1:bf.num_filters 70 filters = [filters bq ]; 71 end 72end 73 74%% Build blob 75bf.all_filters = filters; 76bp = bf_blob_pack(bf); 77 78%% Export 79if isempty(bf.sofctl_fn) 80 fprintf(1, 'No sof-ctl output file specified.\n'); 81else 82 fprintf(1, 'Exporting to %s\n', bf.sofctl_fn); 83 mkdir_check(bf.sofctl_path); 84 eq_alsactl_write(bf.sofctl_fn, bp); 85end 86 87if isempty(bf.tplg_fn) 88 fprintf(1, 'No topology output file specified.\n'); 89else 90 fprintf(1, 'Exporting to %s\n', bf.tplg_fn); 91 mkdir_check(bf.tplg_path); 92 eq_tplg_write(bf.tplg_fn, bp, 'DEF_TDFB_PRIV'); 93end 94 95end 96