sphear_wxyz_plot_all.m 2.2 KB

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