stft hop size calculator
STFT Hop Size Calculator guide
A spectrogram draws one column for every analysis frame. The length of the waveform inside a column and the distance to the next column can be different. Enter the acquired window length, the samples shared by neighboring windows and the sample rate. Read the hop to configure a second analyzer to use the same time grid.
Play the instrument ↑- Default result
- 256 samples per hop
Calculation and units
For a window of N samples and an overlap of O samples, the hop H equals N minus O. The frame spacing is H divided by the sample rate in seconds, and the update rate is the sample rate divided by H. Zero overlap gives a hop of one full window. The overlap must be smaller than the window.
Worked examples
Select a named case in the Worked example control to load these values. You can then edit any input to compare the result.
Quarter-window advance
Window length (samples) = 1024 · Overlap (samples) = 768 · Sample rate (Hz) = 48000.
256 samples per hop. 5.333333 ms between frames · 187.5 frames/s · 75% overlap.
Three quarters of the acquired data is reused. The 256-sample advance determines the column time grid, even when the display later stretches those columns across a different number of screen pixels.
Half-window advance
Window length (samples) = 1024 · Overlap (samples) = 512 · Sample rate (Hz) = 48000.
512 samples per hop. 10.666667 ms between frames · 93.75 frames/s · 50% overlap.
Larger steps reduce the number of spectra per second while leaving the duration represented by each acquired frame unchanged. Compare this with adjusting the analysis length itself.
Adjacent blocks
Window length (samples) = 1024 · Overlap (samples) = 0 · Sample rate (Hz) = 48000.
1024 samples per hop. 21.333333 ms between frames · 46.875 frames/s · 0% overlap.
These windows meet without sharing samples. A short attack close to a block boundary may be represented differently than in an overlapping analysis using the same taper.
One-sample hop
Window length (samples) = 128 · Overlap (samples) = 127 · Sample rate (Hz) = 48000.
1 samples per hop. 0.020833 ms between frames · 48000 frames/s · 99.21875% overlap.
The hop is one positive sample at the maximum valid overlap for this window. It requests a spectrum at every sample position, which can make a long analysis computationally expensive.
Same interval at another rate
Window length (samples) = 2048 · Overlap (samples) = 1536 · Sample rate (Hz) = 96000.
512 samples per hop. 5.333333 ms between frames · 187.5 frames/s · 75% overlap.
The rate and both lengths double. Frame spacing in seconds remains the same even though the number of data points processed per transform has doubled.
Non-power-of-two window
Window length (samples) = 960 · Overlap (samples) = 720 · Sample rate (Hz) = 48000.
240 samples per hop. 5 ms between frames · 200 frames/s · 75% overlap.
A 20-millisecond window advances by five milliseconds under these settings. An FFT implementation may use a different padded transform length without changing the number of acquired samples shared by neighbors.
Interpreting the result
Imagine labeling a 1024-sample window from sample zero through 1023. If the next window starts at 256, it reuses samples 256 through 1023. There are 768 shared samples and the analyzer advances by 256. At 48 kHz these two positions are about 5.33 ms apart, even though the data in each window covers about 21.33 ms.
For a file with no implicit padding, use the hop to locate valid starting samples. With 2048 acquired samples, a 1024-sample window and a 256-sample hop, complete windows start at 0, 256, 512, 768 and 1024. A package that centers the first window on sample zero can report additional columns near the ends. Compare its boundary policy before comparing column counts.
Measurement and model limits
Check whether a library expects hop length, overlap in samples, or an overlap fraction before transferring values. Entering 75 in a field that expects samples does not request 75 percent. Use the reported percentage as a cross-check. Changing the FFT size through zero padding can change the number of frequency bins while leaving every frame start unchanged.
Music theory tools → · FFT Frequency Resolution Calculator → · SciPy ShortTimeFFT reference →
Answers before you play
Common questions
Will a smaller hop improve frequency resolution?
It supplies more closely spaced time observations of overlapping data. Separation of nearby tones also depends on the acquired window length, taper and signal. A higher column rate alone cannot separate two frequencies that a short window blends together.
Can this guarantee perfect reconstruction?
That requires compatible analysis and synthesis windows, overlap handling and boundary choices. The hop is one input to that design. For inverse transforms, check the conditions and normalization used by the specific implementation with the same window.
What should I enter for 75 percent overlap?
Multiply your analysis window length by 0.75 and enter that many shared samples. For a 2048-sample window use 1536 shared samples, which gives a 512-sample hop.
Is the update rate the audio sample rate?
The input sample rate counts individual acquired samples per second. Analysis frames advance once per hop, so the two rates are equal only for a one-sample hop.