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}$: