`hann_window` does not obey COLA; therefore, it cannot be used with `istft`
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 2.9k
- Forks
- 798
- Avg merge
- 58m
- Merged PRs (30d)
- 3
Description
🐛 Bug
In order to enable inversion of an STFT via the inverse STFT in istft, it is sufficient that the signal windowing obeys the constraint of “Constant OverLap Add” (COLA). This ensures that every point in the input data is equally weighted, thereby avoiding aliasing and allowing full reconstruction.
https://docs.scipy.org/doc/scipy/reference/generated/scipy.signal.check_COLA.html
Learn more: https://ccrma.stanford.edu/~jos/sasp/Mathematical_Definition_STFT.html#19930
To Reproduce
>>> from scipy import signal
>>> import torch
>>> signal.check_COLA(signal.hann(1024, sym=False), 1024, 1024 - 256)
True
>>> signal.check_COLA(torch.hann_window(1024).numpy(), 1024, 1024 - 256)
False
>>> window = torch.hann_window(1024).numpy()
>>> window[0] *= 0.5
>>> window[-1] *= 0.5
>>> signal.check_COLA(window, 1024, 1024 - 256)
False
Expected behavior
The expected behavior is that the hann window is implemented such that it is useable with istft.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the torch.hann_window entry point and compare its output with scipy.signal.check_COLA using the parameters in the reproduction. Check how the window is used with istft; done when the Hann window satisfies the stated COLA case and the expected reconstruction behavior is covered by tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, pytorch
- Domain
- audio-video-rtc
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100