sphear_wxyz_plot_all.m 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. %%
  2. %% *SpHEAR Project
  3. %%
  4. %% sphear_wxyz_plot_all: plot the polar response of a B format signal
  5. %%
  6. %% usage:
  7. %% [B] = sphear_wxyz_plot_all(fmin, fmax, Noct, Nbuf, Npre, Nfft, plt)
  8. %%
  9. %% fmin, fmax: lower and upper frequency limits
  10. %% Noct: width of frequency ranges in fractions of an octave, this
  11. %% will be changed slightly so that the frequency range is
  12. %% covered by equally spaced frequency bands
  13. %% Nbuf: total number of samples to analyze
  14. %% Npre: number of samples before the main impulse
  15. %% Nfft: size of fft
  16. %% plt: 0 -> just return the measurements, 1 -> do plots
  17. %%
  18. %% Copyright 2016, Fernando Lopez-Lezcano, All Rights Reserved
  19. %% nando@ccrma.stanford.edu
  20. %%
  21. %% This program is free software: you can redistribute it and/or modify
  22. %% it under the terms of the GNU General Public License as published by
  23. %% the Free Software Foundation, either version 3 of the License, or
  24. %% (at your option) any later version.
  25. %%
  26. %% This program is distributed in the hope that it will be useful,
  27. %% but WITHOUT ANY WARRANTY; without even the implied warranty of
  28. %% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  29. %% GNU General Public License for more details.
  30. %%
  31. %% You should have received a copy of the GNU General Public License
  32. %% along with this program. If not, see <http://www.gnu.org/licenses/>.
  33. function [B] = sphear_wxyz_plot_all(fmin, fmax, Noct, Nbuf, Npre, Nfft, plt)
  34. plotz = 0;
  35. measurements = (1:16);
  36. %% calculate number of frequency bands spaced Noct
  37. n = floor(log(fmax/fmin)/log(2^(1/Noct)));
  38. %% adjust width of band so they fit exactly in frequency range
  39. N = log(2)/(log(fmax/fmin)/n);
  40. printf("%d frequency bands, %f bands per octave\n", n, N);
  41. %% first center frequency
  42. fcmin = fmin * 2^(1/(N * 2));
  43. %% all center and edge frequencies
  44. fc = fcmin * 2.^((0:n - 1)/N)';
  45. fe = fmin * 2.^((0:n)/N)';
  46. %% normalize amplitude with respect to W between 600 and 1200 Hz
  47. ref = sphear_wxyz_power(measurements, 600, 1200, Nbuf, Npre, Nfft, 1);
  48. norm = mean(ref(:,1));
  49. for i = (1:size(fc))
  50. B(:,:,i) = sphear_wxyz_power(measurements, fe(i), fe(i + 1), Nbuf, Npre, Nfft, plotz) / norm;
  51. if (plt == 1)
  52. sphear_wxyz_plot(B(:,:,i), fe(i), fe(i + 1), 1.5);
  53. end
  54. end
  55. end