Skip to content

Conversation

@carolineechen
Copy link
Contributor

@carolineechen carolineechen commented May 17, 2021

Add kaiser window as an option for resampling
Jupyter notebook of some results kaiser_resampling__1_.pdf

cc #1487

@carolineechen carolineechen force-pushed the resample-kaiser-window branch 3 times, most recently from 9577a1d to a5bf156 Compare May 17, 2021 20:59
rolloff: float):
rolloff: float,
resampling_method: str,
beta: float = 6.):
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to https://numpy.org/doc/stable/reference/generated/numpy.kaiser.html, a value of 6 is similar to a Hanning window shape (used for sinc_interpolation), but I'm open to other default values as well. Resampy uses ~8.55 for their kaiser_fast and ~14.77 for kaiser_best.

@carolineechen carolineechen force-pushed the resample-kaiser-window branch from a5bf156 to dd6c076 Compare May 17, 2021 21:39
# There is probably a way to evaluate those filters more efficiently, but this is kept for
# future work.
idx = torch.arange(-width, width + orig_freq)
idx = torch.arange(-width, width + orig_freq, dtype=torch.float64)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

through running separate scripts, I realized that #1499 introduced rounding errors if waveform dtype was greater than float32. adding dtype=float64 here to retain implementation accuracy from the prior version, and this implementation will likely be improved after additional discussion on transforms kernel dtype/device computation

@carolineechen carolineechen force-pushed the resample-kaiser-window branch from dd6c076 to 76bf776 Compare May 17, 2021 22:29
@carolineechen carolineechen marked this pull request as ready for review May 18, 2021 13:50
@carolineechen carolineechen requested a review from mthrok May 18, 2021 13:50
new_freq (float, optional): The desired frequency. (Default: ``16000``)
resampling_method (str, optional): The resampling method. (Default: ``'sinc_interpolation'``)
resampling_method (str, optional): The resampling method.
Options: [``sinc_interpolation``, ``kaiser_window``] (Default: ``'sinc_interpolation'``)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

followup: This docstring can be improved.

@carolineechen carolineechen merged commit 7078fcd into pytorch:master May 19, 2021
@mthrok mthrok mentioned this pull request May 20, 2021
6 tasks
mthrok pushed a commit to mthrok/audio that referenced this pull request Dec 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants