diff --git a/scripts/sof-rebuild-processing-comp-blobs.sh b/scripts/sof-rebuild-processing-comp-blobs.sh new file mode 100755 index 000000000000..26410c811259 --- /dev/null +++ b/scripts/sof-rebuild-processing-comp-blobs.sh @@ -0,0 +1,28 @@ +#!/bin/bash +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2024 Intel Corporation. + +set -e + +if [ -z "${SOF_WORKSPACE}" ]; then + echo "Error: environment variable SOF_WORKSPACE need to be set to top level sof directory" + exit 1 +fi + +if ! command -v octave &> /dev/null; then + echo "Error: this scrip needs GNU Octave, see https://octave.org/" + exit 1 +fi + +OCTAVE="octave --quiet --no-window-system" +cd "$SOF_WORKSPACE"/sof/src/audio/aria/tune; $OCTAVE sof_aria_blobs.m +cd "$SOF_WORKSPACE"/sof/src/audio/crossover/tune; $OCTAVE sof_example_crossover.m +cd "$SOF_WORKSPACE"/sof/src/audio/dcblock/tune; $OCTAVE sof_example_dcblock.m +cd "$SOF_WORKSPACE"/sof/src/audio/drc/tune; $OCTAVE sof_example_drc.m +cd "$SOF_WORKSPACE"/sof/src/audio/eq_iir/tune; $OCTAVE sof_example_iir_eq.m +cd "$SOF_WORKSPACE"/sof/src/audio/eq_iir/tune; $OCTAVE sof_example_fir_eq.m +cd "$SOF_WORKSPACE"/sof/src/audio/eq_iir/tune; $OCTAVE sof_example_iir_bandsplit.m +cd "$SOF_WORKSPACE"/sof/src/audio/eq_iir/tune; $OCTAVE sof_example_spk_eq.m +cd "$SOF_WORKSPACE"/sof/src/audio/multiband_drc/tune; $OCTAVE sof_example_multiband_drc.m +cd "$SOF_WORKSPACE"/sof/src/audio/tdfb/tune; ./sof_example_all.sh +cd "$SOF_WORKSPACE"/sof/tools/tune/mfcc; $OCTAVE setup_mfcc.m diff --git a/src/audio/tdfb/tune/sof_bf_defaults.m b/src/audio/tdfb/tune/sof_bf_defaults.m index 6e530c52d065..cf8e8838ed32 100644 --- a/src/audio/tdfb/tune/sof_bf_defaults.m +++ b/src/audio/tdfb/tune/sof_bf_defaults.m @@ -14,7 +14,7 @@ bf.fir_length = 64; % 64 tap FIR filters bf.kaiser_beta = 10; % Beta for kaiser window method FIR design bf.mu_db = -40; % dB of diagonal loading to noise covariance matrix -bf.do_plots = 1; +bf.do_plots = 0; bf.plot_box = 0.20; % Show 20cm wide plot cube for array geometry bf.array_angle = [0 0 0]; % Array rotation angles for xyz bf.tplg_fn = ''; @@ -29,6 +29,7 @@ bf.data_path = './data'; bf.endian = 'little'; bf.fn = 1; +bf.create_simulation_data = false; bf.sinerot_a = 10^(-20/20); bf.sinerot_f = 2e3; bf.sinerot_t = 1.0; diff --git a/src/audio/tdfb/tune/sof_bf_design.m b/src/audio/tdfb/tune/sof_bf_design.m index 010e48b2c94d..5121ebe6630f 100644 --- a/src/audio/tdfb/tune/sof_bf_design.m +++ b/src/audio/tdfb/tune/sof_bf_design.m @@ -374,73 +374,74 @@ end %% Create data for simulation 1s per angle +if bf.create_simulation_data + if isempty(bf.sinerot_fn) + fprintf(1, 'No file for 360 degree sine source rotate specified\n'); + else + rotate_sound_source(bf, bf.sinerot_fn, 'sine'); + end -if isempty(bf.sinerot_fn) - fprintf(1, 'No file for 360 degree sine source rotate specified\n'); -else - rotate_sound_source(bf, bf.sinerot_fn, 'sine'); -end - -if isempty(bf.noiserot_fn) - fprintf(1, 'No file for 360 degree random noise source rotate specified\n'); -else - rotate_sound_source(bf, bf.noiserot_fn, 'noise'); -end + if isempty(bf.noiserot_fn) + fprintf(1, 'No file for 360 degree random noise source rotate specified\n'); + else + rotate_sound_source(bf, bf.noiserot_fn, 'noise'); + end -if isempty(bf.diffuse_fn) - fprintf(1, 'No file for diffuse noise field specified\n'); -else - fprintf(1, 'Creating diffuse noise field...\n'); - fsi = 384e3; % Target interpolated rate - p = round(fsi / bf.fs); % Interpolation factor - fsi = p * bf.fs; % Recalculate high rate - ti = 1/fsi; % period at higher rate - t_add = 10.0/bf.c; % Additional signal time for max 20m propagation - t0 = bf.diffuse_t + t_add; % Total sine length per angle - n0 = floor(bf.fs * t0); - nt = floor(bf.fs * bf.diffuse_t); % Number samples output per angle - nti = p * nt; % Number samples output per angle at high rate - el = 0; - for az_deg = -160:20:180 % Azimuth plane only noise with sources - az = az_deg * pi/180; - [nx, ny, nz] = source_xyz(bf.steer_r, az, el); - dt = delay_from_source(bf, nx, ny, nz); - dn = round(dt / ti); - ns = rand(n0, 1) + rand(n0, 1) - 1; - nsi = interp(ns, p); - nmi = zeros(nti, bf.mic_n); - for j = 1:bf.mic_n - nmi(:,j) = nmi(:,j) + nsi(end-dn(j)-nti+1:end-dn(j)); + if isempty(bf.diffuse_fn) + fprintf(1, 'No file for diffuse noise field specified\n'); + else + fprintf(1, 'Creating diffuse noise field...\n'); + fsi = 384e3; % Target interpolated rate + p = round(fsi / bf.fs); % Interpolation factor + fsi = p * bf.fs; % Recalculate high rate + ti = 1/fsi; % period at higher rate + t_add = 10.0/bf.c; % Additional signal time for max 20m propagation + t0 = bf.diffuse_t + t_add; % Total sine length per angle + n0 = floor(bf.fs * t0); + nt = floor(bf.fs * bf.diffuse_t); % Number samples output per angle + nti = p * nt; % Number samples output per angle at high rate + el = 0; + for az_deg = -160:20:180 % Azimuth plane only noise with sources + az = az_deg * pi/180; + [nx, ny, nz] = source_xyz(bf.steer_r, az, el); + dt = delay_from_source(bf, nx, ny, nz); + dn = round(dt / ti); + ns = rand(n0, 1) + rand(n0, 1) - 1; + nsi = interp(ns, p); + nmi = zeros(nti, bf.mic_n); + for j = 1:bf.mic_n + nmi(:,j) = nmi(:,j) + nsi(end-dn(j)-nti+1:end-dn(j)); + end end + nm = nmi(1:p:end, :); + nlev = level_dbfs(nm(:,1)); + nm = nm * 10^((bf.diffuse_lev - nlev)/20); + myaudiowrite(bf.diffuse_fn, nm, bf.fs); end - nm = nmi(1:p:end, :); - nlev = level_dbfs(nm(:,1)); - nm = nm * 10^((bf.diffuse_lev - nlev)/20); - myaudiowrite(bf.diffuse_fn, nm, bf.fs); -end -if isempty(bf.random_fn) - fprintf(1, 'No file for random noise specified\n'); -else - fprintf(1, 'Creating random noise ...\n'); - nt = bf.fs * bf.random_t; - rn = rand(nt, bf.num_filters) + rand(nt, bf.num_filters) - 1; + if isempty(bf.random_fn) + fprintf(1, 'No file for random noise specified\n'); + else + fprintf(1, 'Creating random noise ...\n'); + nt = bf.fs * bf.random_t; + rn = rand(nt, bf.num_filters) + rand(nt, bf.num_filters) - 1; - nlev = level_dbfs(rn(:,1)); - rn = rn * 10^((bf.random_lev - nlev)/20); - myaudiowrite(bf.random_fn, rn, bf.fs); -end + nlev = level_dbfs(rn(:,1)); + rn = rn * 10^((bf.random_lev - nlev)/20); + myaudiowrite(bf.random_fn, rn, bf.fs); + end -if isempty(bf.mat_fn) - fprintf(1, 'No file for beam pattern simulation data specified.\n'); -else - fprintf(1, 'Saving design to %s\n', bf.mat_fn); - bf_copy = bf; - bf.fh = []; % Don't save the large figures, this avoids a warning print too - mkdir_check(bf.data_path); - save(bf.mat_fn, 'bf'); - bf = bf_copy; + if isempty(bf.mat_fn) + fprintf(1, 'No file for beam pattern simulation data specified.\n'); + else + fprintf(1, 'Saving design to %s\n', bf.mat_fn); + bf_copy = bf; + bf.fh = []; % Don't save the large figures, this avoids a warning print too + mkdir_check(bf.data_path); + save(bf.mat_fn, 'bf'); + bf = bf_copy; + end end fprintf(1, 'Done.\n'); diff --git a/src/audio/tdfb/tune/sof_example_all.sh b/src/audio/tdfb/tune/sof_example_all.sh index 2a7b45b3833c..2a263f3438f5 100755 --- a/src/audio/tdfb/tune/sof_example_all.sh +++ b/src/audio/tdfb/tune/sof_example_all.sh @@ -12,14 +12,14 @@ OCTAVE_CMD=( octave --no-window-system ) MATLAB_CMD=( matlab -nodisplay -batch ) main () { - if command -v matlab &> /dev/null; then - echo "Using Matlab" - CMD=( "${MATLAB_CMD[@]}" ) - EXT= - elif command -v octave &> /dev/null; then + if command -v octave &> /dev/null; then echo "Using Octave" CMD=( "${OCTAVE_CMD[@]}" ) EXT=".m" + elif command -v matlab &> /dev/null; then + echo "Using Matlab" + CMD=( "${MATLAB_CMD[@]}" ) + EXT= else echo "Please install Matlab or Octave to run this script." exit 1