Hi, Thanks to all for the helpful replies. --------------------------------- I am trying to implement a filter with controllable slope. The slope should be adjustable from 0db/octave to maybe 24db/octave. It should run in realtime. --------------------------------- Fred suggested to interpolate the coefficients of fir filters with different slopes. I tried that and it worked good. But the filter should start to roll off at a very low frequency. (maybe 10-20Hz with samplerate 44.1kHz). To achieve that I need huge fir filters. So I cannot do it that way. Thanks Martin for the info on frequency warped filters, but I probably need more time to get into that. I could not find something which I understood well enough to try it. Jerry suggested that I could also use IIR filters and crossfade between them as long as they are linear-phase. (If I understood you correctly, Jerry?) Does that mean that I have to use forward-reverse filtering and overlap-add? That sound like a pain to implement it right and will probably need quite some computation. Now don't think I am ungrateful, but I am still trying to find a more suitable solution. If the response is a bit curvy or has some ripples I would not care too much if the overall trend shows the desired x db/octave and it would be something as efficient as an order 6-8 IIR or so. I played around with octave(matlab clone) and tried to place poles inwards spiraling in the unit-circle and zeros with the same spiral but a bit shifted. I tried that since I thought a pole closer to the unit circle is a stronger peak, so I hope to achieve the desired response by adding decreasingly strong peaks with increasing frequency. (Does that make any sense? Otherwise I try to explain my thought better.) Some times I achieved responses with e.g. 3.6 db/octave over a large range of the bandwidth. But it was just trial and error with some lucky moments. Does anybody have an idea how to find a formula for the pole/zero placement for a filter that would fit my needs? This page http://www.firstpr.com.au/dsp/pink-noise/ contains a cite from robert bristow-johnson: "an equiripple approximation to the ideal pinking filter can be realized by alternating real poles with real zeros. A simple 3rd order solution that i obtained is: ...." and it shows the coefficients. There must be a method to generate the coefficients on the fly for a given slope. gr. Anton

# filter with arbitrary and variable rolloff

Started by ●May 15, 2006

Reply by ●July 18, 20062006-07-18

Reply by ●July 18, 20062006-07-18

"Anton" <bantone@casema.nl> wrote in message news:86irlvgds5.fsf@koncon.nl...> Hi, > > Thanks to all for the helpful replies. > > --------------------------------- > I am trying to implement a filter with controllable slope. > The slope should be adjustable from 0db/octave to maybe 24db/octave. > It should run in realtime. > --------------------------------- > > Fred suggested to interpolate the coefficients of fir filters > with different slopes. I tried that and it worked good. > But the filter should start to roll off at a very low frequency. > (maybe 10-20Hz with samplerate 44.1kHz). To achieve that I > need huge fir filters. So I cannot do it that way. >Anton, Thanks! Well, this new bit of specification information opens a whole new aspect on things. If you need to roll off at 10Hz out of 44.1kHz, the 10Hz implies that the filter will be down quite a few dB at 40Hz - just as an example. This implies a transition band of 40Hz - 10Hz = 30Hz. 30Hz transition band implies 1/30Hz impulse response length or 33.333msec. At 44.lkHz sample rate the sample interval is 1/44100 = 0.22727msec. So the filter would have to have an impulse response around 33.33/0.22727 = 146 samples. (...and I could well be off by a factor of 2). Is that what you mean by huge? So, if it's a FIR filter then the length is determined by this specification using the rule of thumb: that the length of the filter is the reciprocal of the narrowest transition band width. Fred

Reply by ●July 18, 20062006-07-18

"Fred Marshall" <fmarshallx@remove_the_x.acm.org> writes:> "Anton" <bantone@casema.nl> wrote in message > news:86irlvgds5.fsf@koncon.nl... >> Hi, >> >> Thanks to all for the helpful replies. >> >> --------------------------------- >> I am trying to implement a filter with controllable slope. >> The slope should be adjustable from 0db/octave to maybe 24db/octave. >> It should run in realtime. >> --------------------------------- >> >> Fred suggested to interpolate the coefficients of fir filters >> with different slopes. I tried that and it worked good. >> But the filter should start to roll off at a very low frequency. >> (maybe 10-20Hz with samplerate 44.1kHz). To achieve that I >> need huge fir filters. So I cannot do it that way. >> > > Anton, > > Thanks! > > Well, this new bit of specification information opens a whole new aspect on > things. > If you need to roll off at 10Hz out of 44.1kHz, the 10Hz implies that the > filter will be down quite a few dB at 40Hz - just as an example. This > implies a transition band of 40Hz - 10Hz = 30Hz. 30Hz transition band > implies 1/30Hz impulse response length or 33.333msec. > At 44.lkHz sample rate the sample interval is 1/44100 = 0.22727msec. > So the filter would have to have an impulse response around 33.33/0.22727 = > 146 samples. > (...and I could well be off by a factor of 2). Is that what you mean by > huge? > > So, if it's a FIR filter then the length is determined by this specification > using the rule of thumb: that the length of the filter is the reciprocal of > the narrowest transition band width. > > FredHi Fred, I looked at some plots and I had the impression I would need quite a bit more than 146. I would not call 146 coeffs. a *huge* impulse response, but for every change of the variable slope parameter I would need to recalculate the interpolation for all the coefficients and of course the convolution to calculate the output. I hoped to achieve something more efficient. And actually the ideal of what I have in mind what not really have a transition band (or to put the other way around the whole frequency range would be the transition band). I don't really want to divide the frequency-range into a pass and a stop band, but I want to achieve a (ideally constantly rising or falling) spectral slope for the whole range. (BTW the intended use is for sound-synthesis) thanks, Anton

