From: Rune Allnor on

Ron N. skrev:
> Rune Allnor wrote:

> > It's been a couple of years since I looked at RBJ's cookbook,
> > so I won't criticize it too much. But once you start adding details
> > like that, you pretty soon end up with a full-scale filter design
> > paper.
> >
> > The "simple" Cheb 1 IIR HP filter:
> >
> > - Select a passband corner frequency
> > - Select a stopband corner frequency
> > - Select passband ripple
> > - Select stopband attenuation
> > - Convert to LP prototype
> > - Pre-warp to analog domain
> > - Compute filter order
> > - Compute biquad parameters
> > - BLT back to discrete-time domain
> > - Apply a frequency transform to get the final parameters
> >
> > Even for an as "simple, standard" filter as the Cheb 1, this
> > is alrady a step or two beyond what I would say is "cookbook
> > level".
>
> That's more knobs than someone using a simple cookbook
> recipe, as opposed to creating a new entree from scratch,
> might want or need to have available to turn.

No, it is not. This is what it takes to make a Cheb 1 filter.
The Butterworth, Cheb 2 and elliptic filters are just the same,
only with slightly different formulas used in the various steps.

Of course, this raises the question what a "cookbook" is.
I have assumed it to be a list of steps necessary to achieve
a goal, a guideline for the structure of a computer program,
not a computer code ready to compile.

Rune

From: Rune Allnor on

Fred Marshall skrev:
> "Rune Allnor" <allnor(a)tele.ntnu.no> wrote in message
> news:1165535244.696120.130260(a)79g2000cws.googlegroups.com...
> >
> > Fred Marshall skrev:
> >
> >> On the other hand, a program much like P-M could be made available as a
> >> function call that would take arbitrary shapes and weights.
> >
> > You may be right, from a purely technical point of view. However, a
> > function like P-M has lots of control factors, desired responses, error
> >
> > weight factors etc, which makes it hard to use.
> >
> > It's been a few months since I read up on P-M now, so I don't
> > remember the exact details. The reason why the Remez exchange
> > can be used for optimization is that some cos(n*cos(x)) terms
> > appear in the expressions to be optimized. If it turns out that one
> > of those cosines are the basis finctions for the filters, optimizing
> > the filters for other types of functions excludes the Remez algorithm.
> > In that case, some other optimization method must be used,
> > which may or may not be hard.
> >
> >> My question
> >> was: is this to the point and useful? The notion wasn't that a beginner
> >> should do the programming - just make the function calls.
> >
> > I don't think so. I think such a function would be very hard to learn
> > wot to use and to control. I think it would require more time for
> > preparations than most DIY'ers could reasonably be expected to
> > spend.
>
> ............................................>
>
> > Rune
>
> Well, I guess it depends on what you call "hard to learn". We're already
> talking in the context of a function call so that assumes some sort of
> programming.

I interpreted your previous posts literally, to have some
function that can be called from computer code and
where the results are handeled by the computer. A GUI
is a different kind of interface where the user has more
direct feedback for his decisions. To me, the function and
the GUI are two different things, since the function does
not allow the user to see what the filter looks like.

> Or, it could be simpler than that if one would simply re-write
> the P-M style of interface (and the underlying program) to say:
>
> Give the length of filter desired.
> Give the number of points in the desired frequency response on a regular
> grid.
> Give the desired frequency response values on that grid.

So far so good...

> Give the weighting function on that grid.

Are you able to write a short, comprehenable description of
what a "weighting function" is? Along with a guideline on how
to set up one and evaluate whether the results conforms to
the spec? Remember, you are writing for the non-specialist
John Doe, DIY.

> Results:
> The filter coefficients.

Sure

> The weight-normalized ripple.

Again, someone with possibly more interest than skills
is supposed to handle such results, and evaluate them.
I am not sure it is very easy to write a short guideline
about how to use these things, that a DIY'er will be
able to use. Write too long, and the DIY'er will not
even read it.

> A filter response plot or listing perhaps
> etc.
>
> I don't think this would be hard to learn how to use effectively.

Maybe not, if we were talking about trained engineers.
We are, however, talking about something for DIY'ers
to use. A completely different type of user.

> All that said, I don't think one should use something like this as a "black
> box" in an automated system unless the requirements are constrained -
> because one *can* generate some weird filter responses.

