# Group delay compensation for non coincident drivers

Suppose I have a two-way speakers system which can be modeled as a two-way Linkwitz-Riley crossovers network with impulse responses $$h_{lp}(n)$$ and $$h_{hp}(n)$$. I would like to equalize the group delay of the impulse response of the complete system given by the sum of the impulse responses of the crossovers ($$h_{sum}(n) = h_{lp}(n)+h_{hp}(n)$$) by applying a single equalizer at the input of the system; in other words, I cannot use an equalizer for each way, only one for both the crossovers.

If the speakers are coincident in space (same delay), the group delay of $$h_{sum}(n)$$ is the same as the group delay of $$h_{lp}(n)$$ and $$h_{hp}(n)$$ around the crossover point, so if I design an equalizer $$h_{eq}(n)$$ that inverts the group delay of $$h_{sum}(n)$$ I automatically equalize also the group delay of the two Linkwitz-Riley filters. In other words $$h_{lpEQ}(n) = h_{lp}(n) * h_{eq}(n)\\h_{hpEQ}(n) = h_{hp}(n) * h_{eq}(n)$$ both have flat group delay, with $$*$$ being the convolution and $$h_{sumEQ}(n) = h_{lpEQ}(n) + h_{hpEQ}(n)$$ will also have flat group delay.

If now the speakers are no more coincident in space, the group delay of $$h_{sum}(n)$$ will be different from the group delay of $$h_{lp}(n)$$ and $$h_{hp}(n)$$ and I will get an equalizer that compensates only the group delay of the sum. If I apply the equalizer to $$h_{lp}$$ and $$h_{hp}$$, the group delay of $$h_{lpEQ}(n)$$ and $$h_{hpEQ}(n)$$ will not be flat, only the group delay of $$h_{sumEQ}(n)$$ will be flat.

First question: how is the group delay of $$h_{sum}$$ related to to the group delays of $$h_{lp}$$ and $$h_{hp}$$ from a mathematical point of view? I know that the group delay of the convolution of two signals is the sum of the two singular group delays, but how is it with the sum of two signals?

Second question: when the speaker are not coincident, the magnitude of $$h_{sum}$$ will have a dip near the crossover frequency, due to the time delay. Is there a way to compensate this dip using only the group delay equalizer derived from $$h_{sum}$$? I am trying to understand if it is possible to create an equalizer that starting only from the knowledge of $$h_{sum}$$ is able to compensate the phase misalignments of $$h_{lp}$$ and $$h_{hp}$$.

I am really new to these concepts, so probably there are a lot of mistakes; obviously any further clarification would be very much appreciated.

Here is the Matlab code I used for the tests:

clear all; close all; clc;

fs = 48000;
NFFT = 32768;
f = linspace(0,fs,NFFT);
f_half = f(1:NFFT/2+1);

delta = [1,zeros(1,8191)];

%% COINCIDENT SPEAKERS
% Design the LR filters
[b,a] = butter(4, 1000/(fs/2));
h1 = filter(b,a,delta);
h1 = filter(b,a,h1);

[b,a] = butter(4, 1000/(fs/2),'high');
h2 = filter(b,a,delta);
h2 = filter(b,a,h2);

% Sum the impulse responses
h = h1+h2;

% Plot the magnitude
figure;
semilogx(f,20*log10(abs(fft(h1,NFFT)))); hold on;
semilogx(f,20*log10(abs(fft(h2,NFFT))));
semilogx(f,20*log10(abs(fft(h,NFFT))));
grid on; xlim([10,fs/2]);

% Plot the group delay
figure;
semilogx(f_half,grpdelay(h1,1,NFFT/2+1)/fs*1000); hold on;
semilogx(f_half,grpdelay(h2,1,NFFT/2+1)/fs*1000);
semilogx(f_half,grpdelay(h,1,NFFT/2+1)/fs*1000);

% Design the allpass group delay equalizer
ph = unwrap(angle(fft(h,NFFT)));
heq = real(ifft(exp(1j*-ph)));
heq = circshift(heq,length(h)/2);
heq = heq(1:length(h));

