|
@@ -21,6 +21,7 @@
|
|
|
%% X: extracted shape of X filter (used above Fl)
|
|
%% X: extracted shape of X filter (used above Fl)
|
|
|
%% Y: extracted shape of Y filter (used above Fl)
|
|
%% Y: extracted shape of Y filter (used above Fl)
|
|
|
%% Z: extracted shape of Z filter (used above Fl)
|
|
%% Z: extracted shape of Z filter (used above Fl)
|
|
|
|
|
+%% Z is optional, if not supplied X and Y are averaged to obtain Z
|
|
|
%%
|
|
%%
|
|
|
%% Copyright 2016, Fernando Lopez-Lezcano, All Rights Reserved
|
|
%% Copyright 2016, Fernando Lopez-Lezcano, All Rights Reserved
|
|
|
%% nando@ccrma.stanford.edu
|
|
%% nando@ccrma.stanford.edu
|
|
@@ -42,6 +43,11 @@ function [FIR] = sphear_fir_design(F, A2BF, n, maxboost, Fs, Fl, W, X, Y, Z)
|
|
|
|
|
|
|
|
fig = figure;
|
|
fig = figure;
|
|
|
|
|
|
|
|
|
|
+ if (exist("W") == 1 && ! exist("Z"))
|
|
|
|
|
+ %% Z was not supplied, just average X and Y data
|
|
|
|
|
+ Z = (X + Y) / 2;
|
|
|
|
|
+ end
|
|
|
|
|
+
|
|
|
%% all b format components
|
|
%% all b format components
|
|
|
for b = 1:4
|
|
for b = 1:4
|
|
|
%% all capsules
|
|
%% all capsules
|
|
@@ -136,19 +142,27 @@ function [FIR] = sphear_fir_design(F, A2BF, n, maxboost, Fs, Fl, W, X, Y, Z)
|
|
|
end
|
|
end
|
|
|
|
|
|
|
|
%% plot real measured points
|
|
%% plot real measured points
|
|
|
- axis([300, 24000]);
|
|
|
|
|
|
|
+ axis([300, (Fs/2)]);
|
|
|
|
|
+ tics('x', [300, 500, 1000, 2000, 3000, 5000, 7000, 10000, 15000, 20000]);
|
|
|
grid on;
|
|
grid on;
|
|
|
|
|
+ title(sprintf("B format FIR filters (transition frequency %d Hz)", Fl));
|
|
|
if (b == 1)
|
|
if (b == 1)
|
|
|
- semilogx(F, 20*log10(abs(A2BF(:,c,b)))','*k');
|
|
|
|
|
|
|
+ dlabel = semilogx(F, 20*log10(abs(A2BF(:,c,b)))','.k');
|
|
|
else
|
|
else
|
|
|
- semilogx(F, 20*log10(abs(A2BF(:,c,b)))','*k');
|
|
|
|
|
|
|
+ dlabel = semilogx(F, 20*log10(abs(A2BF(:,c,b)))','.k');
|
|
|
end
|
|
end
|
|
|
hold on;
|
|
hold on;
|
|
|
%% plot extrapolated spline
|
|
%% plot extrapolated spline
|
|
|
if (b == 1)
|
|
if (b == 1)
|
|
|
- semilogx(fi*(Fs/2), 20*log10(abs(ri)), 'b');
|
|
|
|
|
|
|
+ wh = semilogx(fi*(Fs/2), 20*log10(abs(ri)), 'b');
|
|
|
else
|
|
else
|
|
|
- semilogx(fi*(Fs/2), 20*log10(abs(ri)), 'r');
|
|
|
|
|
|
|
+ if (b == 4)
|
|
|
|
|
+ %% Z
|
|
|
|
|
+ zh = semilogx(fi*(Fs/2), 20*log10(abs(ri)), 'g');
|
|
|
|
|
+ else
|
|
|
|
|
+ %% XY
|
|
|
|
|
+ xyh = semilogx(fi*(Fs/2), 20*log10(abs(ri)), 'r');
|
|
|
|
|
+ end
|
|
|
end
|
|
end
|
|
|
|
|
|
|
|
%% design the filter
|
|
%% design the filter
|
|
@@ -156,6 +170,9 @@ function [FIR] = sphear_fir_design(F, A2BF, n, maxboost, Fs, Fl, W, X, Y, Z)
|
|
|
end
|
|
end
|
|
|
end
|
|
end
|
|
|
|
|
|
|
|
|
|
+ l = legend([wh, zh, xyh], {'W', 'XY', 'Z'});
|
|
|
|
|
+ legend(l, 'location', 'southwest');
|
|
|
|
|
+
|
|
|
if (exist("W") == 1)
|
|
if (exist("W") == 1)
|
|
|
print(fig, '-dpng','-color',["figures/w_xyz_filter_full.png"]);
|
|
print(fig, '-dpng','-color',["figures/w_xyz_filter_full.png"]);
|
|
|
else
|
|
else
|