From 3ca77fa02af560806833b523343c1e31ecbff679 Mon Sep 17 00:00:00 2001 From: VeraE Date: Wed, 8 Jun 2016 13:13:33 +0200 Subject: [PATCH 01/13] zero-padding of HRIRs to conf.N before delayline() --- SFS_ir/ir_correct_distance.m | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/SFS_ir/ir_correct_distance.m b/SFS_ir/ir_correct_distance.m index 7a8dd6e6..5774db38 100644 --- a/SFS_ir/ir_correct_distance.m +++ b/SFS_ir/ir_correct_distance.m @@ -22,6 +22,7 @@ % % IR_CORRECT_DISTANCE(ir,ir_distance,r,conf) weights and delays the given % impulse responses, that they are conform with the specified distance r. +% The impulse responses are zero-padded to length conf.N. % % See also: get_ir @@ -76,15 +77,13 @@ 'only extrapolate up to 10m. All larger radii will be set to ', ... '10m.'],upper(mfilename)); end +% Zero-pad HRIRs to conf.N +ir_origlength = size(ir,3); +ir = cat(3,ir,zeros(size(ir,1),size(ir,2),conf.N-ir_origlength)); % Append zeros at the beginning of the impulse responses corresponding to % its maximum radius if ~useoriglength zero_padding = ceil(ir_distance/c * fs); - if conf.N-zero_padding<128 - error(['%s: choose a larger conf.N value, because otherwise you ', ... - 'will have only %i samples of your original impulse response.'], ... - upper(mfilename),conf.N-zero_padding); - end else zero_padding = 0; end @@ -93,9 +92,11 @@ % Amplitude weighting (point source model) % This gives weight=1 for r==ir_distance weight = ir_distance./r; -if abs(delay)>size(ir,3) - error(['%s: your impulse response is to short for a desired ', ... - 'delay of %.1f samples.'],upper(mfilename),delay); +% Check if impulse responses are long enough compared to intended delay +if conf.N-(zero_padding+delay) Date: Wed, 8 Jun 2016 15:22:56 +0200 Subject: [PATCH 02/13] Fix some typos --- SFS_ir/ir_correct_distance.m | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/SFS_ir/ir_correct_distance.m b/SFS_ir/ir_correct_distance.m index 5774db38..445c8553 100644 --- a/SFS_ir/ir_correct_distance.m +++ b/SFS_ir/ir_correct_distance.m @@ -66,7 +66,7 @@ c = conf.c; fs = conf.fs; useoriglength = conf.ir.useoriglength; -%N = conf.N; is used if useoriglength==false +N = conf.N; %% ===== Computation ==================================================== @@ -77,9 +77,9 @@ 'only extrapolate up to 10m. All larger radii will be set to ', ... '10m.'],upper(mfilename)); end -% Zero-pad HRIRs to conf.N +% Append zeros at the end of the impulse responses to reach a length of N ir_origlength = size(ir,3); -ir = cat(3,ir,zeros(size(ir,1),size(ir,2),conf.N-ir_origlength)); +ir = cat(3,ir,zeros(size(ir,1),size(ir,2),N-ir_origlength)); % Append zeros at the beginning of the impulse responses corresponding to % its maximum radius if ~useoriglength @@ -94,7 +94,7 @@ weight = ir_distance./r; % Check if impulse responses are long enough compared to intended delay if conf.N-(zero_padding+delay) Date: Wed, 8 Jun 2016 15:30:20 +0200 Subject: [PATCH 03/13] Update comments --- SFS_ir/ir_correct_distance.m | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/SFS_ir/ir_correct_distance.m b/SFS_ir/ir_correct_distance.m index 445c8553..ab3ee50e 100644 --- a/SFS_ir/ir_correct_distance.m +++ b/SFS_ir/ir_correct_distance.m @@ -11,11 +11,7 @@ % N ... number of samples % ir_distance - distance of the given impulse responses [M 1] % r - desired distance [1] -% conf - configuration struct (see SFS_config), containing: -% conf.c -% conf.fs -% conf.N -% conf.ir.useoriglength +% conf - configuration struct (see SFS_config) % % Output paramteres: % ir - impulse responses [M C N] @@ -56,12 +52,6 @@ %***************************************************************************** -%% ===== Checking of input parameters ================================== -%nargmin = 4; -%nargmax = 4; -%narginchk(nargmin,nargmax); - - %% ===== Configuration ================================================== c = conf.c; fs = conf.fs; @@ -83,7 +73,7 @@ % Append zeros at the beginning of the impulse responses corresponding to % its maximum radius if ~useoriglength - zero_padding = ceil(ir_distance/c * fs); + zero_padding = ceil(ir_distance/c*fs); % / samples else zero_padding = 0; end From 0ad583a26f8cf6b27fd0463b11e0d2158368c6b7 Mon Sep 17 00:00:00 2001 From: Hagen Wierstorf Date: Thu, 9 Jun 2016 09:13:33 +0200 Subject: [PATCH 04/13] Remove 10m radius limit for HRIRs --- SFS_ir/ir_correct_distance.m | 7 ------- 1 file changed, 7 deletions(-) diff --git a/SFS_ir/ir_correct_distance.m b/SFS_ir/ir_correct_distance.m index ab3ee50e..cc9cb7fd 100644 --- a/SFS_ir/ir_correct_distance.m +++ b/SFS_ir/ir_correct_distance.m @@ -60,13 +60,6 @@ %% ===== Computation ==================================================== -% Stop extrapolation for distances larger than 10m -if any(ir_distance>10) - ir_distance = min(ir_distance,10); - warning(['%s: Your desired radius is larger than 10m, but we will ', ... - 'only extrapolate up to 10m. All larger radii will be set to ', ... - '10m.'],upper(mfilename)); -end % Append zeros at the end of the impulse responses to reach a length of N ir_origlength = size(ir,3); ir = cat(3,ir,zeros(size(ir,1),size(ir,2),N-ir_origlength)); From 27e8b172690837ae1c917ccef08b1dfe09c4bf25 Mon Sep 17 00:00:00 2001 From: Hagen Wierstorf Date: Thu, 9 Jun 2016 09:25:54 +0200 Subject: [PATCH 05/13] Remove conf.N from ir_correct_distance() --- SFS_ir/ir_correct_distance.m | 24 +++++------------------- 1 file changed, 5 insertions(+), 19 deletions(-) diff --git a/SFS_ir/ir_correct_distance.m b/SFS_ir/ir_correct_distance.m index cc9cb7fd..e96c5ed6 100644 --- a/SFS_ir/ir_correct_distance.m +++ b/SFS_ir/ir_correct_distance.m @@ -18,7 +18,7 @@ % % IR_CORRECT_DISTANCE(ir,ir_distance,r,conf) weights and delays the given % impulse responses, that they are conform with the specified distance r. -% The impulse responses are zero-padded to length conf.N. +% The impulse responses are zero-padded to not loose information. % % See also: get_ir @@ -55,32 +55,18 @@ %% ===== Configuration ================================================== c = conf.c; fs = conf.fs; -useoriglength = conf.ir.useoriglength; -N = conf.N; %% ===== Computation ==================================================== -% Append zeros at the end of the impulse responses to reach a length of N -ir_origlength = size(ir,3); -ir = cat(3,ir,zeros(size(ir,1),size(ir,2),N-ir_origlength)); -% Append zeros at the beginning of the impulse responses corresponding to -% its maximum radius -if ~useoriglength - zero_padding = ceil(ir_distance/c*fs); % / samples -else - zero_padding = 0; -end +% Time delay to ensure zeros before the maximum radius +offset = ceil(ir_distance/c*fs); % / samples % Time delay of the source (at the listener position) delay = (r-ir_distance)/c*fs; % / samples % Amplitude weighting (point source model) % This gives weight=1 for r==ir_distance weight = ir_distance./r; -% Check if impulse responses are long enough compared to intended delay -if conf.N-(zero_padding+delay) Date: Thu, 9 Jun 2016 09:48:09 +0200 Subject: [PATCH 06/13] Remove conf.N from driving_function_imp_wfs() --- SFS_time_domain/driving_function_imp_wfs.m | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/SFS_time_domain/driving_function_imp_wfs.m b/SFS_time_domain/driving_function_imp_wfs.m index 641c661a..2837ce54 100644 --- a/SFS_time_domain/driving_function_imp_wfs.m +++ b/SFS_time_domain/driving_function_imp_wfs.m @@ -70,7 +70,6 @@ %% ===== Configuration ================================================== fs = conf.fs; -N = conf.N; c = conf.c; t0 = conf.wfs.t0; @@ -142,8 +141,9 @@ end % Append zeros at the end of the driving function. This is necessary, because % the delayline function cuts into the end of the driving signals in order to -% delay them. NOTE: this can be changed by the conf.N setting -d_proto = repmat([row_vector(pulse) zeros(1,N-length(pulse))]',1,size(x0,1)); +% delay them. +ceil(max(delay)+delay_offset) +d_proto = repmat([row_vector(pulse) zeros(1,ceil(max(delay)+delay_offset))]',1,size(x0,1)); % Shift and weight prototype driving function [d, delayline_delay] = delayline(d_proto,delay*fs,weight,conf); % Add delay offset of delayline From f7e62b10cf804b31c458aaa1106bc10409f04823 Mon Sep 17 00:00:00 2001 From: Hagen Wierstorf Date: Thu, 9 Jun 2016 10:00:51 +0200 Subject: [PATCH 07/13] Finish driving_function_imp_wfs() --- SFS_time_domain/driving_function_imp_wfs.m | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/SFS_time_domain/driving_function_imp_wfs.m b/SFS_time_domain/driving_function_imp_wfs.m index 2837ce54..f4b4e953 100644 --- a/SFS_time_domain/driving_function_imp_wfs.m +++ b/SFS_time_domain/driving_function_imp_wfs.m @@ -111,17 +111,12 @@ if strcmp('system',t0) % Set minimum delay to 0, in order to begin always at t=1 with the first % wave front at any secondary source - delay = delay - min(delay); + delay = delay - min(delay); % / s % Return extra offset due to prefilter - delay_offset = prefilter_delay; + delay_offset = prefilter_delay; % / s elseif strcmp('source',t0) % Add extra delay to ensure causality at all secondary sources (delay>0) [diameter,center] = secondary_source_diameter(conf); - t0 = diameter/c; - if (ceil((max(delay)+t0)*fs) - 1 ) > N - % This is a lot more likely to happen. - warning('conf.N = %i is too short for requested source.',N); - end if strcmp('fs',src) % Reject focused source that's too far away % (this will only happen for unbounded listening arrays.) @@ -131,10 +126,10 @@ 'spanned by the array diameter.'],upper(mfilename)); end end - delay = delay + t0; + delay = delay + diameter/c; % / s % Return extra added delay. This is can be used to ensure that the virtual % source always starts at t = 0. - delay_offset = t0 + prefilter_delay; + delay_offset = diameter/c + prefilter_delay; % / s else error('%s: t0 needs to be "system" or "source" and not "%s".', ... upper(mfilename),t0); @@ -142,9 +137,9 @@ % Append zeros at the end of the driving function. This is necessary, because % the delayline function cuts into the end of the driving signals in order to % delay them. -ceil(max(delay)+delay_offset) -d_proto = repmat([row_vector(pulse) zeros(1,ceil(max(delay)+delay_offset))]',1,size(x0,1)); +zero_padding = zeros(1,ceil((max(delay)+delay_offset)*fs)); +d_proto = repmat([row_vector(pulse) zero_padding]',1,size(x0,1)); % Shift and weight prototype driving function -[d, delayline_delay] = delayline(d_proto,delay*fs,weight,conf); +[d,delayline_delay] = delayline(d_proto,delay*fs,weight,conf); % Add delay offset of delayline delay_offset = delay_offset + delayline_delay; From af2068e83c8ff03fb93fce343ba50f832cd11780 Mon Sep 17 00:00:00 2001 From: Hagen Wierstorf Date: Thu, 9 Jun 2016 10:15:12 +0200 Subject: [PATCH 08/13] Remove conf.N from localwfs_findhpref() --- SFS_time_domain/localwfs_findhpref.m | 1 - 1 file changed, 1 deletion(-) diff --git a/SFS_time_domain/localwfs_findhpref.m b/SFS_time_domain/localwfs_findhpref.m index 97588d97..a3e3351d 100644 --- a/SFS_time_domain/localwfs_findhpref.m +++ b/SFS_time_domain/localwfs_findhpref.m @@ -66,7 +66,6 @@ %% ===== Variables ====================================================== -N = conf.N; irs = dummy_irs(N,conf); % Impulse responses fs = conf.fs; % Sampling rate dimension = conf.dimension; % dimensionality From fae516d8fa85be308b4f9dac446ec36162c0410d Mon Sep 17 00:00:00 2001 From: VeraE Date: Thu, 9 Jun 2016 10:15:19 +0200 Subject: [PATCH 09/13] fixed ir_correct_distance.m --- SFS_ir/ir_correct_distance.m | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/SFS_ir/ir_correct_distance.m b/SFS_ir/ir_correct_distance.m index e96c5ed6..8c987cba 100644 --- a/SFS_ir/ir_correct_distance.m +++ b/SFS_ir/ir_correct_distance.m @@ -66,7 +66,6 @@ % This gives weight=1 for r==ir_distance weight = ir_distance./r; % Make sure impulse response is long enough for the specified delay -ir = cat(3,ir,zeros(size(ir,1),size(ir,2),delay+offset)); +ir = cat(3,ir,zeros(size(ir,1),size(ir,2),max(ceil(delay+offset)))); % Apply delay and weighting -ir = delayline(ir,[delay+zero_padding; delay+zero_padding], ... - [weight; weight],conf); +ir = delayline(ir,[delay+offset; delay+offset],[weight; weight],conf); From 4d7a83b0fffd6e35010df923ae6dc4aa73fc2197 Mon Sep 17 00:00:00 2001 From: VeraE Date: Thu, 9 Jun 2016 10:15:19 +0200 Subject: [PATCH 10/13] fixed ir_correct_distance.m --- SFS_ir/ir_correct_distance.m | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/SFS_ir/ir_correct_distance.m b/SFS_ir/ir_correct_distance.m index e96c5ed6..8c987cba 100644 --- a/SFS_ir/ir_correct_distance.m +++ b/SFS_ir/ir_correct_distance.m @@ -66,7 +66,6 @@ % This gives weight=1 for r==ir_distance weight = ir_distance./r; % Make sure impulse response is long enough for the specified delay -ir = cat(3,ir,zeros(size(ir,1),size(ir,2),delay+offset)); +ir = cat(3,ir,zeros(size(ir,1),size(ir,2),max(ceil(delay+offset)))); % Apply delay and weighting -ir = delayline(ir,[delay+zero_padding; delay+zero_padding], ... - [weight; weight],conf); +ir = delayline(ir,[delay+offset; delay+offset],[weight; weight],conf); From d622e5c4300fb3473a382e7c49373044950054e6 Mon Sep 17 00:00:00 2001 From: Hagen Wierstorf Date: Wed, 15 Jun 2016 09:54:14 +0200 Subject: [PATCH 11/13] Remove delay_offset from N calculation for WFS --- SFS_time_domain/driving_function_imp_wfs.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SFS_time_domain/driving_function_imp_wfs.m b/SFS_time_domain/driving_function_imp_wfs.m index f4b4e953..fd23eb31 100644 --- a/SFS_time_domain/driving_function_imp_wfs.m +++ b/SFS_time_domain/driving_function_imp_wfs.m @@ -137,7 +137,7 @@ % Append zeros at the end of the driving function. This is necessary, because % the delayline function cuts into the end of the driving signals in order to % delay them. -zero_padding = zeros(1,ceil((max(delay)+delay_offset)*fs)); +zero_padding = zeros(1,ceil(max(delay)*fs)); d_proto = repmat([row_vector(pulse) zero_padding]',1,size(x0,1)); % Shift and weight prototype driving function [d,delayline_delay] = delayline(d_proto,delay*fs,weight,conf); From 48489b4255a01436192dc108239874ae063364b5 Mon Sep 17 00:00:00 2001 From: Hagen Wierstorf Date: Wed, 15 Jun 2016 10:00:29 +0200 Subject: [PATCH 12/13] Ensure IIR WFS pre-filter has at least 2048 samples for convolution 2048 is the default of conf.N, which was used before for zeropadding --- SFS_time_domain/wfs_preequalization.m | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/SFS_time_domain/wfs_preequalization.m b/SFS_time_domain/wfs_preequalization.m index 793847b6..577d8b4d 100644 --- a/SFS_time_domain/wfs_preequalization.m +++ b/SFS_time_domain/wfs_preequalization.m @@ -77,10 +77,10 @@ % Delay in s added by filter delay = conf.wfs.hpreFIRorder/2 / fs; elseif strcmp('IIR',conf.wfs.hpretype) - if len_ir == 1 + if len_ir < 2048 % Happens when called from driving_function_imp_wfs() - % Zeropadding to length conf.N - ir = [ir; zeros(conf.N-1,size(ir,2))]; + % Zeropadding to 2048 (IIR filter needs infinite long signal) + ir = [ir; zeros(2048-len_ir,size(ir,2))]; end % Get IIR filter hpre = wfs_iir_prefilter(conf); From 51b83f5e8a271520794984449b1a1050714062d6 Mon Sep 17 00:00:00 2001 From: Hagen Wierstorf Date: Wed, 15 Jun 2016 10:16:57 +0200 Subject: [PATCH 13/13] Set length of NFC-HOA time driving signals to 2048 This was covered by conf.N before --- SFS_time_domain/driving_function_imp_nfchoa.m | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/SFS_time_domain/driving_function_imp_nfchoa.m b/SFS_time_domain/driving_function_imp_nfchoa.m index 3304e675..d60d9b4b 100644 --- a/SFS_time_domain/driving_function_imp_nfchoa.m +++ b/SFS_time_domain/driving_function_imp_nfchoa.m @@ -64,8 +64,11 @@ %% ===== Configuration ================================================== nls = size(x0,1); -N = conf.N; X0 = conf.secondary_sources.center; +% Length of driving signal (to which the driving signal is zero padded +% before the filter) +N = 2048; + %% ===== Computation ===================================================== % Generate stimulus pusle