% Apply the group delay equalizer
h1eq = conv(h1,heq);
h2eq = conv(h2,heq);
heq = h1eq + h2eq;

% Plot the group delays
figure;
semilogx(f_half,grpdelay(h1eq,1,NFFT/2+1)/fs*1000); hold on;
semilogx(f_half,grpdelay(h2eq,1,NFFT/2+1)/fs*1000);
semilogx(f_half,grpdelay(heq,1,NFFT/2+1)/fs*1000);

% Plot the magnitude
figure;
semilogx(f,20*log10(abs(fft(h,NFFT))));

%% NON COINCIDENT SPEAKERS
% Shift the impulse response of h1 to simulate delay
h1 = circshift(h1,30);

% Sum the impulse responses
h = h1+h2;

% Plot the magnitude
figure;
semilogx(f,20*log10(abs(fft(h1,NFFT)))); hold on;
semilogx(f,20*log10(abs(fft(h2,NFFT))));
semilogx(f,20*log10(abs(fft(h,NFFT))));
grid on; xlim([10,fs/2]);

% Design the allpass group delay equalizer
ph = unwrap(angle(fft(h,NFFT)));
heq = real(ifft(exp(1j*-ph)));
heq = circshift(heq,length(h)/2);
heq = heq(1:length(h));

% Apply the group delay equalizer
h1eq = conv(h1,heq);
h2eq = conv(h2,heq);
heq = h1eq + h2eq;

% Plot the group delays
figure;
semilogx(f_half,grpdelay(h1eq,1,NFFT/2+1)/fs*1000); hold on;
semilogx(f_half,grpdelay(h2eq,1,NFFT/2+1)/fs*1000);
semilogx(f_half,grpdelay(heq,1,NFFT/2+1)/fs*1000);

% Plot the magnitude
figure;
semilogx(f,20*log10(abs(fft(heq,NFFT))));

EDIT with plots of the non-coincident speakers case.

Here are the plot of the magnitude responses of $$h_{lp}$$, $$h_{hp}$$ and $$h_{sum}$$ where you can see the dip.

These are the group delays of $$h_{lp}$$, $$h_{hp}$$ and $$h_{sum}$$, where $$h_{lp}$$ has a greater group delay due to the circshift:

Here is the group delay for the equalizer of $$h_{sum}$$:

And these are the group delays for $$h_{lpEQ}$$, $$h_{hpEQ}$$ and $$h_{sumEQ}$$:

• won't your result be dependent on listener location; is that ok? Mar 14 at 13:06
• yes, it is ok if the result is valid only in a single location, I am only trying to understand the theory of the operation for now Mar 14 at 13:09

For the first question, given the linear process, what you do to the sum with regards to filtering is equivalent to what you do to each and then sum.

For the second question, the dip is in the amplitude response- the equalizer could if desired compensate for amplitude variation as well as phase - but that is not part of the group delay. When equalizing each path individually, you could align the delays of each prior to the sum with two separate equalizers. The process of combining that to one equalizer would equivalently include the amplitude correction if such amplitude variation was a result of the different delays alone.

Mathematically it may be easier to consider group delay in the frequency domain since we the convolution of the signal with the impulse response of the speaker becomes a multiplication with the frequency response. Both responses from the perspective of a single use will add in frequency or time domain as a linear system.

In the frequency domain, group delay is the negative derivative of phase versus frequency. Generally we desire a linear phase slope which is associated with a fixed time delay independent of any frequency, and thus on its own, will not distort the signal. In the interest of matching two speakers, we likely want the delay from each speaker to both be linear phase in frequency and equal phase slope in frequency, and thus would be delay matched from a single users perspective. This would make the system equivalent to each speaker being equi-distant with not group delay distortion.

Please see this other post where I come up with the filter using least-squares approaches to match the delay between two microphones which is the similar problem in reverse. Given a single microphone and two speakers, the same approach could be used by monitoring each speaker in turn with a test signal and then determining the composite effective delay and delay variation between the two speakers. For this purpose the test signal should be "spectrally rich", meaning fully occupy all frequencies of interest. Chirps and white noise signals are useful for this purpose.

