1
0

sphear_fir_design.m 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. %%
  2. %% *SpHEAR Project
  3. %%
  4. %% sphear_fir_design: design a matrix of FIR filters that equalizes the microphone
  5. %%
  6. %% usage:
  7. %% [FIR] = sphear_fir_design(F, A2BF, n, Fs)
  8. %%
  9. %% F: array of filter section center frequencies
  10. %% A2BF: vector of A2B matrixes
  11. %% n: order of the FIR filter being created
  12. %% Fs: sampling rate
  13. %%
  14. %% Copyright 2016, Fernando Lopez-Lezcano, All Rights Reserved
  15. %% nando@ccrma.stanford.edu
  16. %%
  17. %% This program is free software: you can redistribute it and/or modify
  18. %% it under the terms of the GNU General Public License as published by
  19. %% the Free Software Foundation, either version 3 of the License, or
  20. %% (at your option) any later version.
  21. %%
  22. %% This program is distributed in the hope that it will be useful,
  23. %% but WITHOUT ANY WARRANTY; without even the implied warranty of
  24. %% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  25. %% GNU General Public License for more details.
  26. %%
  27. %% You should have received a copy of the GNU General Public License
  28. %% along with this program. If not, see <http://www.gnu.org/licenses/>.
  29. function [FIR] = sphear_fir_design(F, A2BF, n, Fs)
  30. FIR = zeros(4, 4, (n + 1));
  31. %% frequency range
  32. f = [0 F' Fs/2]' / (Fs/2);
  33. %% all b format components
  34. for b = 1:4
  35. %% all capsules
  36. for c = 1:4
  37. r = [ A2BF(1,c,b) A2BF(:,c,b)' A2BF(end,c,b)]';
  38. FIR(b, c, :) = fir2(n, f, r);
  39. end
  40. end
  41. end