DSP ENGINE

Custom digital signal processing algorithms built from scratch — no external libraries.

PERSONAL PROJECT DSP FFT DENOISING ALGORITHMS PYTHON JAVASCRIPT

// DFT_CALCULATOR INTERACTIVE

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.

// SIGNAL BUILDER

5
0.80
N = 128 samples Fs = 128 Hz
TIME DOMAIN — x[n]
DFT
FREQUENCY DOMAIN — |X[k]|

// SIGNAL_DENOISER INTERACTIVE

Three denoising algorithms, one noisy signal. Build a waveform, crank the noise, then compare how each algorithm recovers the original — measured by R² correlation.

// SIGNAL BUILDER

3
0.80
7
0.60
0.40
N = 200 samples
ORIGINAL SIGNAL
NOISE
NOISY SIGNAL
SPECTRAL --

Iterative threshold — zeros weak bins, subtracts noise floor

CONFIDENCE --

Logistic curve — soft probability gating per frequency bin

SORT --

Magnitude cliff — sorts frequencies, cuts below the drop-off

// UNDER_THE_HOOD

Everything above runs on code written from scratch — no NumPy, no SciPy, not even Math.sin. Click any card to inspect the full source.

trig.py Constants & Helpers
Pi constant, iteration config, factorial, and angle wrapping
pi = 3.14159265359159 iterations = 25
trig.py sin() / cos() / tan()
Core trig via Taylor series — 25 terms, no built-in math
def cos(x): for i in range(iterations): y += 1/(fac(2*i)) * x**(2*i) * (-1)**i
trig.py Signal Generators
sine, cosine, square (Fourier series), sawtooth wave builders
def square(x, freq, N, phase, amp): for i in range(1, 10 * iterations): a += sin(...) / (2*i - 1)
signals.py noise()
LCG pseudorandom noise with auto-normalization to signal amplitude
def noise(signal, loudness): seed = 51925 a = 987325234; c = 40871212; m = 1767174
signals.py dft()
O(N²) Discrete Fourier Transform — real-valued sin/cos correlation
def dft(x): for j in range(N): a += x[j] * trig.cos(2*pi*j*i/N)
signals.py fft() / fftorganize()
Cooley-Tukey radix-2 recursive FFT — O(N log N) with twiddle factors
def fftorganize(x): neven = fftorganize(even) nodd = fftorganize(odd)
signals.py ift()
Inverse Fourier Transform — reconstructs time-domain from magnitude + phase
def ift(mag, phase): for j in range(length): x += mag[i] * cos(i*j*2π/N + φ[i])
denoising.py spectral()
Iterative threshold denoiser — zeros weak bins, subtracts noise floor
def spectral(x): thresh = noisemean + 3 * noisesd mag[i] -= mean # subtract floor
denoising.py confidence()
Logistic confidence gating — soft probability curve per frequency bin
def confidence(x): factor = (thresh - mag[i]) / noisesd mag[i] *= 1 / (1 + e ** factor)
denoising.py sort()
Magnitude drop-off detector — sorts frequencies, finds the cliff, cuts below
def sort(x): mag = sorted(mag, reverse=True) if differences[i] > 2*sd: remove = i

// DESIGN

// GOAL

Build digital signal processing tools with no external libraries or copying any external code. Every operation is transparent, computed from first principles.

// ARCHITECTURE

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.

// DENOISING PHILOSOPHY

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.

// IMPLEMENTED MODULES

trig.py sin / cos / tan — Taylor series
trig.py arctan / arccos — inverse trig
signals.py DFT — O(N²) brute force
signals.py FFT — O(N log N) Cooley-Tukey
signals.py IFT — inverse reconstruction
signals.py Noise — LCG pseudorandom
denoising.py Spectral — iterative threshold
denoising.py Confidence — logistic gating
denoising.py Sort — magnitude drop-off

// PLANNED

FIR / IIR Filters Windowing Functions Z-Transform

// PROJECT STATUS

ACTIVE DEVELOPMENT