Soudure — under the hood
Coherence, energy of the sum, FIR with reported latency: how a bass DI and its amp are aligned
Ultra-GeekWritten with the help of AI
Ultra-Geek · This post opens the hood of Soudure 1.0.0: algorithms, physics and formulas. Version 1.1.0 (song map, clock drift, continuous mode, presets) builds on these foundations; it is described in the manual, not here. To use the plugin, the manual is enough; to understand what happens inside, read on. For a short presentation of the plugin, read the introduction post.
Soudure listens to a song, compares the direct signal of a bass (the DI) with that of its amp, and looks for the correction (delay, polarity, phase rotation) that gives the mix the most energy in the low end. The hard part is not finding a delay: it is not finding a false one.
1. The problem: two tracks, one bass
A bass recorded on two tracks, DI and amp, captures the same string vibration twice. If the two tracks arrive in phase, they add up. If not, they get in each other’s way. At a frequency where the amp is shifted by φ relative to the DI, and at equal levels, the sum is:
In phase, the sum gains 6 dB over one track. At 120°, it gains nothing: the amp adds tone, not weight. At 180°, it cancels. Since the low end of a bass is made of sinusoids that cross several of these zones at once, the phase shift does not dig one hole: it deflates part of the low end.
To reason on the whole band, Soudure counts energy. With S_DD and S_AA the energies of the two tracks and ρ their correlation in the band:
ρ = 1 gives 4 (+6 dB over the DI alone, the theoretical maximum), ρ = 0 gives 2 (+3 dB), ρ = −1 gives 0. The gain displayed in the plugin is this quantity: 10·log₁₀((2 + 2ρ after) / (2 + 2ρ before)), for two tracks of equal level in the band, since the faders are unknown. The Level Match button, for its part, uses the real levels of the capture.
2. Where the phase shift comes from
Three things shift the amp relative to the DI:
- the microphone distance: sound takes d/c to travel d, that is 0.44 ms for 15 cm (c ≈ 343 m/s);
- the interface and the amp plugin: a few milliseconds of latency, sometimes badly compensated;
- the cabinet, and it is the sneakiest. A loudspeaker in its enclosure behaves like a high-pass filter. Such a filter does not only cut the low end: it rotates its phase, more and more as you go down. The delay each frequency undergoes is called the group delay:
The diagram shows a 4th-order Butterworth high-pass at 60 Hz: the 40 Hz note arrives about 9 ms after the mids, which are hardly delayed at all. A simulated cabinet or a bass-reflex cabinet does worse, in the order of 10 to 20 ms, with up to 530° of phase rotation between 22 and 140 Hz.
A bass line is made of notes. A bass note holds a low fundamental and harmonics in the mids: the cabinet separates those harmonics in time. No single delay can align both the low end and the mids.
3. The trap: not looking for a broadband delay
The classic way to align two tracks is cross-correlation, often with the GCC-PHAT weighting (Knapp and Carter, 1976): look for the offset where the two signals look the most alike. On a simulated cabinet, it answers 0 ms. The mids hold most of the energy of the signal over the whole band, they are aligned, and they drown the low end that is not.
So Soudure changes the criterion. It does not look for the offset that makes the tracks “look alike”, but the one that maximises the energy of their sum in the target band, after deciding frequency by frequency where the measurement can be trusted. A broadband delay found on these tracks would be a false delay: 7 to 14 ms, sometimes with the polarity inverted, which would shift the attack of the mids by the same amount and you would hear a flam.
4. LEARN: listening to the song
Capture. While the song plays, the plugin copies both tracks (the DI comes in through the sidechain input) for the Listen Time, from 2 to 30 seconds, 8 by default. The analysis then runs on a separate thread: the audio thread never blocks.
Welch’s method. A single FFT over the whole capture would be too noisy. The capture is cut into 0.68 s segments (32,768 samples at 48 kHz, or fewer if the capture is short), windowed with a Hann window, with 50 % overlap (Welch, 1967). Only the segments where both tracks play are kept: the energy of each track in the band must exceed −40 dB relative to the loudest segment, and at least four are needed. The spectra of each segment, D_s(f) for the DI and A_s(f) for the amp, are averaged into three quantities:
The cross-spectrum S_AD is a complex number per frequency: its modulus says whether the two tracks move together, its argument gives the phase of the amp relative to the DI. This measured phase, and nothing else, is what the plugin tries to bring back to zero.
Coherence. How far can this phase be trusted? The coherence, smoothed over three neighbouring bins, answers:
γ = 1 means that the amp is, at that frequency, a filtered version of the DI. γ close to 0 means there is no stable relation: the amp has saturated and created harmonics with no fixed phase, the microphone picks up the room, or the tracks have nothing to do with each other. The useful bins are those where γ ≥ 0.5 (the Coherence setting), with real signal on both tracks, between Band Low (25 Hz by default, below the low B of a 5-string bass: 30.9 Hz) and Band High. They are the only ones that count, and the only ones that are corrected. On a clean simulated cabinet the useful band reaches 250 Hz; on a very saturated amp it stops around 60 Hz.
5. Searching for the correction
The correction is a complex frequency response H(f) applied to the amp. Over the useful bins U, its effect on the energy of the mix depends on a single sum:
Maximising J means maximising the correlation, hence the energy 2 + 2ρ of the sum. In the parametric modes, H is built from a few parameters:
a is the advance in milliseconds (positive: the amp is moved earlier), ± is the polarity, and AP is a second-order all-pass filter (RBJ formulas), which does not change the level but rotates the phase by −180° at its frequency f₀.
The search. For each pair (frequency f₀, Q) of a grid of 26 frequencies from 20 to 150 Hz (log-spaced) × 7 values of Q (from 0.35 to 3), plus the case with no rotation, the plugin sweeps the delay from −19.5 to +19.5 ms in 0.02 ms steps, with both polarities, and keeps the best J. A regular sweep needs no exponential at each step: the phasor of each bin is multiplied by the phasor of the step. Then a local search (delay, f₀ and Q) refines the best candidate, shrinking its step down to 10 nanoseconds.
Avoiding the false delay. Several candidates give almost the same energy. So the plugin also estimates the delay of the mids (above 250 Hz, or 150 Hz if need be) with the PHAT weighting: each bin becomes a unit phasor z_k = S_AD / |S_AD|, weighted by its coherence, which gives every harmonic the same weight, and the d that maximises |Σ Re[e^{j2πf_k d} z_k]| is found by a sweep followed by a golden-section search. In + Rotation mode, the search is limited to ±1 ms around that delay: the mids never move by more than a millisecond. In all the parametric modes, among the candidates whose energy is within 1.17 % (of the energy of one track) of the best, the plugin picks the one whose delay is closest to that of the mids, and penalises rotation by 0.4 ms. At equal energy, the simplest wins.
6. Fine mode: a FIR that rotates the phase frequency by frequency
A causal second-order all-pass can only add phase delay. For a cabinet that delays the low end by 10 to 20 ms, the opposite is needed: advance the low end, that is, delay everything else by the same amount. Such a filter is possible if you accept some latency. So Fine mode builds a finite impulse response (FIR) filter whose phase follows the measured phase:
The target phase P(k) of each useful bin is the opposite of the average phase of the five neighbouring unit phasors, weighted by level and by γ²: a noisy bin weighs little. The gaps between useful bins are filled by complex interpolation. Outside the useful band, the phase fades smoothly towards a pure delay (a smoothing function x²(3 − 2x)), so that the filter does not ring. The polarity is a global sign, chosen by trying both. The impulse response is brought back to the time domain by inverse FFT, ±c samples are kept around the centre, with a fade on the outer fifth, and the response actually obtained after truncation is measured: it is that response, not the ideal one, that is used for the displayed gains.
The centre c of the FIR is the reported latency minus a block of 128 samples (the delay inherent to the convolution): 832 samples at 20 ms, 1,792 at 40 ms. The filter can therefore advance the low end by c at most: 17.3 ms or 37.3 ms. That is why a simulated cabinet wants 40 ms, and why LEARN says so when it would be worth it: it also computes the gain the long latency would give.