Reply by ●July 18, 20062006-07-18

Anton wrote:> Hi, > > Thanks to all for the helpful replies....> Jerry suggested that I could also use IIR filters and > crossfade between them as long as they are linear-phase. > (If I understood you correctly, Jerry?) > > Does that mean that I have to use forward-reverse filtering > and overlap-add? > That sound like a pain to implement it right and will probably > need quite some computation.I don't think I suggested linear-phase IIR filters. If I did, please forgive me. ...> This page http://www.firstpr.com.au/dsp/pink-noise/ contains a > cite from robert bristow-johnson: > > "an equiripple approximation to the ideal pinking filter can be > realized by alternating real poles with real zeros. > A simple 3rd order solution that i obtained is: ...." > > and it shows the coefficients. There must be a method to > generate the coefficients on the fly for a given slope.If you plot R.B-J's poles and zeros on log paper, you will probably find a constant spacing. 6 dB/octave up and 6 down is what makes 3 dB/octave possible. Placing poles and zeros closer together (at log scale) increases complexity and reduces ripple. I don't see a theoretical way to construct long slopes that are not multiples of 3 dB/octave, certainly not adjustable ones. Jerry -- Engineering is the art of making what you want from things you can get. �����������������������������������������������������������������������

Reply by ●July 19, 20062006-07-19

Anton wrote:> Thanks Martin for the info on frequency warped filters, > but I probably need more time to get into that. I could not > find something which I understood well enough to try it.Tsk, tsk ;) If you don't understand something then play with it! The basic idea of frequency warping is simple: The phase shift of a given frequency sinusoid through an (nontrivial) allpass filter is different from the phase shift through a unit delay. Therefore, when you take the weighted sum of the direct and allpass-filtered sinusoid a different response results than in an FIR with the same weights. Now, it turns out that the FIR and warped frequency responses are related by mapping the frequency axis through the allpass phase response curve, a function on [-pi, pi] -- hence the name. Proving that is the complicated part, of course, but it's easily observed. Anyway, frequency warping just popped into my head as something you might fiddle with but I don't know if it can do what you want. But I've thought of a viable scheme in the meantime: Starting from the observation that the magnitude of (z+1)^n has asymptotic slope -6*n dB/oct for integral n, I noticed that the same holds if we let n be nonintegral and develop into a power series in z to get an implementable system. Cascaded with a low-frequency correction filter this gives nice preliminary results. I'll follow up here once I have it all worked out. I'm doing this work with Maple, a Computer Algebra System. I recommend you too get a CAS to complement Octave. Two free packages I know of are here: http://maxima.sourceforge.net/ http://yacas.sourceforge.net/ Martin -- Research is what I'm doing when I don't know what I'm doing. --Wernher von Braun

Reply by ●July 25, 20062006-07-25

Hi Anton, this is just to let you know I'm still at it as I also want this for myself. The band-end correction filters are harder to parameterize than I anticipated but I believe it'll work out. Have you had any success with the other suggested approaches in the meantime? Martin -- The drowning girl will remark how pretty the coral. --Sara Swanson, Malignant

Reply by ●July 25, 20062006-07-25

Martin Eisenberg <martin.eisenberg@udo.edu> writes:> Hi Anton, > > this is just to let you know I'm still at it as I also want this for > myself. The band-end correction filters are harder to parameterize > than I anticipated but I believe it'll work out. Have you had any > success with the other suggested approaches in the meantime?Hi Martin, First of all, I am very glad to see that this interests you. I searched the web for a really long time, I asked a teacher and I asked here (comp.dsp) and it seems that there is no well known solution. I had absolutely no success and also very limited time. Otherwise I would have posted my progress. I have to finish some non dsp related work, and as if that is not bad enough, I got a stomach flu and could not do anything. It's just too hot here in Den Haag. I have just some basic knowledge of DSP, so for me this all takes really long. I got some books about digital filters from the library and I try to catch up, but you can't really count on me to come up with any useful results. So it is all on you now ;-) gr. Anton

