Custom digital signal processing algorithms built from scratch — no external libraries.
Build a signal from waveforms, then watch the Discrete Fourier Transform decompose it into frequency components — computed in real-time using a from-scratch algorithm.
Three denoising algorithms, one noisy signal. Build a waveform, crank the noise, then compare how each algorithm recovers the original — measured by R² correlation.
Iterative threshold — zeros weak bins, subtracts noise floor
Logistic curve — soft probability gating per frequency bin
Magnitude cliff — sorts frequencies, cuts below the drop-off
Everything above runs on code written from scratch — no NumPy, no SciPy, not even
Math.sin. Click any card to inspect the full source.
pi = 3.14159265359159
iterations = 25def cos(x):
for i in range(iterations):
y += 1/(fac(2*i)) * x**(2*i) * (-1)**idef square(x, freq, N, phase, amp):
for i in range(1, 10 * iterations):
a += sin(...) / (2*i - 1)def noise(signal, loudness):
seed = 51925
a = 987325234; c = 40871212; m = 1767174def dft(x):
for j in range(N):
a += x[j] * trig.cos(2*pi*j*i/N)def fftorganize(x):
neven = fftorganize(even)
nodd = fftorganize(odd)def ift(mag, phase):
for j in range(length):
x += mag[i] * cos(i*j*2π/N + φ[i])def spectral(x):
thresh = noisemean + 3 * noisesd
mag[i] -= mean # subtract floordef confidence(x):
factor = (thresh - mag[i]) / noisesd
mag[i] *= 1 / (1 + e ** factor)def sort(x):
mag = sorted(mag, reverse=True)
if differences[i] > 2*sd: remove = iBuild digital signal processing tools with no external libraries or copying any external code. Every operation is transparent, computed from first principles.
Three-file stack: trig.py implements low-level math
primitives from Taylor series, signals.py builds
core DSP on top, and denoising.py layers three
distinct denoising strategies. Everything is pure Python arithmetic — no NumPy, no
SciPy, no math module. The JavaScript port mirrors this 1:1.
Each algorithm approaches the same problem differently: spectral uses brute-force thresholding, confidence applies probabilistic soft gating, and sort exploits the magnitude distribution. The R² comparison shows that no single approach is universally best.