loading...
running...
The science
A periodic signal f(x) of period 2π can be written as a sum of sinusoids whose coefficients are projections of f onto each harmonic:
f(x) ~ a0/2 + Σ [a_n cos(nx) + b_n sin(nx)], a_n = (1/π)∫ f cos(nx) dx, b_n = (1/π)∫ f sin(nx) dx
Each term equals r_n sin(nx + ψ_n) with r_n = sqrt(a_n²+b_n²). That is a vector of length r_n turning at n times the fundamental rate, so the sum is a chain of rotating arms ("epicycles") and the series value is the height of the last tip. Here the coefficients are computed numerically (8192-point midpoint rule) for the waveform you choose, with x = 2π f t.
Known spectra. Square wave: b_n = 4/(nπ) for odd n only. Sawtooth: 2/(nπ) for all n. Triangle: 8/(n²π²) for odd n (it converges much faster because it is continuous). Full-wave rectified sine contains only even harmonics plus DC.
Gibbs phenomenon. Near a jump the partial sum overshoots by a fixed fraction of the jump: (Si(π)/π - 1/2) = 8.95%, however large N is; only the width of the overshoot shrinks like 1/N. The Lanczos sigma factor sinc(nπ/(N+1)) multiplies each term and reduces the overshoot to about 1.2% at the price of a slightly blurred edge.
Parseval. The mean power of the signal (into 1 ohm) equals the sum of the power in its harmonics: <f²> = (a0/2)² + ½ Σ r_n². The "power captured" readout is the partial sum of that series divided by the exact mean square.
Simplifications. The 80-harmonic cap means the sharpest edges are always slightly rounded; fundamental frequencies are slowed to 0.05 to 1.5 Hz so the motion can be followed (real audio signals are hundreds of times faster). The coefficient integrals are numerical, not symbolic; the checks below compare them with the closed forms.