some DSP questions ( FIR )

Status
This old topic is closed. If you want to reopen this topic, contact a moderator using the "Report Post" button.
form a steady state AC point of view +180 is identical to -180.

ok i think i got it.

also i think you were right when you said you can simply apply FIR around the entire speaker.

this is a very important observation because it potentially allows one to save tons of money by not going fully active and not needing as many amplifiers.

thanks you for your patience.
 
That makes sense. I was tired last night so I was thinking it was the opposite.

I am going to try this 2nd Order offset out for a while and see if it makes any difference with what I listen to. The mic I am using just isn't linear enough to trust for an exact offset so I think this method might work somewhat better than before.
 
Well wouldn't this depend on what is causing those phase and amplitude distortions? That page seems fine in theory but in practice I think impulse response correction of amplitude distortions in a room is a little more messy.

I think that you can correct certain predictable and consistent distortions. Phase distortions caused by a crossover filter network are predictable and can be offset but room response isn't as predictable or consistent with complex signals vs test tones.

Maybe if you use anechoic or free field measurements as a basis to offset certain mechanical deficiencies I can see it working to an extent.
 
Knew you'd ask.

x(t):

An externally hosted image should be here but it was not working when we last tested it.


X(f):

An externally hosted image should be here but it was not working when we last tested it.



Note that the amplitude is the inverse of the double impulse system.

And, lastly, this isn't about correcting room response. It is about correcting a loudspeaker's phase response. This exercise was just addressing Borat's question about a double impulse system.
 
Thanks John, comforting to see that the amplitudes are doubling as expected :) and interesting that what is in effect early truncation of the response doesn't hurt the correction for the band limited excitation used.



The impulse is not truncated. After the big negative peak there is nothing to follow except some noise in the acquisition. The pulse does not continue to grow indefinitely. If there is any truncation it is on the left end. To capture the impulse I have to set a level that must be exceeded for the collection to start. So there may be more low level data to the left of what is shown, but it has little impact on the result.
 
Well wouldn't this depend on what is causing those phase and amplitude distortions? That page seems fine in theory but in practice I think impulse response correction of amplitude distortions in a room is a little more messy.

I think that you can correct certain predictable and consistent distortions. Phase distortions caused by a crossover filter network are predictable and can be offset but room response isn't as predictable or consistent with complex signals vs test tones.

Maybe if you use anechoic or free field measurements as a basis to offset certain mechanical deficiencies I can see it working to an extent.

This is exactly the approach I take. I measure speakers in as close to a free field environment as I can and correct their phase and amplitude. 'Room correction' is a joke. However with FIR filters perfectly flat phase and frequency response is easily produced.
 
Seems a little odd then. For your implementation to be non-inverting, the final largest peak should be positive, and the output of the system should be delayed by the entire impulse response duration of the correction filter and not appear until 0.25ms after that largest peak.

that makes sense.

i think JohnK is using some kind of a time window that is cutting off the signal.

i think this X correction function will produce a horrendous "echo" that simply isn't making it into the time frame John is is looking at.
 
I think JohnK is using some kind of a time window that is cutting off the signal.

i think this X correction function will produce a horrendous "echo" that simply isn't making it into the time frame John is is looking at.
Well, not really, but John's web page doesn't tell the whole story. A single delayed echo is a nice problem to look at though as it does illustrate some particular issues.

While the amplitude of the echo ("a") is less than 1 the equalising filter has a fairly conventional looking impulse response, consisting of

1 ... -a ... +a^2 ... -a^3 ... +a^4 ...

where the a, a^2 etc are separated by the time delay of the echo with zeroes in the response between them. This response is minimum phase, and for small "a" the coefficients decay very rapidly so the response can be short. As a gets closer to 1 the decay gets much slower so the response needs to be much longer to avoid artefacts from truncating it, but it remains minimum phase.

At a=1 there is a problem, the coefficients are heading towards

1 ... -1 ... 1 ... -1 ... 1 ... -1 ... etc

and the response is no longer invertible.

At a > 1 something interesting happens, the order in which we need to place the coefficients reverses and the response becomes

... +(1/a)^5 ... -(1.a)^4 ... +(1/a)^3 ... -(1/a)^2 ... +1/a

where the truncation happens at the start of the response for a small enough coefficient rather than the end and the coefficients are at negative times. The correction filter is no longer causal, but we can make it causal again by delaying the response to correspond to the length of our correction filter. This may or may not be something we are able to do - if the system is just playing music then the delay may not matter as long as we can delay everything else to match, if it is the soundtrack of a movie we might have a problem with lip sync if the video has no delays in its path. The closer "a" is to 1, the longer we need to delay to have an initial coefficient that is small enough, and the longer the time gap to the echo the longer we need to delay the whole filter output.

