浏览代码

add the option to shape the frequency spectrum above and below the transition frequency - the shape is currently hardwired in the file for testing only

Fernando Pablo Lopez-Lezcano 10 年之前
父节点
当前提交
1e0ecae6c0
共有 1 个文件被更改,包括 17 次插入 和 4 次删除
  1. 17 4
      sphear_fir_design.m

+ 17 - 4
sphear_fir_design.m

@@ -52,6 +52,17 @@ function [FIR] = sphear_fir_design(F, A2BF, n, maxboost, Fs, Fl, plot_on, W, X,
     Z = (X + Y) / 2;
   end
 
+  %% find the index of the transition frequency band
+  fl_idx = 1;
+  for d = 1:size(A2BF(:,1,1))(1)
+    if (F(d) <= Fl)
+      fl_idx = d;
+    end
+  end
+  printf("transition band is %d at %f Hz\n", fl_idx, F(fl_idx));
+  %% create a frequency response profile in dB
+  fr_profile = interp1([F(1), F(fl_idx), F(end)], [0, 0, 0], F);
+
   %% all b format components
   for b = 1:4
     %% all capsules
@@ -62,6 +73,8 @@ function [FIR] = sphear_fir_design(F, A2BF, n, maxboost, Fs, Fl, plot_on, W, X,
 	if (F(d) <= Fl)
 	  %% below the limit frequency we use the A2B coefficients
 	  vlast = A2BF(d, c, b);
+	  %% apply frequency response profile
+	  A2BF(d, c, b) = vlast * 10^(fr_profile(d)/20);
 	  dlast = d;
 	  if (exist("W") == 1)
 	    wlast = W(d);
@@ -76,28 +89,28 @@ function [FIR] = sphear_fir_design(F, A2BF, n, maxboost, Fs, Fl, plot_on, W, X,
 	  %% frequency
 	  if (b == 1)
 	    if (exist("W") == 1)
-	      A2BF(d, c, b) = vlast * (W(d)/wlast);
+	      A2BF(d, c, b) = vlast * (W(d)/wlast) * 10^(fr_profile(d)/20);
 	    else
 	      A2BF(d, c, b) = vlast;
 	    end
 	  end
 	  if (b == 2)
 	    if (exist("X") == 1)
-	      A2BF(d, c, b) = vlast * (X(d)/xlast);
+	      A2BF(d, c, b) = vlast * (X(d)/xlast) * 10^(fr_profile(d)/20);
 	    else
 	      A2BF(d, c, b) = vlast;
 	    end
 	  end
 	  if (b == 3)
 	    if (exist("Y") == 1)
-	      A2BF(d, c, b) = vlast * (Y(d)/ylast);
+	      A2BF(d, c, b) = vlast * (Y(d)/ylast) * 10^(fr_profile(d)/20);
 	    else
 	      A2BF(d, c, b) = vlast;
 	    end
 	  end
 	  if (b == 4)
 	    if (exist("Z") == 1)
-	      A2BF(d, c, b) = vlast * (Z(d)/zlast);
+	      A2BF(d, c, b) = vlast * (Z(d)/zlast) * 10^(fr_profile(d)/20);
 	    else
 	      A2BF(d, c, b) = vlast;
 	    end