way to generate FIR from desired spectra data

I am trying to create a custom spectra noise signal from 20 to 20khz. Its got various peaks and valleys. I have a plot of the desired frequency response in about 2hz increments. Is there some way to generate an FIR filter from this data? Or should I say, generate the coefficients? Do all FIR filters come in the form:

b0 = 0.99765 * b0 + white * 0.0990460; b1 = 0.96300 * b1 + white * 0.2965164; b2 = 0.57000 * b2 + white * 1.0526913; tmp = b0 + b1 + b2 + white * 0.1848;

Reply to
acannell
Loading thread data ...

Matlab can do this with firls. Octave-forge (an addon to Gnu Octave, which is very matlab-like) can do it with fir2. You'll want to iterate by making a filter, examining its frequency response (freqz can do this), and adjusting the order of the filter to trade off computational complexity vs adherence to your input. If your shape has sharp peaks and valleys, especially in the low frequency range, you will need a high order filter.

No, that looks like some kind of gaussian noise. For one thing, a FIR filter would not destroy the historical input samples. Although, if the input is noise, I'm not sure if it matters. Good puzzler for DSP guys. :)

--
Ben Jackson

http://www.ben.com/
Reply to
Ben Jackson

As I though we had agreed on earlier, what you posted is an IIR filter, not an FIR filter. An FIR filter will have the form

out = sum-from-i=1toN( coefficient(i) * input(k+1-i) )

or in words, the current input times a coefficient plus the previous input times another coefficient plus the next earlier input times yet another coefficient... until you exhaust the set of coefficients. Next input sample, you slide your set of saved input samples over by one and do the same set of multiply-and-accumulates, which is how a DSP can do the filter very efficiently. A typical DSP will fetch a new coefficient and a new input from a circular buffer, multiply them together, and add them into an accumulator, all in one instruction cycle, and in many cases, the instruction can auto-repeat for N times with practically no additional overhead.

But if the filter needs to have a lot of "memory" -- if its impulse response takes a long time to die out -- then implemented as an FIR it will take a long buffer, a lot of coefficients, and a relatively long time to calculate unless you can do the multiplications and additions all in parallel (such as digitally with an FPGA or in analog domain with weighting resistors). And the IIR filter you have shown below has a lot of "memory". If you hit it with an impulse, each of b0, b1 and b2 becomes non-zero and will take a long time to die out. With no further input, b0 will decay only 0.235 percent per sample. That means it will take 295 sample periods for it to decay to half its original value, and over a thousand sample periods to get down to 1/256th of the amplitude of the input impulse. Depending on how accurately you wanted to emulate the behaviour of that IIR filter, then, you'd probably need a few hundred stages of sample delay, and a few hundred coefficients. MAYBE you can do it in a much shorter FIR filter that will give you acceptable performance, but it depends a lot on what's "acceptable."

Cheers, Tom

snipped-for-privacy@wwc.com wrote:

Reply to
Tom Bruhns

snipped-for-privacy@wwc.com skrev:

This should be to do exactly that and more;

formatting link

-Lasse

Reply to
langwadt

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.