FFT Fourier Decomposition
Explore signal components with a radix-2 Cooley-Tukey transform in your browser
About
Generate deterministic sine combinations or enter a numeric signal, then inspect waveform, magnitude and phase information, detected local frequency peaks, and inverse FFT accuracy. Inputs are processed entirely in the browser.
Examples
Exact 50 Hz tone
analyzeFourier(generateSyntheticSignal([{ frequency: 50, amplitude: 1, phase: 0 }], 256, 256), 256)peaks[0] -> { frequency: 50, magnitude: ~1 }Fifty cycles fit exactly into 256 samples at 256 Hz, so all energy lands on bin 50.
Lossless round-trip
ifft(fft([1.25, -2, 0.5, 3, 4.5, -1, 0, 2]))the original 8 samples backForward then inverse FFT inverts exactly up to floating-point rounding.
About this tool
FFT Fourier Decomposition analyzes signals with analyzeFourier(input, sampleRate): it returns the complex spectrum, per-bin magnitude/phase entries, magnitude-ranked peaks, and the ifft-reconstructed signal. Building blocks fft, ifft (alias inverseFFT), generateSyntheticSignal (alias generateSignal), detectPeaks, and isPowerOfTwo are exported individually.
The transform is an iterative radix-2 Cooley-Tukey FFT: inputs must be a positive power of two (never padded or mutated), bin k sits at k * sampleRate / N, and magnitudes scale by 2/N (1/N at DC and Nyquist). Peak detection keeps local maxima above 1e-10 and sorts them loudest-first.
Everything is deterministic and client-side: the same samples and sample rate always give the same bins and peaks, and round-tripping real data through ifft(fft(x)) recovers the input within floating-point tolerance.
How to use this tool
Prepare power-of-two samples
Supply 64, 256, 1024, or any 2^n-length array — other lengths throw instead of padding.
Analyze at the true rate
Pass the real sample rate so bin frequencies (k * rate / N) land on the intended hertz.
Read peaks loudest-first
Take peaks[0] as the dominant tone with its index, frequency, magnitude, and phase.
Verify with reconstruction
Compare reconstructed against the input to confirm the spectrum explains the signal.
Use cases
Identifying dominant tones
Decompose a recording into ranked sine components with frequency and phase.
Teaching bin math
Show how the same 50 Hz tone moves bins when the sample rate changes at fixed N.
Validating signal chains
Round-trip samples through fft/ifft to prove the pipeline is lossless.
Common mistakes
Mistake:Passing a non-power-of-two length and expecting zero-padding.
Fix:The FFT throws on lengths like 100 or 3 — resample or truncate to 2^n first (e.g. 128, 256).
Mistake:Reading peak index as hertz.
Fix:Index is the bin number; multiply by sampleRate / N for hertz — bin 25 at 512 Hz/N=256 is still 50 Hz.
Mistake:Expecting DC energy in peaks.
Fix:detectPeaks scans interior bins only, so a flat DC signal reports bin 0 magnitude with an empty peaks list.
Frequently asked questions
What does this tool do?
It analyzes signals with analyzeFourier(input, sampleRate) — complex spectrum, per-bin magnitudes/phases, loudest-first peaks, and the ifft reconstruction — plus fft, ifft (inverseFFT), generateSyntheticSignal (generateSignal), detectPeaks, and isPowerOfTwo.
Why is my 50 Hz tone on the wrong bin?
Bins are k * sampleRate / N: 50 Hz sits on bin 50 at 256 Hz/N=256 but bin 25 at 512 Hz/N=256. Read frequency, not index, and pass the true sample rate.
Is my signal uploaded or stored?
No. Synthesis, FFT butterflies, peak picking, and reconstruction run entirely in your browser.
Why did the FFT throw, or why are there no peaks?
Lengths must be a positive power of two — the FFT throws instead of padding, so resize to 2^n. An empty peaks list with strong bin-0 energy means a DC-only signal, which peak detection intentionally skips.
Related guides
References & standards
Related tools
.env Secret Safety Linter
Validate .env syntax and spot likely leaked credentials or placeholder secrets.
.htaccess Generator
Build an Apache .htaccess — HTTPS redirects, rewrites, error pages, security headers, and basic auth
2D Fluid Dynamics & Particle Physics Sandbox
A physics playground with two engines sharing one canvas. The fluid mode runs a real Eulerian Navier-Stokes solver — semi-Lagrangian advection, explicit diffusion, Jacobi pressure projection and vorticity confinement — that you paint with dye and velocity using mouse or touch. The particle mode is a damped Verlet N-body engine with gravity wells, Coulomb attractors and repulsors, spring links, wall restitution and elastic circle collisions. Particle counts adapt to the device (100k target on WebGL2 desktop, 2k-5k on CPU fallback), and every configuration exports as runnable code: a Matter.js world, a PixiJS ticker setup, or a standalone vanilla Canvas engine.
AI Function Calling Schema Generator
Generate function calling JSON schemas from TypeScript interfaces
Algorithm Arena & Data Structure Visualizer
Interactive arena for algorithms and data structures: eight sorting algorithms racing on one seeded input, six pathfinding algorithms walking generated mazes, and BST, AVL, Red-Black, B-tree, heap and trie operations replayed step by step with rotations highlighted. Every run shows the Big-O table and the phase-highlighted reference implementation in four languages, and compared values can be played as pitch (sonification) through the shared audio engine. Everything runs client-side; inputs never leave the browser.
Ansible Playbook Generator
Build an Ansible playbook — hosts, vars, and tasks with modules — as YAML