sfstoolbox / sfs-matlab

SFS Toolbox for Matlab/Octave
https://sfs-matlab.readthedocs.io
MIT License
96 stars 39 forks source link

Logarithmic spacing for linear secondary source distributions #178

Closed fietew closed 6 years ago

fietew commented 6 years ago

Try:

close all
clear variables
SFS_start;
conf = SFS_config;

conf.secondary_sources.geometry = 'linear';
conf.secondary_sources.grid = 'logarithmic';
conf.secondary_sources.logspread = 5;

idx = 0;
fdx = 1;
markers = {'diamond', 'square'};
for N0 = [20, 21]
  conf.secondary_sources.number = N0;
  y0 = zeros(N0,1); 
  for spread = [0.1, 0.25, 0.5, 1.0, 1.5, 2.0, 5.0]
     conf.secondary_sources.logspread = spread;

     x0 = secondary_source_positions(conf);
     y0(:) = idx;
     figure(1);
     hold on;
     plot(x0(:,1),y0,markers{fdx});
     hold off;
     figure(2);
     hold on;
     plot(x0(2:end-1,1), ...
         (x0(1:end-2,1)-x0(2:end-1,1))./(x0(2:end-1,1)-x0(3:end,1)),[markers{fdx} '-']);
     hold off;

     cdx = floor(N0/2)+1;
     fprintf('spread: %2.2f\n', ...
         (x0(end,1)-x0(end-1,1))./(x0(cdx,1)-x0(cdx-1,1)) );
     idx = idx + 0.1;
  end
  fdx = fdx + 1;
end
hold off;
figure(1), title('loudspeaker positions');
figure(2), title('ratio of adjacent loudspeaker spacings');

I am still not sure, how to handle the new functionality in the conf struct: In principle, both logarithmic and equi-distant sampling could be handled using conf.secondary_source.logspread, since 1.0 would results in an equi-distant spacing. Should we nevertheless use conf.secondary_sources.grid in addition?

hagenw commented 6 years ago

Nice addition, could you add two logarithmic example to test_secondary_source_positions(), one with conf.secondary_sources.logspread < 1 and one with > 1. This would be cool.

Regarding the usage of conf.secondary_sources.grid, I think that it should be sufficient to use only conf.secondary_source.logspread and have a default value of 1. If you are planing to add more grid spacings for a linear array then it would make sense to use conf.secondary_sources.grid, but otherwise it would add the burden of using two config settings to change one thing.