The OP has clarified in the comments that the speakers are in a single unit with a cross-over etc and not two speakers at different spatial locations. In this case the equalization as a single filter is rather straightforward- we can treat the speaker as a black-box single system and drive the equalization based on the response as measured characterized by a text microphone as detailed in the link above. This will compensate for everything in the black-box and provide the optimized composite response.

• Maybe I wasn't clear in the question, with two-way speaker I was meaning a single cabinet with a woofer and a tweeter for example, not a classical left-right stereo scenario. If I can't measure the woofer and the tweeter separately, but only together, i.e. a singole impulse response for the whole cabinet, is there a way to accomplish this? Mar 14 at 13:49
• Ah hence your earlier comment on crossover. Yes are you able to characterize with a single microphone and base your equalization on that? Then you can treat your system as a black box and apply equalization according to the details in my linked post. Mar 14 at 14:26
• @Spark123 Thanks, I answered your questions directly and concisely prior to my other details. Bottom line is yes, if you consider your equalizer to correct for both phase and amplitude in the sum signal rather than just a delay equalizer (which is phase only). Be careful of noise enhancement if your dip becomes to large. Mar 14 at 19:47
• Keep in mind that the solution is only perfect along one single spatial plane defined by the microphone position and the normal vector of the speaker-to-speaker axis. Taking the speaker directivity into account, the plane becomes a single line (if the microphone's $z$ is halfway between the speaker's centers) or a even a single point (if it is not). The magnitude of the error created by stepping out of the plane/line/point is proportional to the distance between the speakers (in the line case) and additionally the distance microphone-speakers (in the point case).
– Max
Mar 15 at 7:37
• You're welcome. I have a background in acoustics, so speed of sound is much closer to me, than speed of light.
– Max
Mar 15 at 13:01

I'm not sure whether this is a purely academic exercise or supposed to do something useful in the real world. Assuming it's the later, there are a few additional points to consider

1. Typically when doing a cross over design, the phase contribution from the cross over itself is a minor factor. There are the transfer functions of the drivers themselves, the contributions by the enclosure (specifically the edge diffractions) and than of course, the room itself (for a variety of placements).
2. You will generally try to optimize the magnitude spectrum over the listening area with a reasonable room loading assumption. Trying to equalize the group delay itself is problematic. The room does a LOT of damage to the monaural phase response and the the group delay of loudspeaker in a room is poorly defined and hard to measure. Put it differently: the group delay at any one frequency will change rapidly with only very small movements of either speaker or microphone.
3. Instead of using Linkwitz Riley you can also use odd order Butterworth filters. A 5th order Butterworth will give you high frequency selectivity and less peak group delay as compared to a 4th order LR
4. Both odd order Butterworth and even order Linkwitz Riley crossovers add up to an causal all pass filter. In order to equalize the group delay you would have to apply the inverse of that, which is an anti-causal allpass filter. The only practical way to do this, is to add a good junk of overall delay, which may result in latency issues.
5. In a real world cross over design all these different factors need to be taken into account. It's actually very common to NOT end up with a standard crossover but with different high/low pass frequencies and orders for both drivers.
6. Correcting non-incident drivers is difficult. The interference pattern varies a lot with listener/microphone position. Your best shot is good overall system design: choose dimension, driver placement and cross over frequencies so that the worst interference frequencies are outside if your cross over range.

First question: how is the group delay of hsum related to to the group delays of hlp and hhp from a mathematical point of view?

There is no simple mathematical relationship. Odd order BW and even order LR crossover sum to an allpass. Poles of the allpass are closely related to the poles of the underlying BW filter. The group delay of the sum is the group delay of that allpass. The simple case is a 1st order BW: the group delay of the sum is actually 0.

Second question: ... Is there a way to compensate this dip using only the group delay equalizer derived from hsum?

Sure. Just design a filter with a peak that's the inverse of the dip. The caveat here is that the dips varies with microphone/listener location.