DriftEcho & Dex
Hey Dex, I've been listening to this weird layered hum from the underground metro system at night and thinking about how we could model it with an adaptive filter. Thought you might have some ideas on the algorithmic side.
Hmm, the layered hum sounds like a mix of a few sinusoids with different delays and amplitudes. A simple way to model that is an adaptive FIR filter. Start with a standard LMS implementation – it’s easy to code and works fine for most cases. Pick a step size, say mu = 0.01, and give the filter enough taps to cover the delay spread, maybe 512 taps if you’re sampling at 48 kHz. Watch the mean‑squared error; if it stalls, try a smaller mu or switch to RLS for faster convergence, though that’s heavier computationally.
If the hum has a predictable periodicity, you could also try an adaptive sinusoidal model: keep a few sinusoids whose amplitudes and phases are updated by gradient descent. That can capture the layered structure with fewer parameters.
And if you want to separate the layers, run several adaptive filters in parallel, each initialized slightly differently, and then feed their outputs to a combiner that selects the best match. That should give you a decent starting point to play with.
Nice framework, Dex. I’d first try a 256‑tap FIR with a 0.005 step and run it in stereo so I can map left/right ambience. If it still lags, I’ll add a short‑time Fourier tweak to pull out the dominant frequencies and lock them in a phase‑locked loop. That keeps the hum’s texture but lets the filter snap to the real noise spikes. Let me know how the spectral roll‑off looks.
Sounds solid. With 256 taps you’ll get about 5 ms of latency at 48 kHz, so that should capture most of the ambience spread. The spectral roll‑off for an LMS‑FIR is mainly governed by the filter length and the step size – with 0.005 you’ll see a fairly gentle roll‑off around the cutoff. If you notice a sharp drop, increase the taps a bit or switch to a windowed FIR to flatten the response. The STFT‑based tweak will give you sharper peaks in the spectrum, so the roll‑off will look smoother around those dominant frequencies. Just keep an eye on the error curve; if it’s still high after adding the PLL, you might be missing some high‑frequency components that need more taps.
Got it, will keep the filter tight and watch the error curve. If the high‑frequency tail still bites, I’ll bump to 512 taps and try a Hamming window to keep the roll‑off flat. Let me know how the spectrum looks after the PLL tweak.
If you bump to 512 taps and apply a Hamming window, the spectrum should flatten nicely. The PLL tweak will lock onto the main hum peaks, so you’ll see a cleaner, more stable spectral shape. The high‑frequency tail should drop off more gracefully, and the error curve will likely plateau faster once the dominant components are locked. Just watch for that little bump around 10 kHz – if it persists, you might need a tiny extra buffer or a second PLL for the higher band.
Got it, I'll keep a close eye on that 10 kHz bump. If it sticks around, adding a second PLL for the higher band should smooth it out. Let me know how the error curve shapes up after the tweak.