Based on LinearResample::SetIndexesAndWeights where it retrieves the weights for
resampling as well as the indices in which they are valid. LinearResample (LR) means
that the output signal is at linearly spaced intervals (i.e the output signal has a
kaldi__get_lr_indices_and_weights( orig_freq, new_freq, output_samples_in_unit, window_width, lowpass_cutoff, lowpass_filter_width, device, dtype )
(float): The original frequency of the signal
(float): The desired frequency
(int): The number of output samples in the smallest repeating unit: num_samp_out = new_freq / Gcd (orig_freq, new_freq)
(float): The width of the window which is nonzero
(float): The filter cutoff in Hz. The filter cutoff needs to be less than samp_rate_in_hz/2 and less than samp_rate_out_hz/2.
(int): Controls the sharpness of the filter, more == sharper but less efficient. We suggest around 4 to 10 for normal use.
(torch_device): Torch device on which output must be generated.
(torch::torch_\<dtype\>): Torch dtype such as torch::torch_float
Tensor, Tensor): A tuple of
min_input_index (which is the minimum indices
where the window is valid, size (
weights (which is the weights
which correspond with min_input_index, size (
It uses sinc/bandlimited interpolation to upsample/downsample the signal.
The reason why the same filter is not used for multiple convolutions is because the sinc function could sampled at different points in time. For example, suppose a signal is sampled at the timestamps (seconds) 0 16 32 and we want it to be sampled at the timestamps (seconds) 0 5 10 15 20 25 30 35 at the timestamp of 16, the delta timestamps are 16 11 6 1 4 9 14 19 at the timestamp of 32, the delta timestamps are 32 27 22 17 12 8 2 3
As we can see from deltas, the sinc function is sampled at different points of time assuming the center of the sinc function is at 0, 16, and 32 (the deltas [..., 6, 1, 4, ....] for 16 vs [...., 2, 3, ....] for 32)
Example, one case is when the
new_freq are multiples of each other then
there needs to be one filter.
A windowed filter function (i.e. Hanning * sinc) because the ideal case of sinc function has infinite support (non-zero for all values) so instead it is truncated and multiplied by a window function which gives it less-than-perfect rolloff .
 Chapter 16: Windowed-Sinc Filters, https://www.dspguide.com/ch16/1.htm