Forums

"Correcting" output of a filter

Started by Ross April 26, 2010
"Correcting" is not going to be the right word, but here's my problem.

I would like to have a brick wall filter with no phase delay and
moderate computational complexity. (Yes, I know, who wouldn't).

I'm actually using Butterworth lowpass filters of order 4 as designed
by Tony Fisher's web page.

Imagine I create a 4 pole LPF, with a corner frequency of 31Hz with a
sampling rate of 44.1Khz. The filter gain is very high. On the order
of 4.77e10 or something like that.

I've created a sample signal to feed into this. It has 30 samples of
silence, followed by a 20 Hz (non-bandlimited) sawtooth wave for 44100
samples.

If I filter this signal and then graph the result, it takes some time
for the filter to "get going". The first cycle has a
"concave" (looking from left to right) start from zero and climb to
first peak, rather than the slightly convex more sine-like rises later
on. Also, the height of the first peak is lower than other ones.

Are there any techniques or research on how to "correct" early output
from a filter after there has been a sudden change from (relative)
silence to signal? I will not be using the output of the filter in any
audio that is actually listenened to. I will only be tracking the zero
crossings and peaks of the waveform. However, I need to have an
estimate early on of the peak value of the waveform passing through.
Tricky given that the filter takes some time to "get going" (AKA the
filter isn't a brick wall filter).

Any hints?
On 26 apr, 12:20, Ross <rossclem...@gmail.com> wrote:
> "Correcting" is not going to be the right word, but here's my problem. > > I would like to have a brick wall filter with no phase delay and > moderate computational complexity. (Yes, I know, who wouldn't).
...so you don't know much 'bout filters, do you?
> Are there any techniques or research on how to "correct" early output > from a filter after there has been a sudden change from (relative) > silence to signal?
The initial transient is a fact of life. Rune
On Apr 26, 12:30 pm, Rune Allnor <all...@tele.ntnu.no> wrote:
> On 26 apr, 12:20, Ross <rossclem...@gmail.com> wrote: > > > "Correcting" is not going to be the right word, but here's my problem. > > > I would like to have a brick wall filter with no phase delay and > > moderate computational complexity. (Yes, I know, who wouldn't). > > ...so you don't know much 'bout filters, do you?
Can you please explain what you mean by this? I know that there are no brick wall filters and I believe my message made it clear that I wasn't expecting to be able to completely repair the signal from my significantly not "brick wall" filter to make it a higher performing *all purpose* filter. My comment about wanting a brick wall filter without significant delay nor excessive computational requirements was a tongue in check comment intended to be read as "ideally what I'd like is this, but since I know I won't get it, ....."
> > Are there any techniques or research on how to "correct" early output > > from a filter after there has been a sudden change from (relative) > > silence to signal? > > The initial transient is a fact of life.
Please note that I'm not expecting to produce, by compensating for it, a brick wall filter. I'm looking at a situation where I intend to track the frequency and magnitude of the output from the filter based on the assumption that it's a reasonable approximation to a sine wave. If the output was an idea sine wave, which it won't be given that the filter is not ideal nor will the input signal be idea, then with a few samples I could fit a sinewave to the input with three samples or so. Since my input is not ideal, I'll only be able to constrain the frequency within a probability distribution. After a few cycles of input, I'll be able to constrain the frequency between upper and lower bounds which will be amply accurate for my needs. But, when the input signal goes from 0 to signal, partially due to the initial transient of the filter, I expect that simple methods will give me too wide a probability distribution for frequencies. I can apply a number of "AI" style techniques on the unmodified output of the filter which may (experiments not yet done) improve the accuracy of the prediction early on. However, it would be silly to reinvent wheels should there be research that characterises the nature of the initial transients from filters such that their effect on dynamic signals is well understood and can be predicted for non-trivial input signals. Is this clearer?
On Mon, 26 Apr 2010 03:20:54 -0700 (PDT), Ross <rossclement@gmail.com> wrote:

