[ has background related to [NEWBIE question] How do I filter a digitized signal ] I have a real [only] input {voice in .WAV format) I do a Scilab fft on it. I multiply the resulting frequency domain by a "filter function" *CASE 1* Value of filter is either 1 or zero depending on frequency The filter will have same value over intervals of at least 1/12 octave There will be multiple intervals *CASE 2* Value of filter will be an arbitrary {probably continuous} value between 0 and 1 as a function of frequency I will do an IFFT to produce signal for further processing. I have *NO REASON* for to assume resulting signal to be human intelligle. What should I watch out for? I have a reason to *SUSPECT* that I will want "group delay" thru this 'filter' to be constant vs frequency.

# How much trouble can a NEWBIE get into doing SIMPLISTIC filter in frequency domain

Started by ●August 19, 2004

Reply by ●August 19, 20042004-08-19

"Richard Owlett" <rowlett@atlascomm.net> wrote in message news:10ia1sa5l6f7j20@corp.supernews.com...> [ has background related to > [NEWBIE question] How do I filter a digitized signal > ] > > I have a real [only] input {voice in .WAV format) > I do a Scilab fft on it. > > I multiply the resulting frequency domain by a "filter function" > > *CASE 1* > Value of filter is either 1 or zero depending on frequency > The filter will have same value over intervals of at least 1/12 octave > There will be multiple intervals > > *CASE 2* > Value of filter will be an arbitrary {probably continuous} value > between 0 and 1 as a function of frequency > > I will do an IFFT to produce signal for further processing. > I have *NO REASON* for to assume resulting signal to be human intelligle. > > What should I watch out for? > I have a reason to *SUSPECT* that I will want "group delay" thru this > 'filter' to be constant vs frequency.Hello Richard, I am a newbie too but I know what you have to watch out for. I prefer quoting "Elements of Computer Music" by Moore. "It might be tempting to try to produce a "perfect" notch filter, for example, by simply setting X(k) to zero for a particular frequency. unfortunaterly, the inverse spectrum of a function that is equal to one everywhere except for a single point where it is equal to zero is in many ways very similar to that of a pulse function. Because the pulse function is very narrow, its trasform is very wide. If we convolve a waveform with a wide function, we learn the reason why the convolution is often referred to as the "smearing" operation. Because each sample of the input waveform would be "smeared" over all samples of the output, we see that the result is aliasing in time, which is in every way equivalent to aliasing in frequency." You can apply this to your problem, and understand why the output of the filter is not intelligible. Alessandro

Reply by ●August 20, 20042004-08-20

Ale S wrote:> "Richard Owlett" <rowlett@atlascomm.net> wrote in message > news:10ia1sa5l6f7j20@corp.supernews.com... > >[snip] >> >>I multiply the resulting frequency domain by a "filter function" >> >>*CASE 1* >>Value of filter is either 1 or zero depending on frequency >>The filter will have same value over intervals of at least 1/12 octave >>There will be multiple intervals >> >>[snip] > > > Hello Richard, > I am a newbie too but I know what you have to watch out for. I prefer > quoting "Elements of Computer Music" by Moore. > > "It might be tempting to try to produce a "perfect" notch filter, for > example, by simply setting X(k) to zero for a particular frequency. > unfortunaterly, the inverse spectrum of a function that is equal to one > everywhere except for a single point where it is equal to zero is in many > ways very similar to that of a pulse function. Because the pulse function is > very narrow, its trasform is very wide. If we convolve a waveform with a > wide function, we learn the reason why the convolution is often referred to > as the "smearing" operation. Because each sample of the input waveform would > be "smeared" over all samples of the output, we see that the result is > aliasing in time, which is in every way equivalent to aliasing in > frequency." > > You can apply this to your problem, and understand why the output of the > filter is not intelligible. > > Alessandro > >In other words I need to apply a window function just as I should if starting in time domain and going to frequency domain. Sometimes I miss the obvious.

Reply by ●August 20, 20042004-08-20

"Richard Owlett" <rowlett@atlascomm.net> wrote in message news:10ibrsqlqu87q1d@corp.supernews.com...> In other words I need to apply a window function just as I should if > starting in > time domain and going to frequency domain. > > Sometimes I miss the obvious.I didn't speak about window functions. I see you are doin' a sort of equalizer. So you have to cascade several filters. Look for further documentation about FIR and IIR filters on dsp books or sites, or in the comp.dsp archive. In my first experiments I'm doin' all the filtering work in the time domain using convolution, so I don't have to do FFT --> filtering work --> IFFT . Hope this helps, Alessandro