If our overall system is such that we can live with the delay, our time axis can just be relocated to tie up with the delayed output and we can say the phase is nicely corrected. If not, we need to include in the phase response the time delay of the correction filter, which means that (relative to the original signal) there will be considerable phase shift.
 
This is exactly the approach I take. I measure speakers in as close to a free field environment as I can and correct their phase and amplitude. 'Room correction' is a joke. However with FIR filters perfectly flat phase and frequency response is easily produced.

I would agree that anechoic or quasi-anechoic measurement for mid to high frequencies with consequent speaker correction is arguably more sensible than full spectrum in situ room correction – it certainly means a fully causal correction filter is possible. However, there is little doubt that room correction of sub 100Hz frequencies is a good thing. And using FIRs to tame those room resonances is much better than the traditional 1/3 octave eq done by many.
 
First of all, as I said before, this is NOT about echo canceling. Borat asked me if a system that had two impulses, with the second impulse greater than the first, could be transformed into a system that has a single impulse using FIR filters. The answer is an unequivocal yes. I think there may be some misunderstanding of the process involved though. Let me post a step by step description of how this was done. There are several ways this could be done, but what I have chosen is to do is along the following lines. (Buy the way, echos never have the second (or any subsequent impulses, greater in amplitude than the first).

First, we all know that a system with flat amplitude and zero phase (or linear phase is nothing but a pure time delay. It has perfect impulse response. So the question is can the double impulse system be reduced to a system with flat amplitude and linear phase?

I don't think anyone would question that the system can be equalized flat.

So we start with the double impulse system with impulse, d(t), that looks like

An externally hosted image should be here but it was not working when we last tested it.



Then we introduce the equalization. In this case the eq has an impulse, eq(t), that looks like

An externally hosted image should be here but it was not working when we last tested it.


Convolving eq(t)*d(t) = f(t) yields a system with flat amplitude response and an impulse, f(t) that looks like

An externally hosted image should be here but it was not working when we last tested it.

Note than none of these impulses has any exponential growth in its components. They all decay exponentially in time. It is required to window the impulse, as is the case with any digital filter. The length of the kernel will determine the accuracy of the filter. However, the convolution is actually done in the frequency domain. Thus, the length of the impulse will typically be on the order of at least 50 msec if a 20 Hz cut off is needed. The plots above go out to 9 msec and what you see past a few msec is pretty much noise in the FFt. The initial decay of the spikes is indicative of the rate of decay.

Now, it is simple mathematics that tells us that if h(t) is the impulse of a system of length T, then convolving h(t)*h(T-t) yields a system with zero (linear) phase but with amplitude H'(f) = [H(f)]^2. Obviously, if H(f) = 1.0 (flat response) then H^2 = 1 as well. So in this case the preprocessor has an impulse of

p(t)=eq(t)*f(T-t) = eq(t) * eq(T-t) * d(T-t)

or, when convolved with the original system impulse, d(t) we have

o(t) = d(t) * eq(t) * eq(T-t) * d(T-t). = [d(t) *d(T-t)] * [eq(t)*eq(T-t)]

The first two terms linearize the phase of the original system while the second two apply linear phase eq to flatten the response The result is, o(t) looks like

An externally hosted image should be here but it was not working when we last tested it.



True echo cancellation requires dealing with the true impulse response for the echo over a length of time long enough that the echo decays to an inaudible level. And echos don't have secondary reflections with greater amplitude than the direct sound. If they did, the system would be unstable, growing exponentially in time without additional energy input. You may recall that the laws of thermodynamics prohibit that. If you figure out how to do it you will get a Nobel prize in physics and solve the worlds energy problems once and for all. But echo cancellation is a bigger problem because whatever you do will work only at the point in space where the echo impulse is measured.
 
Last edited:
Seems a little odd then. For your implementation to be non-inverting, the final largest peak should be positive, and the output of the system should be delayed by the entire impulse response duration of the correction filter and not appear until 0.25ms after that largest peak.

It's the acquisition system that inverted the pulse. I didn't correct the polarity. Sorry. And you are correct about the delay, but as I think I noted, to capture the impulse I have to set a level to trigger the acquisition. So that effects the length of the impulse that is actually recorded.
 
John, I assume your post is directed at least in part at me. I'm not sure why the word "echo" is so unpalatable, the second peak in the "double peak" impulse results in a delayed copy of the signal fed in being added to the original signal. "Echo" seems a pretty reasonable word to use to describe a delayed copy of something, but if there's a term that would better describe it that's fine, the word used doesn't have any bearing on the maths :)

As for the piece about "echos don't have secondary reflections with greater amplitude than the direct sound" and violating the principle of conservation of energy, that seems to be drifting off topic somewhat. It is not difficult for delayed contributions to have higher level than the direct sound, some of the more common in acoustics include more than one path to the measurement point with the same delay or a path that concentrates the energy, such as a concave wall. If we needed new laws of physics to have mixed phase systems I don't suppose this thread would exist.

You omitted the plot of the preprocessor, which on your web page is x(t), yes? That impulse response shows the geometrically increasing coefficient values when the amplitude of the delayed contribution is greater than the original.

A more straightforward way to generate the inverse filter is FFT the "double impulse", do an element-wise reciprocal of the result, then inverse FFT. The result is the impulse response of the preprocessor. When the amplitude of the delayed contribution is less than the original this gives us the geometrically decaying coefficient values I posted above, when the delayed contribution is greater the coefficients increase geometrically and the filter has a delay corresponding to its total length. If we ignore that delay the overall result has linear phase but when it is included we of course do not. Whether it can be ignored depends on the wider context within which the system is operating.

Finally, I'm not sure what I may have posted that has implied some personal attack or criticism, which I'm assuming (perhaps wrongly) may be the case from the tone of your reply. None was intended. I am simply commenting on the properties of a system with (for want of a better word) an echo and the consequences of the level of that echo. It is an instructive system to consider, and probably the simplest that can demonstrate how little need change to move a system away from being minimum phase.
 
John, I assume your post is directed at least in part at me. I'm not sure why the word "echo" is so unpalatable, the second peak in the "double peak" impulse results in a delayed copy of the signal fed in being added to the original signal. "Echo" seems a pretty reasonable word to use to describe a delayed copy of something, but if there's a term that would better describe it that's fine, the word used doesn't have any bearing on the maths :)

