Initializing playground…
← Back to roadmap

📡 Signal Processing — Interactive Playground

FFT, windows, STFT, Welch PSD, and periodogram — mirrors numpy.fft and scipy.signal.
Edit any code block below and press ▶ Run (or Ctrl+Enter) to execute it live in your browser.

1. Basic FFT of a sinusoidal signal

Compute a 32 Hz sine wave's FFT and identify the peak frequency bin.

TypeScript
Click ▶ Run to execute
Ctrl+Enter to run · Tab to indent

2. Parseval's theorem — energy preservation

The total energy is preserved between time and frequency domains.

TypeScript
Click ▶ Run to execute
Ctrl+Enter to run · Tab to indent

3. RFFT round-trip

Real-input FFT produces a half-spectrum; irfft reconstructs the original signal.

TypeScript
Click ▶ Run to execute
Ctrl+Enter to run · Tab to indent

4. Window functions

Named windows reduce spectral leakage. Use getWindow(name, n) to obtain any built-in window.

TypeScript
Click ▶ Run to execute
Ctrl+Enter to run · Tab to indent

5. Short-Time Fourier Transform (STFT)

Analyze a chirp signal whose frequency increases linearly over time.

TypeScript
Click ▶ Run to execute
Ctrl+Enter to run · Tab to indent

6. ISTFT reconstruction (round-trip)

Invert an STFT back to the time domain. Interior reconstruction error should be near machine epsilon.

TypeScript
Click ▶ Run to execute
Ctrl+Enter to run · Tab to indent

7. Welch PSD — detect signal frequency

Welch's method averages periodograms of overlapping segments for a lower-variance PSD estimate.

TypeScript
Click ▶ Run to execute
Ctrl+Enter to run · Tab to indent

8. Periodogram

A single-segment PSD estimate — higher variance but simpler than Welch.

TypeScript
Click ▶ Run to execute
Ctrl+Enter to run · Tab to indent

9. fftshift / ifftshift

Rearrange the FFT output so that the zero-frequency component is in the centre.

TypeScript
Click ▶ Run to execute
Ctrl+Enter to run · Tab to indent

API Reference

FunctionDescriptionMirrors
fft(x)N-point DFT (pads to power of 2)numpy.fft.fft
ifft(X)Inverse FFTnumpy.fft.ifft
rfft(x)Real-input FFT (one-sided)numpy.fft.rfft
irfft(X, n?)Inverse real FFTnumpy.fft.irfft
fftFreq(n, d?)DFT sample frequenciesnumpy.fft.fftfreq
rfftFreq(n, d?)One-sided DFT frequenciesnumpy.fft.rfftfreq
fftshift(x)Shift DC to centrenumpy.fft.fftshift
ifftshift(x)Inverse of fftshiftnumpy.fft.ifftshift
getWindow(name, n)Named window functionscipy.signal.get_window
stft(x, opts?)Short-Time Fourier Transformscipy.signal.stft
istft(Zxx, opts?)Inverse STFT (overlap-add)scipy.signal.istft
welch(x, opts?)Welch PSD estimatescipy.signal.welch
periodogram(x, opts?)Periodogram PSD estimatescipy.signal.periodogram