A question for any truly advanced level mavens.
When we decide to fit a dataset with a line there are well defined algorithms like Least Squares fit in statistics.
All clear cut and reproducible.
When I want to, say, equalise a speaker then I have to best fit a curve with Poles and Zeros.
In parametric equaliser nomenclature that's centre frequencies and Qs, lo-pass and hi-pass, shelves and so on.
Similarly for a cross over, there may be a need to tailor the electrical response so the acoustic response behaves correctly.
Rather than just trial and error "there's a peak there so let's drop a parametric notch on that", has anyone seen any work on how to optimise the process?
The statistics literature has many ways to fit splines and the like but not quite suitable for this AFAIK.
It seems there should be some work on this but perhaps it's too nerdy for DIY?
David
When we decide to fit a dataset with a line there are well defined algorithms like Least Squares fit in statistics.
All clear cut and reproducible.
When I want to, say, equalise a speaker then I have to best fit a curve with Poles and Zeros.
In parametric equaliser nomenclature that's centre frequencies and Qs, lo-pass and hi-pass, shelves and so on.
Similarly for a cross over, there may be a need to tailor the electrical response so the acoustic response behaves correctly.
Rather than just trial and error "there's a peak there so let's drop a parametric notch on that", has anyone seen any work on how to optimise the process?
The statistics literature has many ways to fit splines and the like but not quite suitable for this AFAIK.
It seems there should be some work on this but perhaps it's too nerdy for DIY?
David
Hi,
There is a special case which 'automate' the process: linkwitz transform.
For real world application, there is usually no needs for an automated process: tweak until it 'fit' your target curve.
There is a special case which 'automate' the process: linkwitz transform.
For real world application, there is usually no needs for an automated process: tweak until it 'fit' your target curve.
not a maven by any means, ....only dumb enough to think i can throw in a few comments !
I think the target curve math you might be looking for, has to be in the various types of automated EQs floating around.
REW's auto EQ is the only one I know that generates IIR EQs in a form where the EQs can be placed in a traditional processor. Iow, like you mentioned, "centre frequencies and Qs, lo-pass and hi-pass, shelves and so on". There's bound to be other programs that work in IIR mode / biquad mode (like the limited case krivium brought up), but i'm unaware of them.
I've looked towards FIR based automation. Most products there seem to cater to the room correction market, like Dirac does. But quite a few allow multi-way xover design too. Acourate, DRC, Audiolense i think, and most definitely FirDesigner as examples.
I have no idea what the math is that fits a measured response to a target response (that includes high pass and low pass filters)....I haven't seen any programs authors write about it. Maybe DRC-FIR or something in Matlab describes it.....
The easiest manual method of matching acoustic targets that i know of, is simply flatten both in-band and out-of-band response as far as you want good critical region summation; and then apply complementary xovers. Works with either IIR, or FIR as linear phase or as minimum phase. Just check that out-of-band boost used in flattening is sufficiently attenuated post xover application.
I think the target curve math you might be looking for, has to be in the various types of automated EQs floating around.
REW's auto EQ is the only one I know that generates IIR EQs in a form where the EQs can be placed in a traditional processor. Iow, like you mentioned, "centre frequencies and Qs, lo-pass and hi-pass, shelves and so on". There's bound to be other programs that work in IIR mode / biquad mode (like the limited case krivium brought up), but i'm unaware of them.
I've looked towards FIR based automation. Most products there seem to cater to the room correction market, like Dirac does. But quite a few allow multi-way xover design too. Acourate, DRC, Audiolense i think, and most definitely FirDesigner as examples.
I have no idea what the math is that fits a measured response to a target response (that includes high pass and low pass filters)....I haven't seen any programs authors write about it. Maybe DRC-FIR or something in Matlab describes it.....
The easiest manual method of matching acoustic targets that i know of, is simply flatten both in-band and out-of-band response as far as you want good critical region summation; and then apply complementary xovers. Works with either IIR, or FIR as linear phase or as minimum phase. Just check that out-of-band boost used in flattening is sufficiently attenuated post xover application.
haven't used it in a while but VituixCAD has an automated filter fit tool.
the developer has a thread somewhere on DIYaudio
the developer has a thread somewhere on DIYaudio
VituixCAD is swiss army knife for loudspeaker work. Can do many things, even optimize crossover part values to meet (acoustic) target slopes. Load in measurements and of you go. https://kimmosaunisto.net/
Also check that the processor is floating point or that you don't have numerical overflow issues inside the DSP pipeline if fixed point.The easiest manual method of matching acoustic targets that i know of, is simply flatten both in-band and out-of-band response as far as you want good critical region summation; and then apply complementary xovers. Works with either IIR, or FIR as linear phase or as minimum phase. Just check that out-of-band boost used in flattening is sufficiently attenuated post xover application.
I'm not sure entirely automatic design is a good idea as you may end up doing things like boosting nulls or correcting phenomenon that are unstable with position unless the algorithm is quite sophisticated at which point it's requiring manual parameters anyway. Here is a method of using REW to generate FIR filters:
https://www.diyaudio.com/community/threads/rew-as-fir-generator-experiments.349880/
Rather than just trial and error ....., has anyone seen any work on how to optimise the process?
I've seen a commercial method make use of the mismatched area between actual and target curves to optimise the PEQs after which the result is continuously refined until all the available biquads are exhausted. I also remember that it didn't take more than 10-12 biquads to get an essentially perfect response that way. Maybe it works.
Though the (commercial) source code may not be openly available, you could still try the same and see if it makes sense to you.
https://community.st.com/s/question...ertune-for-automatic-loudspeaker-compensation
crossover transfer function = acoustic target / raw driver responsefor a cross over, there may be a need to tailor the electrical response so the acoustic response behaves correctly
I vaguely remember that the control theory section of the Delft University of Technology had some program that could convert measured frequency responses into pole-zero patterns, but I don't remember any details; it is over 30 years ago. I think it was a bit wonky, because sometimes two or more patterns more or less fitted the measured data.
The Spectre simulator can output pole-zero patterns, I think it gives you the choice between the algorithms QR and Arnoldi. No idea if those are suitable for measured data.
More fundamentally, can a loudspeaker still be treated as a lumped system at high audio frequencies, where its size is not much smaller than the wavelength?
The Spectre simulator can output pole-zero patterns, I think it gives you the choice between the algorithms QR and Arnoldi. No idea if those are suitable for measured data.
More fundamentally, can a loudspeaker still be treated as a lumped system at high audio frequencies, where its size is not much smaller than the wavelength?
Basically it is an inversion, there are a few other stages to make sure that the inversion doesn't result in an unrealistic filter.I've looked towards FIR based automation. Most products there seem to cater to the room correction market, like Dirac does. But quite a few allow multi-way xover design too. Acourate, DRC, Audiolense i think, and most definitely FirDesigner as examples.
I have no idea what the math is that fits a measured response to a target response (that includes high pass and low pass filters)....I haven't seen any programs authors write about it. Maybe DRC-FIR or something in Matlab describes it.....
DRC-FIR docs explain the process it uses
- Initial windowing and normalization of the input impulse response.
- Optional microphone compensation.
- Initial dip limiting to prevent numerical instabilities during homomorphic deconvolution.
- Decomposition into minimum phase and excess phase components using homomorphic deconvolution.
- Prefiltering of the minimum phase component with frequency dependent windowing.
- Frequency response dip limiting of the minimum phase component to prevent numerical instabilities during the inversion step.
- Prefiltering of the excess phase component with frequency dependent windowing.
- Normalization and convolution of the preprocessed minimum phase and excess phase components (optional starting from version 2.0.0).
- Impulse response inversion through least square techniques or fast deconvolution.
- Optional computation of a psychoacoustic target response based on the magnitude response envelope of the corrected impulse response.
- Frequency response peak limiting to prevent speaker and amplification overload.
- Ringing truncation with frequency dependent windowing to remove any unwanted excessive ringing caused by the inversion stage and the peak limiting stage.
- Postfiltering to remove uncorrectable (subsonic and ultrasonic) bands and to provide the final target frequency response.
- Optional generation of a minimum phase version of the correction filter.
- Final optional test convolution of the correction filter with the input impulse response.
A question for any truly advanced level mavens.
When we decide to fit a dataset with a line there are well defined algorithms like Least Squares fit in statistics.
All clear cut and reproducible.
When I want to, say, equalise a speaker then I have to best fit a curve with Poles and Zeros.
In parametric equaliser nomenclature that's centre frequencies and Qs, lo-pass and hi-pass, shelves and so on.
Similarly for a cross over, there may be a need to tailor the electrical response so the acoustic response behaves correctly.
Rather than just trial and error "there's a peak there so let's drop a parametric notch on that", has anyone seen any work on how to optimise the process?
The statistics literature has many ways to fit splines and the like but not quite suitable for this AFAIK.
It seems there should be some work on this but perhaps it's too nerdy for DIY?
David
The issue i see in doing something 'automated' about the eq is into the analysis of input data: i talked about LT in my first answer to your question as it is a minimum phase phenomenom and so can be somewhat 'automated'.
But how would such a routine based process identify diffraction from a driver minimum phase frequency response defect? Iow i have same concerns as Kipman725.
I suppose it could be implemented with an 'inteligent' process analysing a set of polar measurements and some kind of averaging based on the full set of measurements ( or through an MMM technique) but i would suspect it would still need some human involved into the process to make the final choice imho.
Maybe this is possible to do it without a human taking the lead on choices but i'm still cautious about it. After all there is now a number of 'processors' doing it by 'themself' ( Dirac) as Mark pointed but the most advanced ones ( imo) still ask for separate 'steps' involving operator choices ( Acourate).
Maybe i'm biased by the use to do it by myself too for a long time ( i can quickly reach my target with a limited number of measurements and a limited amount of eq)?
Anyway it was worth being interested in it even if only for validation of what i applied intuitively ( even if based on bad assumptions from my side... EG: dont try to compensate notch/dip, works only by attenuation, etc,etc,..).
Dave Zan, may i ask what idea leads you to ask for this? Do you want to implement something or it is just curiosity?
Last edited:
In case you're looking for a simple algorithm that is practicable, then there's the following. For example, let us assume that you have 10 biquads available for frequencies ranging from 20Hz to 20kHz.
1) Apply octave smoothing from 20Hz to 20000Hz. This should give you a smoothened response that neglects the fine variations in response between adjacent frequencies.
2) Start by applying 10 PEQs (with correct gains) at the 10 centre frequencies of interest namely 30, 60, 120, 240, 480, 960, 1920, 3840, 7680 and 15360 Hz. Also apply these filters to obtain a slightly corrected response.
3) Refine the compensation by combining several adjacent narrow PEQs with fewer ones, with lower Q-factors.
4) If you find that you still have several biquads left, then return to Step (1) for an iteration with lighter smoothing (say 1/2 or 1/3 octave) to get the next layer of narrower PEQs, combine them wherever possible and so on, until you run out of resources.
It should follow fairly easily that the smoothening in Step (1) is to be chosen according to the number of biquads available. The results would look (somewhat) like the below. The pictures are from the user manual for the software mentioned in post#7, for 4, 8 and 12 PEQs respectively, across 200-15kHz. Note that the method in the pictures uses mismatch area (and not peak gain) to iterate, so the actual results could be different.
1) Apply octave smoothing from 20Hz to 20000Hz. This should give you a smoothened response that neglects the fine variations in response between adjacent frequencies.
2) Start by applying 10 PEQs (with correct gains) at the 10 centre frequencies of interest namely 30, 60, 120, 240, 480, 960, 1920, 3840, 7680 and 15360 Hz. Also apply these filters to obtain a slightly corrected response.
3) Refine the compensation by combining several adjacent narrow PEQs with fewer ones, with lower Q-factors.
4) If you find that you still have several biquads left, then return to Step (1) for an iteration with lighter smoothing (say 1/2 or 1/3 octave) to get the next layer of narrower PEQs, combine them wherever possible and so on, until you run out of resources.
It should follow fairly easily that the smoothening in Step (1) is to be chosen according to the number of biquads available. The results would look (somewhat) like the below. The pictures are from the user manual for the software mentioned in post#7, for 4, 8 and 12 PEQs respectively, across 200-15kHz. Note that the method in the pictures uses mismatch area (and not peak gain) to iterate, so the actual results could be different.
Dave Gunnes is famous for having an EQ procedure called Temporal EQ or Gunness Focusing that can correct many acoustic anomalies with loudspeakers that must be at least semi automated. Its applied through an FIR filter but the procedure for generating the filter seems quite secret.
I think the difficulty lies is finding "the frequency response" of a loudspeaker. It differs for each radiation angle, whether you include room effects et cetera.
Dave Gunnes is famous for having an EQ procedure called Temporal EQ or Gunness Focusing that can correct many acoustic anomalies with loudspeakers that must be at least semi automated. Its applied through an FIR filter but the procedure for generating the filter seems quite secret.
Yes, Dave Gunness is in my view one of the guy at the 'avant garde' regarding commercial loudspeakers at the moment.
It seems they managed to have reached a point were all models within the range are replaceable without change in sound. Impressive. Even more if they have same sonic signature than Presonus Sceptre8 which use same waveguide/technology ( licenced to Presonus): they sounded very good to me.
There seems to be some Fir inverse forced step response involved from the video i've seen.
I wonder if they did not design the horn part to have a constant artefact behavior over a defined range which could help with the FIR filter.
Measure the system from 0 to 90 or even better 180 off axis, gated measurements no smoothing, and you'll see diffraction and resonances and stuff, some can be fixed with EQ some don't if dips/peaks vary with angle. Very easy thing to do with VituixCAD, tedious part is to take the measurements. Best thing is to see power response.In case you're looking for a simple algorithm that is practicable, then there's the following. For example, let us assume that you have 10 biquads available for frequencies ranging from 20Hz to 20kHz.
1) Apply octave smoothing from 20Hz to 20000Hz. This should give you a smoothened response that neglects the fine variations in response between adjacent frequencies.
2) Start by applying 10 PEQs (with correct gains) at the 10 centre frequencies of interest namely 30, 60, 120, 240, 480, 960, 1920, 3840, 7680 and 15360 Hz. Also apply these filters to obtain a slightly corrected response.
3) Refine the compensation by combining several adjacent narrow PEQs with fewer ones, with lower Q-factors.
4) If you find that you still have several biquads left, then return to Step (1) for an iteration with lighter smoothing (say 1/2 or 1/3 octave) to get the next layer of narrower PEQs, combine them wherever possible and so on, until you run out of resources.
It should follow fairly easily that the smoothening in Step (1) is to be chosen according to the number of biquads available. The results would look (somewhat) like the below. The pictures are from the user manual for the software mentioned in post#7, for 4, 8 and 12 PEQs respectively, across 200-15kHz. Note that the method in the pictures uses mismatch area (and not peak gain) to iterate, so the actual results could be different.
View attachment 1075511View attachment 1075512View attachment 1075513
Of course all that is true however, when we talk about EQ, we talk processing and we don't talk speakers. And when we say "curve fitting", we assume that there's a reference curve to fit things onto, and it doesn't matter where / how you obtained it. Also, when we talk EQ, we talk of things that can be EQed, and anything else that can't be EQed therefore, doesn't come into the picture.Thus, my suggestions were oriented (only) towards methods to optimise EQ and not towards those that give "perfect speakers". In this context (EQ), a "perfect response" is the same as "target response", which may or may not be flat. The X-curve maybe thought of as an example.
I'm not sure entirely automatic design is a good idea as you may end up doing things like boosting nulls or correcting phenomenon that are unstable with position unless the algorithm is quite sophisticated at which point it's requiring manual parameters anyway. Here is a method of using REW to generate FIR filters:
https://www.diyaudio.com/community/threads/rew-as-fir-generator-experiments.349880/
Hi, i had almost forgotten about that old thread of mine...that was a fun project.
Totally agree that automatic design must be done with care.
Ironically, using REW manually to simply invert the impulse response as per the linked thread, is perhaps the most "automatic" way to assure that overcorrections of things that shouldn't be corrected occur.
A pure impulse inversion like that will correct everything without discrimination...the good, the bad, and the ugly!
Perhaps after applying smoothing or FDW, or manually adjusting the measurement one wants to correct...having learned how to do that before using the trace arithmetic to invert the impulse response .......and learning how to include high pass and low pass in the measurement....then I'd say REW could make a good FIR generator.
But before all those adjustment steps are judiciously taken, beware of straight trace arithmetic impulse inversion !
Same warning applies to doing it with VituixCAD, as I remember....
Basically it is an inversion, there are a few other stages to make sure that the inversion doesn't result in an unrealistic filter.
Yep, my take is they are all inverting the impulse, with different methods to assure filters correctly address what can be corrected without negative consequence, and avoid detrimental corrections altogether.
This is the math part that 'i think' gets to what David was asking in his thread starter. How to fit to a curve...and it seemed like, how to fit normally specified PEQs and shelf filters to a xover curve, or perhaps even deeper with poles and zeroes.DRC-FIR docs explain the process it uses
- Impulse response inversion through least square techniques or fast deconvolution.
Once you get all your filters, you could write a function to decompose them into poles and zeroes. I had a MATLAB script once that I'm sharing below. It's a fairly straightforward one and anyone with basic C++ skills could follow what's being done. The parameters are:
A =>PEQ gain (V/V, not dB)
Q => Q-factor
frequency => centre frequency
The result gives the poles and zeroes sp1, sp2 and sz1, sz2 respectively. Since these quantities are complex, they're represented as structures with real and imaginary parts as members. However, no complex arithmetic has been used anywhere in this code (MATLAB).
A =>PEQ gain (V/V, not dB)
Q => Q-factor
frequency => centre frequency
The result gives the poles and zeroes sp1, sp2 and sz1, sz2 respectively. Since these quantities are complex, they're represented as structures with real and imaginary parts as members. However, no complex arithmetic has been used anywhere in this code (MATLAB).
Code:
% SET PARAMETERS HERE
A = 2; % +6dB
Q = 1;
frequency = 1000;
%PARAEQ
if(A>=1)
Q = Q/A;
else
Q=Q*A;
end
wc = 2*pi*frequency; % Cutoff frequency
delta = 1/(2*Q); % damping ratio
wc_dash = wc;
delta = 1/(2*Q*A);
delta_dash = A/(2*Q);
%Solve zeroes
if(delta_dash>=1)
sz1.real = -delta_dash*wc_dash + wc_dash*sqrt(delta_dash*delta_dash-1);
sz1.imag = 0;
sz2.real = -delta_dash*wc_dash - wc_dash*sqrt(delta_dash*delta_dash-1);
sz2.imag = 0;
else
sz1.real = -delta_dash*wc_dash;
sz1.imag = wc_dash*sqrt(1-delta_dash*delta_dash);
sz2.real = -delta_dash*wc_dash;
sz2.imag = -wc_dash*sqrt(1-delta_dash*delta_dash);
end
%Solve poles
if(delta>=1)
sp1.real = -delta*wc + wc*sqrt(delta*delta-1);
sp1.imag = 0;
sp2.real = -delta*wc - wc*sqrt(delta*delta-1);
sp2.imag = 0;
else
sp1.real = -delta*wc;
sp1.imag = wc*sqrt(1-delta*delta);
sp2.real = -delta*wc;
sp2.imag = -wc*sqrt(1-delta*delta);
end
- Home
- Loudspeakers
- Multi-Way
- Equalisation/Crossover - Best way to fit a curve?