As for the piece about "echos don't have secondary reflections with greater amplitude than the direct sound" and violating the principle of conservation of energy, that seems to be drifting off topic somewhat. It is not difficult for delayed contributions to have higher level than the direct sound, some of the more common in acoustics include more than one path to the measurement point with the same delay or a path that concentrates the energy, such as a concave wall. If we needed new laws of physics to have mixed phase systems I don't suppose this thread would exist.

You omitted the plot of the preprocessor, which on your web page is x(t), yes? That impulse response shows the geometrically increasing coefficient values when the amplitude of the delayed contribution is greater than the original.

A more straightforward way to generate the inverse filter is FT the "double impulse", do an element-wise reciprocal of the result, then inverse FT. The result is the impulse response of the preprocessor. When the amplitude of the delayed contribution is less than the original this gives us the geometrically decaying coefficient values I posted above, when the delayed contribution is greater the coefficients increase geometrically and the filter has a delay corresponding to its total length. If we ignore that delay the overall result has linear phase but when it is included we of course do not. Whether it can be ignored depends on the wider context within which the system is operating.

Finally, I'm not sure what I may have posted that has implied some personal attack or criticism, which I'm assuming (perhaps wrongly) may be the case from the tone of your reply. None was intended. I am simply commenting on the properties of a system with (for want of a better word) an echo and the consequences of the level of that echo. It is an instructive system to consider, and probably the simplest that can demonstrate how little need change to move a system away from being minimum phase.


John, first, nothing personal here. It's just discussion. Second, I think my objection to the term echo is more how I interpret it than anything. When I read echo I think multiple reflections with differing time delays. Third, yes, if multiple reflections arrive at the observation point at the same time, then there is a possibility that the sum of those reflections can be greater than the direct sound. Is that a single echo or coincident arrival of several echoes? :)

Going back and reading you post more closely I don't have any objections to what you are saying. You are just saying it in different light. I think I was mixing the content of some of the earlier posts from other with yours.

In any event, the double impulse system can be corrected, if the delay is acceptable. The correction is easy to work out in the frequency domain, since it is just division and multiplication rather than convolution, and since convolution for FIR filters is typically done in the frequency domain it is actually quite straight forward. The details aren't of issue here, just can it be done or not. The answer is still, it can be done, and rather simply.
 
hm. i thought i already replied here, but apparently not.

thank you both i see how it works now. the "echo" is now the original signal while the original signal is now padded into the ground.

didn't understand your math though JohnK but it's ok. the point i guess is that the process can be automated.

thanks again everybody.
 
Status
This old topic is closed. If you want to reopen this topic, contact a moderator using the "Report Post" button.