sfstoolbox / sfs-matlab

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

fix handling of edges for tapering window #69

Closed fietew closed 8 years ago

fietew commented 8 years ago

See https://github.com/sfstoolbox/sfs/commit/c8fec3ef82435a90c4d0a42cdb04e3de039d4566#diff-f9229d5f60cedf852a470bd907a2ac05R103 .

The if clause in the current implementation incorrectly recognizes edges=[1,2] as edges=[end,1]

fietew commented 8 years ago

In order to test, execute the following with current and the modified version:

conf = SFS_config;

conf.plot.realloudspeakers = true;

conf.usetapwin = true;
conf.tapwinlen = 1.0;
conf.secondary_sources.number = 64;
conf.secondary_sources.geometry = 'box';
conf.secondary_sources.size = 4.0;

conf.localsfs.vss.geometry = 'circle';
conf.localsfs.vss.number = 72;
conf.localsfs.vss.size = 2;
conf.localsfs.usetapwin = false;

phis = 90;

xs = 4*[cosd(phis), sind(phis), 0];
f = 500;
x0 = secondary_source_positions(conf);
[D, x0, xv] = driving_function_mono_localwfs(x0,xs,'ps',f,conf);

figure,
subplot(2,2,1);
conf.plot.realloudspeakers = true;
draw_loudspeakers(x0, [1 1 0], conf);
hold on;
conf.plot.realloudspeakers = true;
draw_loudspeakers(xv, [1 1 0], conf);
hold off;
title(sprintf('number of secondary sources: %d', size(x0,1))); 
subplot(2,2,2);
plot(1:length(x0), x0(:,7), 'b',1:length(x0), abs(D), 'r');

xs = 4*[cosd(phis+180), sind(phis+180), 0];
f = 500;
x0 = secondary_source_positions(conf);
[D, x0, xv] = driving_function_mono_localwfs(x0,xs,'ps',f,conf);
subplot(2,2,3);
conf.plot.realloudspeakers = true;
draw_loudspeakers(x0, [1 1 0], conf);
hold on;
conf.plot.realloudspeakers = true;
draw_loudspeakers(xv, [1 1 0], conf);
hold off;
title(sprintf('number of secondary sources: %d', size(x0,1))); 
subplot(2,2,4);
plot(1:length(x0), x0(:,7), 'b',1:length(x0), abs(D), 'r');
hagenw commented 8 years ago

OK, that means there were actual two different errors involved in your strange localsfs behavior: 1) the secondary source selection has problems for some special symmetries: #68 2) the edge detection for calculating the tapering window had an error (fixed by this pull request)

So far your changes seems to fix the problem. I will do a final test later and merge it then.