Reply by ●August 20, 20042004-08-20

Richard Owlett <rowlett@atlascomm.net> wrote in message news:<10ia1sa5l6f7j20@corp.supernews.com>...> [ has background related to > [NEWBIE question] How do I filter a digitized signal > ] > > I have a real [only] input {voice in .WAV format) > I do a Scilab fft on it. > > I multiply the resulting frequency domain by a "filter function" > > *CASE 1* > Value of filter is either 1 or zero depending on frequency > The filter will have same value over intervals of at least 1/12 octave > There will be multiple intervals > > *CASE 2* > Value of filter will be an arbitrary {probably continuous} value > between 0 and 1 as a function of frequency > > I will do an IFFT to produce signal for further processing. > I have *NO REASON* for to assume resulting signal to be human intelligle. > > What should I watch out for?Lots of things. First, there is the transition band issue. If you use a "boxcar filter" with H(w) = 1 in the pass band and H(w) = 0 in the stop band, with no "don't care" band in between, you will see severe ringing in time domain, basically a h(t) = sin(t)/t type of response. Generally speaking, a wider pass-band in the filter gives a shorter impulse response, and a wider "don't care" region gives less ringing. So the art here lies in getting a filter that does an interesting job (i.e. filters the signal) without introducing too many artefacts in time domain. Second, you need to allow for transition effects. The input data x(t) must be padded with "sufficiently many" zeros (yep, that's another of those art things), to allow for end effects without time-domain wrap-around. Third, you must (well, ought to) achieve the above and yet have the filter stay causal, i.e. that no response is seen on the output at a time sample before the first input sample has been fed into the system. Rick's book contains 22 pages about various ways to design FIR filters. Were it not for the questions above, the recipe wouldn't need much more than 22 lines.> I have a reason to *SUSPECT* that I will want "group delay" thru this > 'filter' to be constant vs frequency.Well, you certainly would like it to be a positive group delay at all frequencies. Which is a complicated way to say that the system should be causal. A FIR filter with constant group delay is one with "linear phase". Again, Rick has the recipe. Rune

Reply by ●August 20, 20042004-08-20

Ale S wrote:> "Richard Owlett" <rowlett@atlascomm.net> wrote in message > news:10ibrsqlqu87q1d@corp.supernews.com... > > >>In other words I need to apply a window function just as I should if >>starting in >>time domain and going to frequency domain. >> >>Sometimes I miss the obvious. > > > I didn't speak about window functions.Actually I think the author you quoted was ..sort of... Rick, Jerry, Rune Please jump in before Alessandro and I confuse each other, or at least me ;}> I see you are doin' a sort of > equalizer. So you have to cascade several filters. Look for further > documentation about FIR and IIR filters on dsp books or sites, or in the > comp.dsp archive. In my first experiments I'm doin' all the filtering work > in the time domain using convolution, so I don't have to do FFT --> > filtering work --> IFFT .I'm working in frequency domain for same reason you are in time domain -- it's simpler for our specific problems. My desired filter shape is not analytic and is only piecewise continuous. I'm beginning to think I should look at making the derivatives also piecewise continuous.> Hope this helps, > Alessandro > >

Reply by ●August 20, 20042004-08-20

Rune Allnor wrote:> Richard Owlett <rowlett@atlascomm.net> wrote in message news:<10ia1sa5l6f7j20@corp.supernews.com>... > >>[ has background related to >> [NEWBIE question] How do I filter a digitized signal >>] >> >>I have a real [only] input {voice in .WAV format) >>I do a Scilab fft on it. >> >>I multiply the resulting frequency domain by a "filter function" >> >>*CASE 1* >>Value of filter is either 1 or zero depending on frequency >>The filter will have same value over intervals of at least 1/12 octave >>There will be multiple intervals >> >>*CASE 2* >>Value of filter will be an arbitrary {probably continuous} value >>between 0 and 1 as a function of frequency >> >>I will do an IFFT to produce signal for further processing. >>I have *NO REASON* for to assume resulting signal to be human intelligle. >> >>What should I watch out for? > > > Lots of things. > > First, there is the transition band issue. If you use a "boxcar filter" > with H(w) = 1 in the pass band and H(w) = 0 in the stop band, with no > "don't care" band in between, you will see severe ringing in time domain, > basically a h(t) = sin(t)/t type of response. Generally speaking, a > wider pass-band in the filter gives a shorter impulse response, and a > wider "don't care" region gives less ringing. So the art here lies > in getting a filter that does an interesting job (i.e. filters the signal) > without introducing too many artefacts in time domain. > > Second, you need to allow for transition effects. The input data x(t) > must be padded with "sufficiently many" zeros (yep, that's another > of those art things), to allow for end effects without time-domain > wrap-around. > > Third, you must (well, ought to) achieve the above and yet have the > filter stay causal, i.e. that no response is seen on the output at a > time sample before the first input sample has been fed into the system. > Rick's book contains 22 pages about various ways to design FIR filters. > Were it not for the questions above, the recipe wouldn't need much more > than 22 lines. > > >>I have a reason to *SUSPECT* that I will want "group delay" thru this >>'filter' to be constant vs frequency. > > > Well, you certainly would like it to be a positive group delay at all > frequencies. Which is a complicated way to say that the system should be > causal. A FIR filter with constant group delay is one with "linear phase". > Again, Rick has the recipe. > > RuneActually what started some of my thought trains was Rick's book. [ he think I've become "derailed" ;] Part of the problem is I see no way of describing my desired filter shape analytically. Also I just don't think mathmaticaly so I bounce between math, geometry, and experiment(Scilab as a lab bench/tinker toy set).

Reply by ●August 21, 20042004-08-21

On Fri, 20 Aug 2004 10:03:53 -0500, Richard Owlett <rowlett@atlascomm.net> wrote:>Ale S wrote: > >> "Richard Owlett" <rowlett@atlascomm.net> wrote in message >> news:10ibrsqlqu87q1d@corp.supernews.com... >> >> >>>In other words I need to apply a window function just as I should if >>>starting in >>>time domain and going to frequency domain. >>> >>>Sometimes I miss the obvious. >> >> >> I didn't speak about window functions. > >Actually I think the author you quoted was ..sort of... > >Rick, Jerry, Rune >Please jump in before Alessandro and I confuse each other, or at least >me ;}Hi, Ale's quote from "Elements of Computer Music" by Moore makes good sense to me. When we try to represent a sequence (time or freq-domain) with an abrupt transition, like this: *********** Sequence 1 | | | ************ the Fourier transform (either forward or inverse) of Sequence 1 will be "smeared" out. That is, the Fourier transform will extended in length and have oscillations. In the time domain we call those oscillations "ripples". In the freq domain we call those oscillations "sidelobes". If we change our original sequence so that it has a single "transition region" sample, like this: *********** Sequence 2 \ * \ ************ the Fourier transform (either forward or inverse) of Sequence 2 will will have greatly-reduced oscillations compared with the Fourier transform of Sequence 1. If we create a sequence that has two "transition region" samples, like this: *********** Sequence 3 \ * \ * \ ************ the Fourier transform (either forward or inverse) of Sequence 3 will have greatly-reduced oscillations compared with the Fourier transform of Sequence 2. And so on. The price we pay for reducing the oscillations in the other domain is that we must sacrifice the sharpness of the sequence's transition in the domain in which we working. I'll bet you guys knew all of that, but the real "butt kicker" is this: The amount of "other" domain ripple (sidelobe) amplitude reduction depends on width of the high-level portion of the sequence *and* the value of the transition coefficient(s). There is no equation that tells us what the value should be for the "transition region" coefficient in Sequence 2 to obtain absolute-minimum ripple (sidelobes) in the other domain. So you have to experiment with different values (between the high level and the low level) for "transition region" coefficient in Sequence 2 to see which value give you the minimum ripple (sidelobes) amplitude in the other domain. The same story goes for the two "transition region" coefficients in Sequence 3. To determine what the values for the two coefficients should be in order to obtain absolute-minimum ripple (sidelobes) in the other domain, you have to try all possible combinations for the two coefficients!! I did my best to cover this topic in Section 7.1.9, "Improving Performance with Transition Band Coefficients" in the 2nd edition of my book. Anyway, hope that helps a little. Gotta run. See Ya', [-Rick-]

Reply by ●August 22, 20042004-08-22

Richard Owlett <rowlett@atlascomm.net> wrote in message news:<10ic6jv7gqv9tba@corp.supernews.com>...> Part of the problem is I see no way of describing my desired filter > shape analytically. Also I just don't think mathmaticaly so I bounce > between math, geometry, and experiment(Scilab as a lab bench/tinker > toy set).There is one useful way of drawing up the desired filter response graphically. You find it in Rick's figure 5-30. All you need to specify a FIR filter is in that figure: Bandwidth of pass-band, allowed ripple in passband, transition band, bandwith of stop-band, and attenuation in stop-band. Once you have come up with a spec like that, you can plug the numbers into the machinery of FIR filter design, be it the Remez algorithm, or the formulas for "window FIR filters". Rune