>Are there any techniques or research on how to "correct" early output >from a filter after there has been a sudden change from (relative) >silence to signal?
Ah, the perils of designing in the frequency domain. It's so much easier to get that frequency response "just right" when you don't have to worry about the time domain. Consider that frequency response is a steady-state concept. That is to say, when you specify the response of a filter at a certain frequency, you tacitly assume that a signal of constant amplitude at that frequency was applied an infinitely long time ago, and will continue for an infinite time to come. But we live in the time domain. Signals start, stop, and change. Those starts, stops, and changes trigger time-domain responses from filters. And the time-domain responses can be very unattractive when the filters are designed in the frequency domain. It is a fundamental give-and-take; to optimize something in the frequency domain almost always means to "un-optimize" something else in the time domain, and vice-versa. So the answer to your question on how to "correct" the filter is to design the filter for better time domain response in the first place. And, of course, that means giving up something in the frequency domain. Greg
On 4/26/2010 9:36 AM, Ross wrote:
> On Apr 26, 12:30 pm, Rune Allnor<all...@tele.ntnu.no> wrote: >> On 26 apr, 12:20, Ross<rossclem...@gmail.com> wrote: >> >>> "Correcting" is not going to be the right word, but here's my problem. >> >>> I would like to have a brick wall filter with no phase delay and >>> moderate computational complexity. (Yes, I know, who wouldn't). >> >> ...so you don't know much 'bout filters, do you? > > Can you please explain what you mean by this? I know that there are no > brick wall filters and I believe my message made it clear that I > wasn't expecting to be able to completely repair the signal from my > significantly not "brick wall" filter to make it a higher performing > *all purpose* filter. My comment about wanting a brick wall filter > without significant delay nor excessive computational requirements was > a tongue in check comment intended to be read as "ideally what I'd > like is this, but since I know I won't get it, ....." > >>> Are there any techniques or research on how to "correct" early output >>> from a filter after there has been a sudden change from (relative) >>> silence to signal? >> >> The initial transient is a fact of life. > > Please note that I'm not expecting to produce, by compensating for it, > a brick wall filter. I'm looking at a situation where I intend to > track the frequency and magnitude of the output from the filter based > on the assumption that it's a reasonable approximation to a sine wave. > > If the output was an idea sine wave, which it won't be given that the > filter is not ideal nor will the input signal be idea, then with a few > samples I could fit a sinewave to the input with three samples or so. > Since my input is not ideal, I'll only be able to constrain the > frequency within a probability distribution. After a few cycles of > input, I'll be able to constrain the frequency between upper and lower > bounds which will be amply accurate for my needs. But, when the input > signal goes from 0 to signal, partially due to the initial transient > of the filter, I expect that simple methods will give me too wide a > probability distribution for frequencies. I can apply a number of "AI" > style techniques on the unmodified output of the filter which may > (experiments not yet done) improve the accuracy of the prediction > early on. However, it would be silly to reinvent wheels should there > be research that characterises the nature of the initial transients > from filters such that their effect on dynamic signals is well > understood and can be predicted for non-trivial input signals. > > Is this clearer?
What is clear is that you don't understand the problem. I'll try to explain. Whether digital or analog, every filter has memory elements. (I assume that you can identify them in your particular filter. If not, ask.) Until the contents of those memory elements settle to a repeating cycle of values determined by a repetitive input, the output of the filter will deviate from the naively expected. If you know enough about the input signal to preload the memory elements (set the initial conditions, as the math people say) you don't really need a filter. The output of an IIR filter depends on a large number of the input samples. The "expected" output assumes an infinite number of them. You have another problem. Your signal isn't bandlimited, so many of its higher components alias into the passband. That changes what you expect (or should expect) your output to be. Jerry -- "I view the progress of science as ... the slow erosion of the tendency to dichotomize." --Barbara Smuts, U. Mich. &#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;
On 4/26/2010 9:37 AM, Greg Berchin wrote:

   ...

