|
@@ -43,6 +43,8 @@
|
|
|
|
|
|
|
|
function [FIR] = sphear_fir_design(F, A2BF, n, maxboost, Fs, Fl, plot_on, W, X, Y, Z)
|
|
function [FIR] = sphear_fir_design(F, A2BF, n, maxboost, Fs, Fl, plot_on, W, X, Y, Z)
|
|
|
|
|
|
|
|
|
|
+ minphase = 1;
|
|
|
|
|
+
|
|
|
if (plot_on != 0)
|
|
if (plot_on != 0)
|
|
|
fig = figure;
|
|
fig = figure;
|
|
|
end
|
|
end
|
|
@@ -219,6 +221,26 @@ function [FIR] = sphear_fir_design(F, A2BF, n, maxboost, Fs, Fl, plot_on, W, X,
|
|
|
|
|
|
|
|
%% design the filter
|
|
%% design the filter
|
|
|
FIR(b, c, :) = fir2(n, fi, ri);
|
|
FIR(b, c, :) = fir2(n, fi, ri);
|
|
|
|
|
+ if (minphase != 0)
|
|
|
|
|
+ %% try to get it close to minimum phase
|
|
|
|
|
+ %%
|
|
|
|
|
+ %% "Two alternative minimum-phase filters tested perceptually"
|
|
|
|
|
+ %% Robert Mores and Ralf Hendrych, AES Convertion paper 9554
|
|
|
|
|
+ %%
|
|
|
|
|
+ IR = reshape(FIR(b, c, :), 257, 1);
|
|
|
|
|
+ %% number of samples in the sin transition
|
|
|
|
|
+ %%
|
|
|
|
|
+ %% 8 seems to be the sweet spot for a FIR filter size of 256,
|
|
|
|
|
+ %% 16 leads to bigger phase shift, 4 starts to impact negatively
|
|
|
|
|
+ %% the flattness of the frequency response
|
|
|
|
|
+ %%
|
|
|
|
|
+ N = 16;
|
|
|
|
|
+ M = size(IR)(1);
|
|
|
|
|
+ R = 0.5 + (0.5 * sin(pi * ((1:(2*N)) - N) / (2 * N)));
|
|
|
|
|
+ ramp = [zeros(M/2 - N + 1, 1); R'; ones(M/2 - N, 1)];
|
|
|
|
|
+ IRR = (IR .* ramp * 2);
|
|
|
|
|
+ FIR(b, c, :) = IRR(:);
|
|
|
|
|
+ end
|
|
|
end
|
|
end
|
|
|
end
|
|
end
|
|
|
|
|
|