Advanced maths

Short time Fourier spectrogram calculator from sample values

A short-time Fourier analysis computes a separate spectrum for successive portions of a sampled signal.

Your numbers

Calculated on your device. Your inputs aren’t sent to us.

Your result

Ready when you are

Enter your inputs and select Calculate.

Report an issue

Behind the numbers

How this calculation works

A short-time Fourier analysis computes a separate spectrum for successive portions of a sampled signal. It exposes when frequency content changes instead of merging the entire record into one transform. The price is a time-frequency tradeoff: shorter windows localize events more closely but separate neighboring frequencies less sharply.

THE FORMULAPSD(k)=|sum_j w_j x_j exp(−2πikj/L)|²/(fs sum_j w_j²),doubled at interior one-sided bins.

A worked example

A unit-amplitude1Hz sine sampled at8Hz with periodic Hann length16 and hop8 gives3 frames,9 bins,and integrated power0.5 per frame.

Good to know

Real8–512 samples,even window8–64,hop1–window,≤1,000 cells;positive sample rate,periodic Hann or rectangular window;one-sided PSD,complete windows only,no padding.

Resolve frequency content over short time windows

A short-time Fourier analysis computes a separate spectrum for successive portions of a sampled signal. It exposes when frequency content changes instead of merging the entire record into one transform. The price is a time-frequency tradeoff: shorter windows localize events more closely but separate neighboring frequencies less sharply.

This calculator accepts a real uniformly sampled sequence and produces a one-sided power spectral density for each complete window. It reports frame times, frequency bins, the strongest time-frequency cell and integrated power checks. It does not infer a sample rate from the values or analyze irregularly timed observations.

Windowed short-time Fourier power density3 time framesPeak 1 Hz∫ PSD df = 0.5Time →;frequency ↑
Scroll across to see the full diagram.
A unit-amplitude1Hz sine sampled at8Hz with periodic Hann length16 and hop8 gives3 frames,9 bins,and integrated power0.5 per frame.

Compare this with the Discrete Fourier transform calculator for complex sequences. Return localized frequency power over time windows,not a single whole-record transform.

Specify the sampling and window lengths

The sample rate is the number of samples per unit time, such as samples per second. The window length is an even number of samples, and the hop is the number of samples advanced between adjacent frames. These are counts rather than durations; dividing by the sample rate converts them into time units.

Between eight and five hundred twelve samples are supported, with windows from eight to sixty-four samples and hops from one to the window length. A further one-thousand-cell budget limits the product of frame count and frequency bins. The final incomplete window is omitted rather than padded with invented values.

Choose a window deliberately

A rectangular window gives equal weight to every sample in a frame. The periodic Hann window tapers the values toward the frame boundary, reducing leakage for many off-bin signals at the cost of a wider main lobe. The selected window is part of the analysis and affects displayed peak density.

The Hann convention here uses one minus cosine of two pi times sample index divided by window length, scaled by one half. It is the periodic form, not the symmetric denominator-length-minus-one form sometimes used in filter design. Match that convention when comparing precise numbers with another implementation.

Read one-sided density units correctly

Each complex Fourier magnitude is squared and divided by the sample rate and the sum of squared window weights. Interior positive-frequency bins are doubled to account for omitted negative frequencies, while the zero and Nyquist bins are not doubled. This produces a one-sided density rather than unnormalized FFT magnitude.

The frequency spacing is sample rate divided by window length. Summing density times that spacing yields the window-weighted mean square of the frame. The implementation checks this Parseval relationship numerically, which helps expose normalization or one-sided doubling errors that would otherwise make plausible-looking spectra quantitatively incorrect.

Check the one-hertz example

The thirty-two prefilled samples form a unit-amplitude sine wave at one cycle per second with sample rate eight. A sixteen-sample window and hop eight give three complete frames. Each frame has nine one-sided frequency bins spaced by half a hertz, and the strongest bin is one hertz.

The integrated power of every default frame is approximately one half, matching the mean square of a unit sine under this windowed example. The peak density is about two thirds, not one half, because density is distributed across bins and has different units from integrated power. Equating a density maximum with total power would be incorrect.

Balance resolution against timing

Increasing the window length narrows the frequency-bin spacing but averages over a longer portion of the signal. Reducing the hop increases overlap and produces more time samples of the spectrogram without increasing the underlying frequency resolution. Adjacent overlapping frames are not independent repetitions of the experiment.

The displayed frame time is the center of the actual complete sample window. No edge padding, detrending or hidden extension is applied, so early and late centers do not cover the full record endpoints. An impulsive change near a boundary may therefore appear differently from a centered-window method with explicit padding.

Keep the interpretation within the sampled signal

The Nyquist frequency is half the entered sample rate, but avoiding aliasing also depends on how the original signal was sampled and filtered. A calculated spectrogram cannot recover frequencies that were aliased before the values reached the calculator. Wrong sample-rate units rescale every frequency and frame time consistently but incorrectly.

This page does not apply log-power display corrections, significance testing, reassignment or adaptive windows. Its small direct Fourier calculation is intended for transparent numerical examples. Preserve the sample rate, window convention, hop and one-sided density normalization whenever exporting values so another analyst can reproduce both timing and power units.

A few questions, answered

Are incomplete end windows padded?

No. Only complete windows are included.

Why are interior bins doubled?

For real data,the negative-frequency power is folded into matching positive-frequency bins;DC and Nyquist are not doubled.

Does the window change amplitude and resolution?

Yes. The PSD normalization accounts for window energy,but temporal and spectral leakage tradeoffs remain.

What checks integrated power?

A per-frame discrete Parseval comparison verifies the one-sided PSD sum against the windowed sample energy.

Find your calculator

Start typing to explore the library.