Exactly.

Rune

From: Fred Marshall on

"Rune Allnor" <allnor(a)tele.ntnu.no> wrote in message
news:1165581274.388415.94110(a)79g2000cws.googlegroups.com...
>
> Fred Marshall skrev:
>> "Rune Allnor" <allnor(a)tele.ntnu.no> wrote in message
>> news:1165535244.696120.130260(a)79g2000cws.googlegroups.com...
>> >
>> > Fred Marshall skrev:
>> >
>> >> On the other hand, a program much like P-M could be made available as
>> >> a
>> >> function call that would take arbitrary shapes and weights.
>> >
>> > You may be right, from a purely technical point of view. However, a
>> > function like P-M has lots of control factors, desired responses, error
>> >
>> > weight factors etc, which makes it hard to use.
>> >
>> > It's been a few months since I read up on P-M now, so I don't
>> > remember the exact details. The reason why the Remez exchange
>> > can be used for optimization is that some cos(n*cos(x)) terms
>> > appear in the expressions to be optimized. If it turns out that one
>> > of those cosines are the basis finctions for the filters, optimizing
>> > the filters for other types of functions excludes the Remez algorithm.
>> > In that case, some other optimization method must be used,
>> > which may or may not be hard.
>> >
>> >> My question
>> >> was: is this to the point and useful? The notion wasn't that a
>> >> beginner
>> >> should do the programming - just make the function calls.
>> >
>> > I don't think so. I think such a function would be very hard to learn
>> > wot to use and to control. I think it would require more time for
>> > preparations than most DIY'ers could reasonably be expected to
>> > spend.
>>
>> ............................................>
>>
>> > Rune
>>
>> Well, I guess it depends on what you call "hard to learn". We're already
>> talking in the context of a function call so that assumes some sort of
>> programming.
>
> I interpreted your previous posts literally, to have some
> function that can be called from computer code and
> where the results are handeled by the computer. A GUI
> is a different kind of interface where the user has more
> direct feedback for his decisions. To me, the function and
> the GUI are two different things, since the function does
> not allow the user to see what the filter looks like.
>
>> Or, it could be simpler than that if one would simply re-write
>> the P-M style of interface (and the underlying program) to say:
>>
>> Give the length of filter desired.
>> Give the number of points in the desired frequency response on a regular
>> grid.
>> Give the desired frequency response values on that grid.
>
> So far so good...
>
>> Give the weighting function on that grid.
>
> Are you able to write a short, comprehenable description of
> what a "weighting function" is? Along with a guideline on how
> to set up one and evaluate whether the results conforms to
> the spec? Remember, you are writing for the non-specialist
> John Doe, DIY.
>
>> Results:
>> The filter coefficients.
>
> Sure
>
>> The weight-normalized ripple.
>
> Again, someone with possibly more interest than skills
> is supposed to handle such results, and evaluate them.
> I am not sure it is very easy to write a short guideline
> about how to use these things, that a DIY'er will be
> able to use. Write too long, and the DIY'er will not
> even read it.
>
>> A filter response plot or listing perhaps
>> etc.
>>
>> I don't think this would be hard to learn how to use effectively.
>
> Maybe not, if we were talking about trained engineers.
> We are, however, talking about something for DIY'ers
> to use. A completely different type of user.
>
>> All that said, I don't think one should use something like this as a
>> "black
>> box" in an automated system unless the requirements are constrained -
>> because one *can* generate some weird filter responses.
>
> Exactly.
>
> Rune

Rune,

Maybe I'm too close to the problem. Anyway, here's an attempt at describing
ripple and weighting. You will have to decide if the descriptions are
adequate and if the descriptions are too lofty for an intended user:

- The filter design function or program will result in frequency response
that deviates from the given ideal - this is called "ripple". The filter
design program minimizes the maximum ripple values throughout. Doing that
causes the ripples to have equal peak values. In general, the longer the
filter, the lower the ripple.

- Sometimes you want the ripple in one region to be smaller than in others.
The "weighting" function simply says: "I want the ripple to be lower here, I
don't care about the ripple there" Without saying so, the "weight" is 1.0
everywhere. So, if I want lower ripple in one region then I might set the
weight to be 10. And, if I don't care about ripple in another region, then
I might set the weight to 0.1.