The WAVE screen shows the result on an excerpt of about 85 ms of the useful band: before, the amp (in red) follows the DI (in white) with an offset that varies with the note; after, it hugs it.
7. The verdict, and knowing when to do nothing
After the search, the confidence is the correlation obtained on the useful bins, between 0 and 1.
- Below 0.3, there is no usable link: “Confidence too low”, nothing is applied.
- If the best correction gains less than 0.05 dB: “Already in phase”, nothing is applied. It is not a failure, it is the right answer on a pair that is already aligned or on a saturated amp.
- Otherwise, the correction is applied, and the screen gives the gain, the useful band and a guess about the origin of the signal (simulation or render when the mean coherence exceeds 0.9, recorded amp otherwise).
The analysis also checks whether the relation drifts during the capture, by comparing the delay of the mids at the start and at the end: a difference of more than 0.05 ms points to two clocks that do not run at the same speed. The plugin says so; it does not correct it yet.
8. Real time: fixed latency, click-free fades
The correction is an offline computation. Real time has to apply it without artefacts.
- A fixed latency, reported to the host (20 or 40 ms), which never changes during playback. It makes it possible to advance the amp (delay it by a little less than the latency) as well as to delay it. This is what makes Soudure a mixing tool, not a live monitoring one.
- A fractional delay: the amp is read with a delay D = L − a, using a 32-point Kaiser-windowed sinc (β = 8.5), for a delay that is accurate to a fraction of a sample. The DI is delayed by exactly L.
- The all-pass rotation: when a new correction starts, the filter replays the last 0.4 s to start from the correct state, with no transient.
- The FIR convolution: by partitions of 128 samples in the frequency domain (Gardner, 1995). Two sets of responses share the same input history, which makes it possible to go from one to the other without any warm-up.
- 50 ms fades at every change of correction: no clicks.
The correlometer and the RE-LEARN lamp use a live measurement: if the instantaneous correlation falls below its slow average by more than 0.35 for 0.4 s, the relation between the tracks has changed (another cabinet, another EQ in the simulation) and the lamp turns rust. The plugin never re-aligns by itself: you decide when to run LEARN again.
9. What it gives
On my recordings, the plugin’s automatic acceptance tests check that it gets close to the phase optimum, the maximum gain the measurements themselves allow (the ideal correction, bin by bin, over the useful band):
| Item | Gain at equal levels | Share of the optimum |
|---|---|---|
| 4-string bass pair | +4.7 dB | 100 % |
| 8×10 bass pair | +3.7 dB | 94 % |
| 5-string bass pair, very saturated amp | nothing to correct | — |
The last case is deliberate: a saturated amp has almost no stable phase relation with the DI above 60 Hz, and Soudure answers “already in phase” rather than inventing a correction.
10. References
- P. D. Welch, “The use of fast Fourier transform for the estimation of power spectra”, IEEE Transactions on Audio and Electroacoustics, 15(2), 1967, pp. 70–73.
- C. H. Knapp and G. C. Carter, “The generalized correlation method for estimation of time delay”, IEEE Transactions on Acoustics, Speech, and Signal Processing, 24(4), 1976, pp. 320–327: GCC-PHAT.
- W. G. Gardner, “Efficient convolution without input-output delay”, Journal of the Audio Engineering Society, 43(3), 1995, pp. 127–136: partitioned convolution.
- R. Bristow-Johnson, “Cookbook formulae for audio EQ biquad filter coefficients”: the all-pass filter.
- U. Zölzer (ed.), DAFX: Digital Audio Effects, 2nd ed., Wiley, 2011: filters, fractional delays.
- J. O. Smith III, Introduction to Digital Filters and Spectral Audio Signal Processing, CCRMA, Stanford (online): phase, group delay, windows, FIR.
- PolMax Studio, Soudure page and manual: /plugins/soudure/