Ver código fonte

update design example with Octathingy specific code, add first version of code that tries to measure the z axis wobble during the calibration measurements (with the goal of fixing it)

Fernando Pablo Lopez-Lezcano 9 anos atrás
pai
commit
9af24bb643

+ 35 - 0
calibration/src/sphear_af_fix_wobble.m

@@ -0,0 +1,35 @@
+%% -*- mode: octave -*-
+%%
+%% *SpHEAR Project
+%%
+%% sphear_signal_arrival_times: measure rotation axis wobble in the measurements
+%%
+%% usage:
+%%   [] = sphear_signal_arrival_times(SIG);
+%%
+%% SIG: array of signals (measurements, capsules, samples)
+%%
+%% Copyright 2016-2017, Fernando Lopez-Lezcano, All Rights Reserved
+%% nando@ccrma.stanford.edu
+%%
+%%  This program is free software: you can redistribute it and/or modify
+%%  it under the terms of the GNU General Public License as published by
+%%  the Free Software Foundation, either version 3 of the License, or
+%%  (at your option) any later version.
+%%
+%%  This program is distributed in the hope that it will be useful,
+%%  but WITHOUT ANY WARRANTY; without even the implied warranty of
+%%  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+%%  GNU General Public License for more details.
+%%
+%%  You should have received a copy of the GNU General Public License
+%%  along with this program.  If not, see <htp://www.gnu.org/licenses/>.
+
+function [SIGC] = sphear_af_fix_wobble(SIG, delta)
+  for m = 1:size(SIG, 1);
+    for c = 1:size(SIG, 2);
+      SIGC(m, c, :) = fracshift(reshape(SIG(m, c, :), 1, []), delta(m));
+    end
+  end
+end
+

+ 40 - 1
calibration/src/sphear_design_example.m

@@ -70,6 +70,8 @@ sphear_af_plot_frequency_response(AF, 300, 20000, -60, -10, 48000, 8192);
 
 [R] = sphear_signal_power(AF, FS, 600, 1000, 8192);
 
+[R] = sphear_signal_power(AF, FS, 800, 2400, 8192);
+
 %% check that capsule signals are reasonable
 
 sphear_plot_r(R, 0);
@@ -78,6 +80,8 @@ sphear_plot_r(R, 0);
 
 [A2B, PV, COND] = sphear_calculate_a2b(R);
 
+[A2B, PV, COND] = sphear_octa_calculate_a2b(R);
+
 %% generate a B-format signal using the A-format signal and the static A to B matrix
 
 [BF] = sphear_af_to_bf(AF, A2B);
@@ -102,9 +106,13 @@ sphear_bf_plot_frequency_response(BF, 300, 20000, -60, 0, 48000, 8192);
 
 [W X Y Z] = sphear_bf_extract_filter_shapes(B, [1:16]);
 
+[W X Y Z U V] = sphear_bf_extract_filter_shapes(B, [1:16]);
+
+[W X Y Z U V] = sphear_bf_extract_filter_shapes(B, 0);
+
 %% now design four FIR filters, one for each B-format component
 
-[FIR] = sphear_design_fir_filters(FC, 512, 15, 48000, W, X, Y);
+[FIR TFIR] = sphear_design_fir_filters(FC, 512, 15, 48000, W, X, Y);
 
 %% in the case of the Octathingy we do use Z for now (this is a hack!)
 %%
@@ -114,6 +122,10 @@ sphear_bf_plot_frequency_response(BF, 300, 20000, -60, 0, 48000, 8192);
 
 [FIR] = sphear_design_fir_filters(FC, 512, 15, 48000, W, X, Y, Z);
 
+[FIR TFIR] = sphear_design_fir_filters(FC, 512, 15, 48000, W, X, Y, Z, U, V);
+
+[FIR TFIR] = sphear_design_fir_filters(FC, 512, 15, 48000, W, X, Y, Z, U, V, 8, -24);
+
 %% look at the shapes of the filters
 %% for tetrahedral microphones Z is an average estimation so do not plot it
 
@@ -121,10 +133,24 @@ sphear_bf_plot_filters(FC, W, X, Y);
 
 sphear_bf_plot_filters(FC, W, X, Y, Z);
 
+sphear_bf_plot_filters(FC, W, X, Y, Z, U, V);
+
 %% re-calculate the full B-format signal with the filters
 
 [BF, BFF] = sphear_af_to_bf(AF, A2B, FIR, 8192);
 
+[BF, BFF] = sphear_af_to_bf(AF, A2B, TFIR, 8192);
+
+%% get the average power in the directions of the lobes for W, XY and UV
+%% and normalize the A2B matrix so that ZY and UV have the same peak amplitude
+%% as W
+
+[A2B XY_gain UV_gain] = sphear_bf_normalize_gain(A2B, BFF, FS, 1200, 2400, 8192);
+
+%% re-calculate the B-format signal
+
+[BF, BFF] = sphear_af_to_bf(AF, A2B, TFIR, 8192);
+
 %% plot the frequency response of the B-format components for each measurement
 %% direction, they should all be flat
 
@@ -143,8 +169,21 @@ sphear_bf_plot_polar_response(BFF, 800, 1600, 300, 20000, 3, 8192, FS);
 
 sphear_bf_plot_polar_response(BFF, 800, 1600, 300, 20000, 3, 8192, FS, 1.0);
 
+sphear_bf_plot_polar_response(BFF, 800, 1600, 300, 20000, 3, 8192, FS, 2.0);
+
 %% write a simple Faust A to B encoder that includes the static matrix
 %% and all FIR filters (not efficient but works)
 
 sphear_write_simple_a2b_encoder(A2B, FIR);
 
+sphear_write_simple_a2b_encoder(A2B, TFIR);
+
+%%
+
+sphear_capsule_plot_frequency_response(BFF, [1:16], 300, 20000, -50, 0, 48000, 8192);
+
+%%%%%%%%% testing code to determine z axis wobble during calibration measurements
+
+DELTA = sphear_signal_arrival_times(AF);
+AFC = sphear_af_fix_wobble(AF, (DELTA + abs(min(DELTA')))');
+