Reply by ●July 25, 20062006-07-25

Anton wrote:> I have to finish some non dsp related work, and as if that is > not bad enough, I got a stomach flu and could not do anything.I hope you'll recover soon! Martin -- Quidquid latine scriptum sit, altum viditur.

Reply by ●July 26, 20062006-07-26

Jerry Avins wrote:> Anton wrote: > ... > > > This page http://www.firstpr.com.au/dsp/pink-noise/ contains a > > cite from robert bristow-johnson: > > > > "an equiripple approximation to the ideal pinking filter can be > > realized by alternating real poles with real zeros. > > A simple 3rd order solution that i obtained is: ...." > > > > and it shows the coefficients. There must be a method to > > generate the coefficients on the fly for a given slope. > > If you plot R.B-J's poles and zeros on log paper, you will probably find > a constant spacing.almost, Jerry. if i recall correctly there was some manual adjustment of the outside poles/zeros due to edge effects. certainly if you were making an optimized pinking filter that would be good to a zillion octaves, there would be a lot of alternating poles and zeros (maybe about 1/2 zillion pair) and in the middle of the list (assuming it is sorted in order of log frequency) these alternating poles/zeros would follow constant spacing extremely closely.> 6 dB/octave up and 6 down is what makes 3 dB/octave > possible. Placing poles and zeros closer together (at log scale) > increases complexity and reduces ripple. I don't see a theoretical way > to construct long slopes that are not multiples of 3 dB/octave, > certainly not adjustable ones.i s'pose one might try adjusting the relative spacing of the log frequency the zeros relative to their adjacent poles. we start out with a pole at the left and then alternate zeros and poles. the poles are sorta fixed and equally spaced in log frequency. with the zeros equally spaced but slidable w.r.t. their neighboring poles, one can make an adjustment of slope from 0 dB/oct (when the equally spaced and interspersed zeros are slid to the left right next to their left neighbors) to -6 dB/oct (when the zeros are slid over to the right next to their respective right neighbors). does that make any sense? i dunno what you would have to do to make it continuously adjustable from 0 to -12 dB/oct. r b-j

Reply by ●July 26, 20062006-07-26

robert bristow-johnson wrote:> Jerry Avins wrote:...>> If you plot R.B-J's poles and zeros on log paper, you will probably find >> a constant spacing. > > almost, Jerry. if i recall correctly there was some manual adjustment > of the outside poles/zeros due to edge effects. certainly if you were > making an optimized pinking filter that would be good to a zillion > octaves, there would be a lot of alternating poles and zeros (maybe > about 1/2 zillion pair) and in the middle of the list (assuming it is > sorted in order of log frequency) these alternating poles/zeros would > follow constant spacing extremely closely.That makes sense.>> 6 dB/octave up and 6 down is what makes 3 dB/octave >> possible. Placing poles and zeros closer together (at log scale) >> increases complexity and reduces ripple. I don't see a theoretical way >> to construct long slopes that are not multiples of 3 dB/octave, >> certainly not adjustable ones. > > i s'pose one might try adjusting the relative spacing of the log > frequency the zeros relative to their adjacent poles. we start out > with a pole at the left and then alternate zeros and poles. the poles > are sorta fixed and equally spaced in log frequency. with the zeros > equally spaced but slidable w.r.t. their neighboring poles, one can > make an adjustment of slope from 0 dB/oct (when the equally spaced and > interspersed zeros are slid to the left right next to their left > neighbors) to -6 dB/oct (when the zeros are slid over to the right next > to their respective right neighbors). does that make any sense?I actually started to write that; wrote it out and then discarded it when I found what seems to be a contradiction. Now I'm not so sure, but it's 3:00 AM. I'll sleep on it and just maybe, do the math. Even if the slope is adjustable that way it would go from zero (when poles and zeros coincide) to 3 dB/octave (when they alternate midway) and back to zero when they coincide th other way. (Ignore the ends for now.)> i dunno what you would have to do to make it continuously adjustable > from 0 to -12 dB/oct.The way we used to make variable attenuators: have a section with a 3 dB/octave range, and as many cascaded 6 dB/octave sections as needed. Jerry -- Engineering is the art of making what you want from things you can get. �����������������������������������������������������������������������