Просмотр исходного кода

add code to implement the minimum phase transformation described in "Two alternative minimum-phase filters tested perceptually", AES paper 9554, yields much smaller phase shifts in the high frequency range

Fernando Pablo Lopez-Lezcano 10 лет назад
Родитель
Сommit
9e4db32f26
1 измененных файлов с 22 добавлено и 0 удалено
  1. 22 0
      sphear_fir_design.m

+ 22 - 0
sphear_fir_design.m

@@ -43,6 +43,8 @@
 
 function [FIR] = sphear_fir_design(F, A2BF, n, maxboost, Fs, Fl, plot_on, W, X, Y, Z)
 
+  minphase = 1;
+  
   if (plot_on != 0)
     fig = figure;
   end
@@ -219,6 +221,26 @@ function [FIR] = sphear_fir_design(F, A2BF, n, maxboost, Fs, Fl, plot_on, W, X,
 
       %% design the filter
       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