- An input to such a program for a bandpass filter might look like this:
Filter Length: 128
Number of samples: 12,800
Desired response: [0 0 0 .... 0 1 1 1 1 1 1 1 .... 0 0 0 0] (12,800 values)
Weight:[10 10 10 .... 10 1 1 1 1 1 1 1 . . . . 5 5 5 5] (12,800 values)

The weight says: the ripple in the lower stopband (attenuation) is important
compared to the ripple in the passband (comparing weights of 10 to weights
of 1) and 2X (weight 10 compared to weight 5) more important than the
ripple in the upper stopband. So, here, the attenuation in the upper
stopband will be 2 times worse than in the lower stopband (at the respective
ripple peaks).

Because we are *all* DIY folks the variation in knowledge, understanding,
etc. is infinite. One could go further and describe the relationship
between the stopband weight and attenuation vs. the passband weight and
passband ripple. Then there are tricks to design particular types of
filters, and on and on .....

A simple trick for a program like this is to make the transition band
"desired response" a set of transition values like this:

[ 0 0 0 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1 1 1 1 1 1 ]
and one might set the weights in the transtion band to be rather low.

The program accompanied by a set of examples and pictures looks like a
"cookbook" to me.

Fred


From: Rune Allnor on

Fred Marshall skrev:
> "Rune Allnor" <allnor(a)tele.ntnu.no> wrote in message
> > Maybe not, if we were talking about trained engineers.
> > We are, however, talking about something for DIY'ers
> > to use. A completely different type of user.
....
> > Rune
>
> Rune,
>
> Maybe I'm too close to the problem.
....
> Because we are *all* DIY folks the variation in knowledge, understanding,
> etc. is infinite.
....
> The program accompanied by a set of examples and pictures looks like a
> "cookbook" to me.
>
> Fred

I think everything poils down to definitions of terms like
"cookbook", "DIY user" and so on.

The reason why I am a bit concernd about these things, is
that I have been involved in a couple of projects where the
interaction betwen the system and the end user have been
major factors in desicion making and design.

The job I did for my PhD thesis was to develop an analysis
system for seismic data. The system worked, but was so
intricate and based on such esoteric phenomena and
techniques that no one were willing to put in the efforts to
learn how to use it. The cost/benefit just did not add up.

On another project, the goal was to make a measurement
device to be used in an industrial plant. In that case, one
major design constraint was that the system should be
possible to operate flawlessly and consitently by an
unsupervised 20-year-old freshman worker the day after
he had his worker's certification test.

Once those sorts of factors are included in the design loop,
things become very interesting. And the work needed to
meet the spec is increased by a factor 5 to 10.

Rune

From: Ron N. on
Ron N. wrote:
> jeff227 wrote:
> > Has anyone come up with a "cookbook" for simple FIR filters similar to
> > RBJ's IIR cookbook?

The one on the musicdsp site is a bit wordy, and uses 2 sinc functions
for bandpass filter, when 1 sinc function will do.

Here's my recipe for a simple Q&D windowed sinc FIR filter generator
in about a 8 lines of Basic, plus some comments:

n = 256 : rem number of taps
fs = 44100 : rem sample rate
bw = 5000 : rem bandwidth, range 0 .. fs/2 and bw < fs/n
fc = 0 : rem center frequency, range 0 (lowpass) ... fs/2 (highpass)
g = 1 : rem filter gain

dim fir(n+1)

for i = 0 to n-1
a = 2.0*pi*(i-n/2)*bw/fs : rem scale sinc width
if a <> 0 then ys = sin(a)/a : else ys = 1 : rem calculate sinc
ys = g * (2.0*bw/fs) * ys : rem correct gain
yw = (0.54-0.46*cos(2.0*pi*i/n)) * ys : rem Hamming window
yf = yw * cos(2.0*pi*(i-n/2)*fc/fs) : rem shift to fc
fir(i) = yf : rem assign fir coeff.
next i

rem R. Nicholson's QDDS FIR filter generator cookbook recipe
rem QDDS = Quick, Dirty, Dumb and Short
rem version 0.1 - 2006-Dec-08
rem No warranties implied. Error checking, optimization, and quality
rem assessment of the "results" is left as an exercise for the student.
rem (consider this code Open Source under a BSD style license)
....

IMHO. YMMV.
--
Ron N.
http://www.nicholson.com/rhn/