# STFT with varying window lengths (like the continuous wavelet transform)

I was wondering if it is possible to use windows of varying lengths when making a spectrogram based on the short-time Fourier transform (STFT). That is, for higher frequencies I would use shorter windows so that I get higher temporal resolution at the cost of poor spectral resolution. I understand this method will result in tradeoffs between time and frequency resolution just like in the continuous wavelet transform, as well as higher computational complexity.

I wanted to ask if there are any other disadvantages other than the ones mentioned above when the STFT is employed in such way since I could not find any literatures about it.

Thank you very much.

• That's very common practice. For example you can run your signal through some cascaded half band filters and have a different time resolution in each band. There is no other downside to it. May 27 at 11:04
• May 28 at 14:47

Simplifying a bit,

• CWT <-> STFT with varied resolution
• STFT <-> CWT with fixed resolution

it's the only defining difference between the two transforms (that still leads to very different properties). More fully, CWT will distribute window lengths exponentially (and resulting kernels are admissible), but you could use another distribution (e.g. linear). This doesn't necessarily come with greater compute complexity; CWT can be implemented with column-wise FFTs and have a hop_length.

1. Losing invertibility -> losing information. Possible depending on window and width selection.
2. Harder invertibility; even if possible, may be unclear how to. Some methods rely on clean invertibility (e.g. independent mode extraction, time-frequency reassignment).
3. Degraded feature quality / harder design: CWT atoms are designed to vary in time-frequency support. STFT atoms are optimized for a single tradeoff. Things like transform redundancy, analyticity, and boundary effects are better controllable with former when varying resolutions. (One can instead use a CWT wavelet and vary its resolution e.g. linearly).
4. Limited flexibility: windowing cannot achieve all behavior a wavelet can. "Windowing" is scaling of a complex sinusoid of single frequency; this lends to one unique center frequency. Center frequency has at least three different notions, each exploitable by wavelets (quick example). Note windowing cannot yield real wavelets (useful for fast transient detection, fractal analysis).

Also worth looking into the generalization of the two, Nonstationary Gabor Transform (NSGT).

• "It's the only defining difference between the two transforms" Assuming you're using a complex Morlet wavelet May 28 at 14:46
• @endolith Originally I wrote "simplified", then omitted because it's close enough in context. I clarify in point 4. It doesn't have to be Morlet but it does need to be admissible (which, I admit, is a "defining difference"), which isn't a criterion for windowing. Fair comment - edited. May 28 at 15:15
• Well to be the same as the STFT it needs to be Morlet, no? STFT only has one possible kernel May 28 at 18:30
• "Same" as in equal, the comparison is indeed more restricted; my intent is to convey the difference in terms of resolutions and fundamental operations. -- I don't follow on "one possible kernel", there are infinite possible zero-mean windowings of a cisoid. It's Morlet if STFT window is Gaussian (but only approximately, it falls apart for low center frequencies). May 28 at 18:57

This is sometimes done when creating a log frequency scaled spectrogram (which might better match human time versus pitch perception).

One issue with using multiple sizes of STFTs it that this results in multiple FFT outputs for the same graphical plot point (frequency vs. time). So you have to decide how to select from, scale, mix, interpolate, and/or cross-fade the overlapping FFT information without adding (more) visual banding artifacts, and in the frequency domain as well as the time domain, where the resolution difference problems can be orthogonal.

• "this results in multiple outputs for the same graphical plot point" -- I don't follow. A single point in the 2D time-frequency plane will still have a unique associated center frequency and timeshift. There's overlap in sense of adjacent rows but that's always the case. May 28 at 10:28
• One advantage of using mutiple sizes of overlapped STFTs over generic wavelets is that the full set of STFT results can have redundancy. You can invert from a subset of the FFT results, pick the one that produces the minimal local rounding or numerical errors, or whatever. May 31 at 5:53
• Unsure what you refer to. Using multiple kernels per center frequency is its own subject and can be done with wavelets (e.g. higher order GMWs). May 31 at 9:15
• If it's about taking a full STFT with each of the different window lengths, that's not OP's inquiry. The wavelet equivalent there is a different frequential width distribution. May 31 at 9:47