|
@@ -1,9 +1,12 @@
|
|
|
|
|
+%% -*- mode: octave -*-
|
|
|
%%
|
|
%%
|
|
|
%% *SpHEAR Project
|
|
%% *SpHEAR Project
|
|
|
-%% sphear_fir_render_directions: render impulse responses throught the FIR filter A2B matrix
|
|
|
|
|
|
|
+%%
|
|
|
|
|
+%% sphear_fir_render_directions: plot frequency response of FIR filter A2B matrix for principal
|
|
|
|
|
+%% and diagonal directions
|
|
|
%%
|
|
%%
|
|
|
%% usage:
|
|
%% usage:
|
|
|
-%% [] = sphear_fir_render_directions(FIR, fmin, fmax, ymin, ymax, Nfft, plot_on, smooth)
|
|
|
|
|
|
|
+%% [] = sphear_fir_render_directions(FIR, fmin, fmax, ymin, ymax, Fs, Nfft, plot_on, smooth)
|
|
|
%%
|
|
%%
|
|
|
%% FIR: A2B matrix of FIR filters
|
|
%% FIR: A2B matrix of FIR filters
|
|
|
%% fmin, fmax: range of frequencies to use
|
|
%% fmin, fmax: range of frequencies to use
|
|
@@ -52,15 +55,15 @@ function [BFF] = sphear_fir_render_directions(FIR, fmin, fmax, ymin, ymax, Fs, N
|
|
|
if (strcmp(plot_on, "epsc") || strcmp(plot_on, "pngc"))
|
|
if (strcmp(plot_on, "epsc") || strcmp(plot_on, "pngc"))
|
|
|
%% color plot
|
|
%% color plot
|
|
|
wopts = 'k;W;';
|
|
wopts = 'k;W;';
|
|
|
- popts = 'r;X;';
|
|
|
|
|
- dopts = 'b;Y;';
|
|
|
|
|
|
|
+ xopts = 'r;X;';
|
|
|
|
|
+ yopts = 'b;Y;';
|
|
|
copt = '-color';
|
|
copt = '-color';
|
|
|
cext = "_color";
|
|
cext = "_color";
|
|
|
else
|
|
else
|
|
|
%% mono plot
|
|
%% mono plot
|
|
|
wopts = '-';
|
|
wopts = '-';
|
|
|
- popts = '--';
|
|
|
|
|
- dopts = ':';
|
|
|
|
|
|
|
+ xopts = '--';
|
|
|
|
|
+ yopts = ':';
|
|
|
copt = '-mono';
|
|
copt = '-mono';
|
|
|
cext = "_mono";
|
|
cext = "_mono";
|
|
|
end
|
|
end
|
|
@@ -73,55 +76,75 @@ function [BFF] = sphear_fir_render_directions(FIR, fmin, fmax, ymin, ymax, Fs, N
|
|
|
ca=get (gcf, "currentaxes");
|
|
ca=get (gcf, "currentaxes");
|
|
|
set(ca,"fontweight","bold","linewidth",1.5)
|
|
set(ca,"fontweight","bold","linewidth",1.5)
|
|
|
|
|
|
|
|
|
|
+ %% measurements, first four in cardinal directions
|
|
|
|
|
+ measurements = [1, 5, 9, 13, 3, 7, 11, 15];
|
|
|
|
|
+
|
|
|
|
|
+ %% which components to plot, we ommit the ones that are nulled
|
|
|
|
|
+ %% 0: do not plot, 1: cardinal, 2: diagonal plot
|
|
|
|
|
+ m_W = [1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0];
|
|
|
|
|
+ m_X = [1, 0, 2, 0, 0, 0, 2, 0, 1, 0, 2, 0, 0, 0, 2, 0];
|
|
|
|
|
+ m_Y = [0, 0, 2, 0, 1, 0, 2, 0, 0, 0, 2, 0, 1, 0, 2, 0];
|
|
|
|
|
+ m_Z = [1, 0, 2, 0, 1, 0, 2, 0, 1, 0, 2, 0, 1, 0, 2, 0];
|
|
|
|
|
+
|
|
|
|
|
+ W_offset = +0;
|
|
|
|
|
+ X_offset = -3;
|
|
|
|
|
+ Y_offset = -3;
|
|
|
idx = 1;
|
|
idx = 1;
|
|
|
- for m = [1, 5, 9, 13, 3, 7, 11, 15]
|
|
|
|
|
|
|
+ for m = measurements
|
|
|
%% render b format components
|
|
%% render b format components
|
|
|
bf(idx,:,:) = sphear_a_to_b(m, FIR, Nfft);
|
|
bf(idx,:,:) = sphear_a_to_b(m, FIR, Nfft);
|
|
|
|
|
|
|
|
%% calculate B format frequency responses
|
|
%% calculate B format frequency responses
|
|
|
for b = 1:4
|
|
for b = 1:4
|
|
|
if (smooth > 0)
|
|
if (smooth > 0)
|
|
|
- bfft(idx,b,:) = fastsmooth(20*log10(abs(fft(bf(idx,b,:), Nfft))), smooth, 2, 1);
|
|
|
|
|
|
|
+ bfft(idx,b,:) = fastsmooth(10*log10(abs(fft(bf(idx,b,:), Nfft))), smooth, 2, 1)(1:end/2);
|
|
|
else
|
|
else
|
|
|
- bfft(idx,b,:) = 20*log10(abs(fft(bf(idx,b,:), Nfft)));
|
|
|
|
|
|
|
+ bfft(idx,b,:) = 10*log10(abs(fft(bf(idx,b,:), Nfft)))(1:end/2);
|
|
|
end
|
|
end
|
|
|
end
|
|
end
|
|
|
fr = (1:Nfft/2) * Fs/Nfft;
|
|
fr = (1:Nfft/2) * Fs/Nfft;
|
|
|
- %% W
|
|
|
|
|
- p1 = semilogx(fr, bfft(idx,1,1:end/2) * 10^(-6/20), wopts, "linewidth", 1.5);
|
|
|
|
|
- %% print principal and diagonal directions with different colors
|
|
|
|
|
- if (rem(idx, 2) == 1)
|
|
|
|
|
- if (idx > 4)
|
|
|
|
|
- p2 = semilogx(fr, bfft(idx,2,1:end/2) * 10^(6/20), dopts, "linewidth", 1.5);
|
|
|
|
|
- else
|
|
|
|
|
- p3 = semilogx(fr, bfft(idx,2,1:end/2) * 10^(6/20), popts, "linewidth", 1.5);
|
|
|
|
|
|
|
+
|
|
|
|
|
+ fft_avg = mean(bfft(1,1,round(end/4):round(end/2)));
|
|
|
|
|
+ %%fft_avg = 0.0;
|
|
|
|
|
+
|
|
|
|
|
+ for b = 1:4
|
|
|
|
|
+ if (m_W(m) > 0 && b == 1)
|
|
|
|
|
+ if (m_W(m) > 1)
|
|
|
|
|
+ pW = semilogx(fr, bfft(idx,b,:) - fft_avg + W_offset, wopts, "linewidth", 1.5, "linestyle", "--");
|
|
|
|
|
+ else
|
|
|
|
|
+ pW = semilogx(fr, bfft(idx,b,:) - fft_avg + W_offset, wopts, "linewidth", 1.5);
|
|
|
|
|
+ end
|
|
|
end
|
|
end
|
|
|
- else
|
|
|
|
|
- if (idx > 4)
|
|
|
|
|
- p2 = semilogx(fr, bfft(idx,3,1:end/2) * 10^(6/20), dopts, "linewidth", 1.5);
|
|
|
|
|
- else
|
|
|
|
|
- p3 = semilogx(fr, bfft(idx,3,1:end/2) * 10^(6/20), popts, "linewidth", 1.5);
|
|
|
|
|
|
|
+ if (m_X(m) > 0 && b == 2)
|
|
|
|
|
+ if (m_X(m) > 1)
|
|
|
|
|
+ pXd = semilogx(fr, bfft(idx,b,:) - fft_avg + X_offset, xopts, "linewidth", 1.5, "linestyle", "--");
|
|
|
|
|
+ else
|
|
|
|
|
+ pXp = semilogx(fr, bfft(idx,b,:) - fft_avg + X_offset, xopts, "linewidth", 1.5);
|
|
|
|
|
+ end
|
|
|
|
|
+ end
|
|
|
|
|
+ if (m_Y(m) > 0 && b == 3)
|
|
|
|
|
+ if (m_Y(m) > 1)
|
|
|
|
|
+ pYd = semilogx(fr, bfft(idx,b,:) - fft_avg + Y_offset, yopts, "linewidth", 1.5, "linestyle", "--");
|
|
|
|
|
+ else
|
|
|
|
|
+ pYp = semilogx(fr, bfft(idx,b,:) - fft_avg + Y_offset, yopts, "linewidth", 1.5);
|
|
|
|
|
+ end
|
|
|
end
|
|
end
|
|
|
end
|
|
end
|
|
|
|
|
|
|
|
idx = idx + 1;
|
|
idx = idx + 1;
|
|
|
end
|
|
end
|
|
|
-
|
|
|
|
|
- if (strcmp(plot_on, "epsc") || strcmp(plot_on, "pngc"))
|
|
|
|
|
- l = legend([p1, p2, p3],
|
|
|
|
|
- {"W (+12dB for clarity)", "XY principal directions", "XY diagonal directions"});
|
|
|
|
|
- legend(l, 'location', 'southwest');
|
|
|
|
|
- else
|
|
|
|
|
- %% there seems to be bug with legends in mono, the order of
|
|
|
|
|
- %% the legends seems to be reversed
|
|
|
|
|
- l = legend([p1, p2, p3],
|
|
|
|
|
- {"XY principal directions", "W (+12dB for clarity)", "XY diagonal directions"});
|
|
|
|
|
- legend(l, 'location', 'southwest');
|
|
|
|
|
- end
|
|
|
|
|
|
|
+ l = legend([pW, pXp, pXd, pYp, pYd],
|
|
|
|
|
+ {sprintf("W principal directions (%.1fdB offset)", W_offset),
|
|
|
|
|
+ sprintf("X principal directions (%.1fdB offset)", X_offset),
|
|
|
|
|
+ sprintf("X diagonal directions (%.1fdB offset)", Y_offset),
|
|
|
|
|
+ sprintf("Y principal directions (%.1fdB offset)", X_offset),
|
|
|
|
|
+ sprintf("Y diagonal directions (%.1fdB offset)", Y_offset),
|
|
|
|
|
+ });
|
|
|
|
|
+ legend(l, 'location', 'southwest');
|
|
|
if (strcmp(plot_on, 'eps') || strcmp(plot_on, 'epsc') || plot_on == 1)
|
|
if (strcmp(plot_on, 'eps') || strcmp(plot_on, 'epsc') || plot_on == 1)
|
|
|
- print(f, '-deps', '-tight', copt,["figures/sphear_directions.eps"]);
|
|
|
|
|
|
|
+ print(f, '-deps', '-tight', '-S1920,1080', copt,["../figures/sphear_directions.eps"]);
|
|
|
else
|
|
else
|
|
|
- print(f, '-deps', copt, ["figures/sphear_directions.eps"]);
|
|
|
|
|
|
|
+ print(f, '-deps', copt, ["../figures/sphear_directions.eps"]);
|
|
|
end
|
|
end
|
|
|
|
|
|
|
|
end
|
|
end
|