A twin-T notch is a passive RC network that puts a deep null at one frequency. Phonalyser.web uses one as the pre-filter for its lowest-distortion measurements: parked on the fundamental, it removes the big tone so the ADC can be driven hard on the harmonics alone (DAC pre-distortion explains why that notch is mandatory). But a twin-T's null is only deep when its three trimmed components are balanced exactly, and the balance drifts with temperature. The tune-notch tool is the live display you watch while turning the trimmer: it shows the notch's own magnitude response, refreshing a few times a second, so you can walk the null onto the target frequency and see how deep it really goes.
It measures a transfer function the same way the frequency-response module does - a logarithmic sweep in, a division out - but it is built for a continuously updating live view rather than a single careful capture, and that changes how the sweep is run.
Tuning is a closed loop with a human in it: turn the trimmer a hair, see the null move and deepen, turn again. A one-shot sweep that opens the device, plays, captures and closes takes on the order of a second and a half of dead time between pictures - far too slow to tune by. So the tool keeps the sound device open and the sweep running, and simply takes a fresh look at the most recent period whenever it can. The reward is a display that reacts almost as fast as your hand; the challenge is that each look is grabbed at an arbitrary moment in the loop, with no start marker to line it up. The trick below is what makes that not matter.
The generator plays a short logarithmic sweep on an endless seamless loop into the notch under test; the return signal is collected in a small rolling buffer that always holds the last few sweep periods. Several times a second the tool grabs exactly one period's worth of samples, transforms it, divides the returned spectrum by the known sweep spectrum to get the notch's magnitude, and tracks the deepest point.
The sweep is played on a loop whose length is deliberately rounded to a power of two samples,
so that the transform of one grabbed period is a circular one - the buffer wraps back onto itself with no gap. A window taken at some random phase of the loop is then nothing more than the same periodic sweep rotated by a few samples, and the shift theorem of the transform says a rotation changes only the phase of each bin, never its magnitude:
Because tuning reads only magnitude, the arbitrary grab phase drops out entirely - no start marker, no trigger, no alignment. This is the whole reason the live loop is allowed to be careless about when it looks. (Round the period to anything other than a power of two and the transform is no longer circular: an unaligned window then wraps across the seam and smears every bin into a spike, which is exactly the artefact this avoids.)[2] The one seam that does exist - where the loop rejoins its own start - is smoothed by a short raised-cosine fade applied identically to the played sweep and to the reference it is divided by, so the two cancel.
Each period is turned into the notch's magnitude response by dividing the returned spectrum by the swept reference spectrum, H(f) = Y(f) ⁄ X(f) - the same Farina deconvolution the frequency-response chapter describes[1]. The deepest point of that curve is read off the trace as it is painted: the curve is evaluated at every pixel column of the plot and the lowest one wins.
Here W is the plot width in pixels, f(k) the frequency the painter maps to column k, and D the same reconstruction it draws with - per-pixel Lanczos while that is active for the current axis and width, plain interpolation between bins otherwise. Earlier versions instead refined the null to a fraction of a bin by fitting a parabola through the lowest sample and its two neighbours in linear magnitude. That fit has been removed: a well-trimmed null is a V, not a parabola, and a curve laid across its two steep walls has its vertex above the true bottom, so the depth came out shallower than the notch really was. Taking the painted minimum also makes the readout, the target marker and the curve on screen one number - at a sharp null the three used to disagree by 2-3 dB. The vertical auto-fit is applied after the null is known, so the axis always leaves a decibel of room below the dip rather than clipping it.
The null frequency and depth are what you read off the display as you trim. One deliberate difference from an ordinary sweep measurement: the usual smoothing that tidies a frequency-response trace is switched off here. On the coarse grid this quick live view uses, a smoothing window would span many hertz and round several decibels off the bottom of a sharp null - hiding exactly the depth you are trying to maximise. A raw, un-smoothed curve reads the true null.
◀ Frequency response · Theory of operation · next: Algorithm reference ▶