@@ -954,15 +954,19 @@ def intersection_time_lundeby(
954954 sampling_rate = np .round (1 / np .diff (data .times ).mean (), decimals = 4 )
955955 energy_data = energy_data .time
956956
957+ # number of frequency bands given by first channel axis
958+ n_bands = np .prod (data .cshape )
957959 if smoothing_parameter == "broadband" :
958960 # broadband: use 30 ms windows sizes
959- freq_dependent_window_time = 0.03
961+ freq_dependent_window_time = np . atleast_1d ([ 0.03 ] * n_bands )
960962 elif isinstance (smoothing_parameter , (int , list , tuple , np .ndarray )):
961- smoothing_parameter = np .asarray (smoothing_parameter )
962- if (smoothing_parameter .ndim > 0 ) and (
963- smoothing_parameter .size != np .prod (data .cshape )):
963+ smoothing_parameter = np .atleast_1d (smoothing_parameter )
964+ if smoothing_parameter .size == 1 :
965+ smoothing_parameter = np .tile (smoothing_parameter , n_bands )
966+ elif smoothing_parameter .size != n_bands :
964967 raise ValueError (
965- "The size of smoothing_parameter must match data.csize." )
968+ "The size of smoothing_parameter must match the number of "
969+ "frequency bands." )
966970 freq_dependent_window_time = (800 / smoothing_parameter + 10 ) / 1000
967971 else :
968972 raise TypeError (
@@ -986,19 +990,12 @@ def intersection_time_lundeby(
986990 noise_peak_level = np .zeros (data .cshape , data .time .dtype )
987991
988992 for ch in np .ndindex (data .cshape ):
989- if len (np .atleast_1d (smoothing_parameter )) > 1 :
990- output = _intersection_time_lundby (
991- time_window_data [ch ], noise_estimation [ch ], energy_data [ch ],
992- np .squeeze (np .atleast_2d (time_vector_window )[ch , :]),
993- dB_above_noise , n_intervals_per_10dB ,
994- use_dyn_range_for_regression , sampling_rate ,
995- ch , failure_policy )
996- else :
997- output = _intersection_time_lundby (
998- time_window_data [ch ], noise_estimation [ch ], energy_data [ch ],
999- time_vector_window , dB_above_noise , n_intervals_per_10dB ,
1000- use_dyn_range_for_regression , sampling_rate , ch , failure_policy )
1001-
993+ output = _intersection_time_lundby (
994+ time_window_data [ch ], noise_estimation [ch ], energy_data [ch ],
995+ np .squeeze (np .atleast_2d (time_vector_window )[ch , :]),
996+ dB_above_noise , n_intervals_per_10dB ,
997+ use_dyn_range_for_regression , sampling_rate ,
998+ ch , failure_policy )
1002999 if output is None :
10031000 reverberation_time [ch ] = np .nan
10041001 noise_level [ch ] = np .nan
0 commit comments