|
@@ -11,12 +11,12 @@
|
|
|
%% n: order of the FIR filter being created
|
|
%% n: order of the FIR filter being created
|
|
|
%% maxboost: max high and low frequency boost in dB of the final filter
|
|
%% maxboost: max high and low frequency boost in dB of the final filter
|
|
|
%% Fs: sampling rate
|
|
%% Fs: sampling rate
|
|
|
|
|
+%% Fl: frequency limit, below it use A2B matrixes, above it use WXYZ shapes
|
|
|
%%
|
|
%%
|
|
|
-%% for the first run do not supply Fl/W/XYZ, render the filters and from inspection
|
|
|
|
|
-%% determine the limit frequency, then run sphear_fir_extract to extract the
|
|
|
|
|
-%% W and XYZ filter shapes and run this again with the extra parameters below
|
|
|
|
|
|
|
+%% for the first run do not supply W/XYZ, render the filters and then run
|
|
|
|
|
+%% sphear_fir_extract to extract the W and XYZ filter shapes, finally run
|
|
|
|
|
+%% this again with the extra parameters below
|
|
|
%%
|
|
%%
|
|
|
-%% Fl: frequency limit, below it use A2B matrixes, above it use WXYZ shapes
|
|
|
|
|
%% W: extracted shape of W filter (used above Fl)
|
|
%% W: extracted shape of W filter (used above Fl)
|
|
|
%% XYZ: extracted shape of X, Y and Z filters (used above Fl)
|
|
%% XYZ: extracted shape of X, Y and Z filters (used above Fl)
|
|
|
%%
|
|
%%
|
|
@@ -38,8 +38,6 @@
|
|
|
|
|
|
|
|
function [FIR] = sphear_fir_design(F, A2BF, n, maxboost, Fs, Fl, W, XYZ)
|
|
function [FIR] = sphear_fir_design(F, A2BF, n, maxboost, Fs, Fl, W, XYZ)
|
|
|
|
|
|
|
|
- FIR = zeros(4, 4, (n + 1));
|
|
|
|
|
-
|
|
|
|
|
%% all b format components
|
|
%% all b format components
|
|
|
for b = 1:4
|
|
for b = 1:4
|
|
|
%% all capsules
|
|
%% all capsules
|
|
@@ -75,10 +73,19 @@ function [FIR] = sphear_fir_design(F, A2BF, n, maxboost, Fs, Fl, W, XYZ)
|
|
|
end
|
|
end
|
|
|
end
|
|
end
|
|
|
|
|
|
|
|
- %% fit a spline over the existing points and extrapolate
|
|
|
|
|
- %% for low and high ends of spectrum
|
|
|
|
|
- fi = (0:200/(Fs/2):1)';
|
|
|
|
|
- ri = spline(F/(Fs/2), A2BF(:,c,b)', fi);
|
|
|
|
|
|
|
+ %% fit a spline to the W and XYZ segments and extrapolate
|
|
|
|
|
+ %% highest frequency if it does not exist in the measurements
|
|
|
|
|
+ fh = (F(dlast)/(Fs/2):200/(Fs/2):1)';
|
|
|
|
|
+ fh(end) = 1;
|
|
|
|
|
+ rh = spline(F(dlast:end)/(Fs/2), A2BF(dlast:end,c,b)', fh);
|
|
|
|
|
+
|
|
|
|
|
+ %% extract the low frequency A2B coefficients
|
|
|
|
|
+ fl = [0 F(1:dlast-1)']' ./ (Fs/2);
|
|
|
|
|
+ rl = [A2BF(1,c,b) A2BF(1:dlast-1,c,b)']';
|
|
|
|
|
+
|
|
|
|
|
+ %% concatenate low and high frequency arrays
|
|
|
|
|
+ fi = cat(1, fl, fh);
|
|
|
|
|
+ ri = cat(1, rl, rh);
|
|
|
|
|
|
|
|
printf("low frequency boost %f, high frequency boost %f\n", 20*log10(ri(1)), 20*log10(ri(end)));
|
|
printf("low frequency boost %f, high frequency boost %f\n", 20*log10(ri(1)), 20*log10(ri(end)));
|
|
|
%% force a max boost at low and high frequencies
|
|
%% force a max boost at low and high frequencies
|
|
@@ -95,18 +102,20 @@ function [FIR] = sphear_fir_design(F, A2BF, n, maxboost, Fs, Fl, W, XYZ)
|
|
|
end
|
|
end
|
|
|
end
|
|
end
|
|
|
|
|
|
|
|
- %% real measured points
|
|
|
|
|
|
|
+ %% plot real measured points
|
|
|
|
|
+ axis([300, 24000]);
|
|
|
|
|
+ grid on;
|
|
|
if (b == 1)
|
|
if (b == 1)
|
|
|
- semilogx(F/(Fs/2), A2BF(:,c,b)','*g');
|
|
|
|
|
|
|
+ semilogx(F, 20*log10(abs(A2BF(:,c,b)))','*k');
|
|
|
else
|
|
else
|
|
|
- semilogx(F/(Fs/2), A2BF(:,c,b)','*b');
|
|
|
|
|
|
|
+ semilogx(F, 20*log10(abs(A2BF(:,c,b)))','*k');
|
|
|
end
|
|
end
|
|
|
hold on;
|
|
hold on;
|
|
|
- %% extrapolated spline
|
|
|
|
|
|
|
+ %% plot extrapolated spline
|
|
|
if (b == 1)
|
|
if (b == 1)
|
|
|
- semilogx(fi,ri,'g');
|
|
|
|
|
|
|
+ semilogx(fi*(Fs/2), 20*log10(abs(ri)), 'b');
|
|
|
else
|
|
else
|
|
|
- semilogx(fi,ri,'r');
|
|
|
|
|
|
|
+ semilogx(fi*(Fs/2), 20*log10(abs(ri)), 'r');
|
|
|
end
|
|
end
|
|
|
|
|
|
|
|
%% design the filter
|
|
%% design the filter
|