Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scripts: Add script to rebuild all configuration blobs for processing #9751

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions scripts/sof-rebuild-processing-comp-blobs.sh
Original file line number Diff line number Diff line change
@@ -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
3 changes: 2 additions & 1 deletion src/audio/tdfb/tune/sof_bf_defaults.m
Original file line number Diff line number Diff line change
Expand Up @@ -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 = '';
Expand All @@ -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;
Expand Down
119 changes: 60 additions & 59 deletions src/audio/tdfb/tune/sof_bf_design.m
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
10 changes: 5 additions & 5 deletions src/audio/tdfb/tune/sof_example_all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading