sfstoolbox / sfs-matlab

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

Return wfs delay #62

Closed hagenw closed 8 years ago

hagenw commented 8 years ago

This is a follow up on #59.

The main goal was fomulated by @fietew as:

Imho, it would be easier to return the pre-delay which has been added to the driving function by a particular processing step, e.g. fractional delay, wfs prefilter, focused source, plane wave, etc.. Furthermore, I would prefer that t=0 corresponds to the t=0 of the virtual source, i.e. where the sound "starts" to radiate from a point/focused source or when the plane wave passed its point of zero phase.

In order to achieve this I did the following things:

  1. Add an additional prefilter_delay return parameter to wfs_preequalization(), which returns the delay that is added by the applied pre-filter.
  2. Add an additional delay_offset return parameter to driving_function_imp_wfs(). In the case of conf.removedelay=1 it returns prefilter_delay. In the case of conf.wfs.removedelay=0 it returns secondary_source_diameter(conf)/c + prefilter_delay
  3. I used this directly in sound_field_imp_wfs():
[d,~,~,delay_offset] = driving_function_imp_wfs(x0,xs,src,conf);
t = t + delay_offset*fs;

Result That means if you use sound_field_imp_wfs() with conf.wfs.removedelay=1 you will have the first activity at the secondary sources for t = 0. With conf.wfs.removedelay=0 you will have the first activity of the virtual sources for t = 0.

Example

conf = SFS_config;
conf.wfs.removedelay = 1;
conf.plot.usedb = 1;
sound_field_imp_wfs([-2 2],[-2 2],0,[0 0.5 0 0 -1 0],'fs',0,conf)

wfs_fs_removedelay1

conf = SFS_config;
conf.wfs.removedelay = 0;
conf.plot.usedb = 1;
sound_field_imp_wfs([-2 2],[-2 2],0,[0 0.5 0 0 -1 0],'fs',0,conf)

wfs_fs_removedelay0

Open questions

trettberg commented 8 years ago

I have added a return value also for the IIR filter I think it's best to return a delay of zero, instead of something like maximum group delay.

btw: The IIR case in wfs_preequalization had some issues. It should hopefully work now.

fietew commented 8 years ago

As the new version of the delayline is still under construction (see #50) I would prefer to add the delay_offset return value to this function after the merge of the new delayline.

hagenw commented 8 years ago

OK, I have created #64 in order to not forget it and will merge this pull request in the meantime.