> Ah, the perils of designing in the frequency domain. It's so much easier to get > that frequency response "just right" when you don't have to worry about the time > domain. > > Consider that frequency response is a steady-state concept. That is to say, > when you specify the response of a filter at a certain frequency, you tacitly > assume that a signal of constant amplitude at that frequency was applied an > infinitely long time ago, and will continue for an infinite time to come. > > But we live in the time domain. Signals start, stop, and change. Those starts, > stops, and changes trigger time-domain responses from filters. And the > time-domain responses can be very unattractive when the filters are designed in > the frequency domain. It is a fundamental give-and-take; to optimize something > in the frequency domain almost always means to "un-optimize" something else in > the time domain, and vice-versa. > > So the answer to your question on how to "correct" the filter is to design the > filter for better time domain response in the first place. And, of course, that > means giving up something in the frequency domain.
What a wonderfully concise way to emphasize a simple truth! Those paragraphs should be in the preface to every writing on filter design. Jerry -- "I view the progress of science as ... the slow erosion of the tendency to dichotomize." --Barbara Smuts, U. Mich. &#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;

Ross wrote:

> "Correcting" is not going to be the right word, but here's my problem.
Could you tell what is the real problem. I.e. what are you trying to accomplish as the final result.
> I would like to have a brick wall filter with no phase delay and > moderate computational complexity. (Yes, I know, who wouldn't).
There is no free cheese. A linear filter with a bandwidth B will have a delay no less then about 1/B.
> Are there any techniques or research on how to "correct" early output > from a filter after there has been a sudden change from (relative) > silence to signal?
Yes, there are. If you have a particular model of the signal, and a particular goal to accomplish, you can make a nonlinear adaptive filter.
> I will not be using the output of the filter in any > audio that is actually listenened to.
If this is about audio, why can't you delay the rest of the signal by the same amount as the delay in the filter?
> I will only be tracking the zero > crossings and peaks of the waveform.
What is the goal of this? Vladimir Vassilevsky DSP and Mixed Signal Design Consultant http://www.abvolt.com
On 26 apr, 15:36, Ross <rossclem...@gmail.com> wrote:
> On Apr 26, 12:30 pm, Rune Allnor <all...@tele.ntnu.no> wrote: > > > On 26 apr, 12:20, Ross <rossclem...@gmail.com> wrote: > > > > "Correcting" is not going to be the right word, but here's my problem. > > > > I would like to have a brick wall filter with no phase delay and > > > moderate computational complexity. (Yes, I know, who wouldn't). > > > ...so you don't know much 'bout filters, do you? > > Can you please explain what you mean by this?
To establish a baseline from which to start. Somebody who knows the basics of filter design would never mention the ideal filter in a design setting.
> I know that there are no > brick wall filters and I believe my message made it clear that I > wasn't expecting to be able to completely repair the signal
...and right there you revealed your ignorance again. There is nothing to repair, as the effect you see is impossible to avoid. The best one can do is control it.
> from my > significantly not "brick wall" filter to make it a higher performing > *all purpose* filter.
There is no such thing as an 'all purpose' filter.
> My comment about wanting a brick wall filter > without significant delay nor excessive computational requirements was > a tongue in check comment intended to be read as "ideally what I'd > like is this, but since I know I won't get it, ....."
Yet again you reveal a total ignorance about the subject. ...
> Is this clearer?
What is clear is that you have no idea what a filter is, how it works, or how to design one. Why not describe what you attempt to achieve with your filter. Rune

Rune Allnor wrote:


> Why not describe what you attempt to achieve > with your filter.
Hm, it is interesting to guess. The OP is obviously not a pro although he tries to accomplish some kind of sub audio signaling; so it should be something very common. My first guess would be amateurish EEG or ECG. Vladimir Vassilevsky DSP and Mixed Signal Design Consultant http://www.abvolt.com

Ross wrote:

> Are there any techniques or research on how to "correct" early output > from a filter after there has been a sudden change from (relative) > silence to signal? I will not be using the output of the filter in any > audio that is actually listenened to. I will only be tracking the zero > crossings and peaks of the waveform. However, I need to have an > estimate early on of the peak value of the waveform passing through. > Tricky given that the filter takes some time to "get going" (AKA the > filter isn't a brick wall filter).
Sounds like not using a filter would instantly solve all the problems. Is there a reason why you haven't tried that? -jim