I want to convert a non-realtime audio filter bank I wrote into one that works in realtime with low enough latency as not to be noticed when playing intruments through it. That usually means no more than about 10 ms. Currently the taps in my FIR filter are computed from an inverse FFT where I've set the bins to whatever freq response I want. From that I get an impulse of 2x the number of bins. This produces a symmetrical impulse (or at least after I shift it into the proper position). I'm currently working with 8192 bins, which gives me an impulse of 16384, where the main spike portion is of course near the center, about 8192 samples in. If I'm correct, that means I'm probably going to hear about a 185 ms delay between input vs output. What I'd like to do is convert that impulse into something more like that of an IIR where the initial spike (don't know what else to call it) is at the front and the trailing ripples come after that. The question is how? Can I do this with the impulse file itself, or do I mess around with the phases in the bins before I do the inverse FFT? Thanks for any help. -Elhardt
Converting symmetrical FIR Impulse to non-symmetrical ?
Started by ●August 3, 2008
Reply by ●August 3, 20082008-08-03
On 3 Aug, 15:49, "elhardt" <elha...@att.net> wrote:> I want to convert a non-realtime audio filter bank I wrote into one that > works in realtime with low enough latency as not to be noticed when playing > intruments through it. �That usually means no more than about 10 ms. > > Currently the taps in my FIR filter are computed from an inverse FFT where > I've set the bins to whatever freq response I want. �From that I get an > impulse of 2x the number of bins. �This produces a symmetrical impulse (or > at least after I shift it into the proper position). �I'm currently working > with 8192 bins, which gives me an impulse of 16384, where the main spike > portion is of course near the center, about 8192 samples in. �If I'm > correct, that means I'm probably going to hear about a 185 ms delay between > input vs output. �What I'd like to do is convert that impulse into > something more like that of an IIR where the initial spike (don't know what > else to call it) is at the front and the trailing ripples come after that. > The question is how? �Can I do this with the impulse file itself, or do I > mess around with the phases in the bins before I do the inverse FFT?What kinds of filters are these? Plain low-pass, high-pass etc filters? Or some effects filters? If these are plain filters you might want to use IIR filters instead of FIRs. Not only is the latency in IIRs a lot less than with symmetrical FIRs, but they are cheaper on the computational resources. Rune
Reply by ●August 3, 20082008-08-03
First, you are doing the strange things in the strange way. The delay in a filter is determined by the narrowest band features of the response. From there you can either estimate the length and design the FIR filter by Parks-McClellan algorithm, or estimate the phase response as the minimum phase and design the IIR filter by FDLS algorithm of Greg Berchin. The FDLS method can result in the better phase response and more efficient realization *but* there are certain numeric and conceptual problems that you have to take care off. Of course, there is also a dull way of the approximation of the frequency response by a set of EQ filters with the brute force optimization, however this is not sporty. Vladimir Vassilevsky DSP and Mixed Signal Design Consultant http://www.abvolt.com elhardt wrote:> I want to convert a non-realtime audio filter bank I wrote into one that > works in realtime with low enough latency as not to be noticed when playing > intruments through it. That usually means no more than about 10 ms. > > Currently the taps in my FIR filter are computed from an inverse FFT where > I've set the bins to whatever freq response I want. From that I get an > impulse of 2x the number of bins. This produces a symmetrical impulse (or > at least after I shift it into the proper position). I'm currently working > with 8192 bins, which gives me an impulse of 16384, where the main spike > portion is of course near the center, about 8192 samples in. If I'm > correct, that means I'm probably going to hear about a 185 ms delay between > input vs output. What I'd like to do is convert that impulse into > something more like that of an IIR where the initial spike (don't know what > else to call it) is at the front and the trailing ripples come after that. > The question is how? Can I do this with the impulse file itself, or do I > mess around with the phases in the bins before I do the inverse FFT? > > Thanks for any help. > > -Elhardt > > >
Reply by ●August 3, 20082008-08-03
elhardt wrote:> I want to convert a non-realtime audio filter bank I wrote into one that > works in realtime with low enough latency as not to be noticed when playing > intruments through it. That usually means no more than about 10 ms. > > Currently the taps in my FIR filter are computed from an inverse FFT where > I've set the bins to whatever freq response I want. From that I get an > impulse of 2x the number of bins. This produces a symmetrical impulse (or > at least after I shift it into the proper position). I'm currently working > with 8192 bins, which gives me an impulse of 16384, where the main spike > portion is of course near the center, about 8192 samples in. If I'm > correct, that means I'm probably going to hear about a 185 ms delay between > input vs output. What I'd like to do is convert that impulse into > something more like that of an IIR where the initial spike (don't know what > else to call it) is at the front and the trailing ripples come after that. > The question is how? Can I do this with the impulse file itself, or do I > mess around with the phases in the bins before I do the inverse FFT? > > Thanks for any help. > > -Elhardt > > >I'm sure there's a clever way to do this with FIR filters. What you want is a minimum phase FIR filter; FIR filters are usually implemented because they're symmetric around their center point, which requires them to _not_ be minimum phase. Doing a web search on "non-minimum phase FIR filter synthesis" may cough up the right answer. In theory you could get your FIR filter, factor it as a polynomial in z^-1, and change all of the roots with magnitude greater than 1 into their reciprocals. In practice if you tried this for any realistically long FIR you'd lose your desired frequency response into a sea of numerical difficulties with the factoring. I suspect that there may be a a way to do this using the properties of the Fourier transform, taking the desired magnitude response and allowing the phase response to do whatever it needed to do in order to yield a minimum-phase answer. In practice I started doing this, filled up half an 8-1/2 x 11 sheet of paper and didn't get the answer, and that's my limit for free consultation today. -- Tim Wescott Wescott Design Services http://www.wescottdesign.com Do you need to implement control loops in software? "Applied Control Theory for Embedded Systems" gives you just what it says. See details at http://www.wescottdesign.com/actfes/actfes.html
Reply by ●August 3, 20082008-08-03
On 3 Aug, 21:28, Tim Wescott <t...@seemywebsite.com> wrote:> elhardt wrote: > > I want to convert a non-realtime audio filter bank I wrote into one that > > works in realtime with low enough latency as not to be noticed when playing > > intruments through it. �That usually means no more than about 10 ms. > > > Currently the taps in my FIR filter are computed from an inverse FFT where > > I've set the bins to whatever freq response I want. �From that I get an > > impulse of 2x the number of bins. �This produces a symmetrical impulse (or > > at least after I shift it into the proper position). �I'm currently working > > with 8192 bins, which gives me an impulse of 16384, where the main spike > > portion is of course near the center, about 8192 samples in. �If I'm > > correct, that means I'm probably going to hear about a 185 ms delay between > > input vs output. �What I'd like to do is convert that impulse into > > something more like that of an IIR where the initial spike (don't know what > > else to call it) is at the front and the trailing ripples come after that. > > The question is how? �Can I do this with the impulse file itself, or do I > > mess around with the phases in the bins before I do the inverse FFT? > > > Thanks for any help. > > > -Elhardt > > I'm sure there's a clever way to do this with FIR filters. > > What you want is a minimum phase FIR filter; FIR filters are usually > implemented because they're symmetric around their center point, which > requires them to _not_ be minimum phase. > > Doing a web search on "non-minimum phase FIR filter synthesis" may cough > up the right answer. > > In theory you could get your FIR filter, factor it as a polynomial in > z^-1, and change all of the roots with magnitude greater than 1 into > their reciprocals. �In practice if you tried this for any realistically > long FIR you'd lose your desired frequency response into a sea of > numerical difficulties with the factoring. > > I suspect that there may be a a way to do this using the properties of > the Fourier transform, taking the desired magnitude response and > allowing the phase response to do whatever it needed to do in order to > yield a minimum-phase answer. �In practice I started doing this, filled > up half an 8-1/2 x 11 sheet of paper and didn't get the answer, and > that's my limit for free consultation today.Could this be a test case for the Hilbert transform relation between magnitude and phase that RBJ has mentioned so often? It seems the OP has a magnitude response he is happy with; compute the HT, convert from polar to rectangular format, IFFT - shouldn't be too hard to implement? Rune
Reply by ●August 3, 20082008-08-03
Tim Wescott wrote:> elhardt wrote: >> I want to convert a non-realtime audio filter bank I wrote into one that >> works in realtime with low enough latency as not to be noticed when >> playing >> intruments through it. That usually means no more than about 10 ms. >> >> Currently the taps in my FIR filter are computed from an inverse FFT >> where >> I've set the bins to whatever freq response I want. From that I get an >> impulse of 2x the number of bins. This produces a symmetrical impulse >> (or >> at least after I shift it into the proper position). I'm currently >> working >> with 8192 bins, which gives me an impulse of 16384, where the main spike >> portion is of course near the center, about 8192 samples in. If I'm >> correct, that means I'm probably going to hear about a 185 ms delay >> between >> input vs output. What I'd like to do is convert that impulse into >> something more like that of an IIR where the initial spike (don't know >> what >> else to call it) is at the front and the trailing ripples come after >> that. The question is how? Can I do this with the impulse file >> itself, or do I >> mess around with the phases in the bins before I do the inverse FFT? >> >> Thanks for any help. >> >> -Elhardt >> >> >> > I'm sure there's a clever way to do this with FIR filters. > > What you want is a minimum phase FIR filter; FIR filters are usually > implemented because they're symmetric around their center point, which > requires them to _not_ be minimum phase. > > Doing a web search on "non-minimum phase FIR filter synthesis" may cough > up the right answer. > > In theory you could get your FIR filter, factor it as a polynomial in > z^-1, and change all of the roots with magnitude greater than 1 into > their reciprocals. In practice if you tried this for any realistically > long FIR you'd lose your desired frequency response into a sea of > numerical difficulties with the factoring. > > I suspect that there may be a a way to do this using the properties of > the Fourier transform, taking the desired magnitude response and > allowing the phase response to do whatever it needed to do in order to > yield a minimum-phase answer. In practice I started doing this, filled > up half an 8-1/2 x 11 sheet of paper and didn't get the answer, and > that's my limit for free consultation today.I'm not satisfied that minimum-phase filters will work. I suspect, from the OP's phrase "filter bank" in his opening post, that the several signals are to be recombined after filtering. Phase needs to be carefully managed if that's so. Jerry -- Engineering is the art of making what you want from things you can get. �����������������������������������������������������������������������
Reply by ●August 3, 20082008-08-03
Jerry Avins wrote:> Tim Wescott wrote: >> elhardt wrote: >>> I want to convert a non-realtime audio filter bank I wrote into one that >>> works in realtime with low enough latency as not to be noticed when >>> playing >>> intruments through it. That usually means no more than about 10 ms. >>> >>> Currently the taps in my FIR filter are computed from an inverse FFT >>> where >>> I've set the bins to whatever freq response I want. From that I get an >>> impulse of 2x the number of bins. This produces a symmetrical >>> impulse (or >>> at least after I shift it into the proper position). I'm currently >>> working >>> with 8192 bins, which gives me an impulse of 16384, where the main spike >>> portion is of course near the center, about 8192 samples in. If I'm >>> correct, that means I'm probably going to hear about a 185 ms delay >>> between >>> input vs output. What I'd like to do is convert that impulse into >>> something more like that of an IIR where the initial spike (don't >>> know what >>> else to call it) is at the front and the trailing ripples come after >>> that. The question is how? Can I do this with the impulse file >>> itself, or do I >>> mess around with the phases in the bins before I do the inverse FFT? >>> >>> Thanks for any help. >>> >>> -Elhardt >>> >>> >>> >> I'm sure there's a clever way to do this with FIR filters. >> >> What you want is a minimum phase FIR filter; FIR filters are usually >> implemented because they're symmetric around their center point, which >> requires them to _not_ be minimum phase. >> >> Doing a web search on "non-minimum phase FIR filter synthesis" may >> cough up the right answer. >> >> In theory you could get your FIR filter, factor it as a polynomial in >> z^-1, and change all of the roots with magnitude greater than 1 into >> their reciprocals. In practice if you tried this for any >> realistically long FIR you'd lose your desired frequency response into >> a sea of numerical difficulties with the factoring. >> >> I suspect that there may be a a way to do this using the properties of >> the Fourier transform, taking the desired magnitude response and >> allowing the phase response to do whatever it needed to do in order to >> yield a minimum-phase answer. In practice I started doing this, >> filled up half an 8-1/2 x 11 sheet of paper and didn't get the answer, >> and that's my limit for free consultation today. > > I'm not satisfied that minimum-phase filters will work. I suspect, from > the OP's phrase "filter bank" in his opening post, that the several > signals are to be recombined after filtering. Phase needs to be > carefully managed if that's so. > > JerryMmm. Good point. How do analog graphics equalizers handle this problem? -- Tim Wescott Wescott Design Services http://www.wescottdesign.com Do you need to implement control loops in software? "Applied Control Theory for Embedded Systems" gives you just what it says. See details at http://www.wescottdesign.com/actfes/actfes.html
Reply by ●August 4, 20082008-08-04
Tim Wescott wrote:> Jerry Avins wrote: >> Tim Wescott wrote: >>> elhardt wrote: >>>> I want to convert a non-realtime audio filter bank I wrote into one >>>> that >>>> works in realtime with low enough latency as not to be noticed when >>>> playing >>>> intruments through it. That usually means no more than about 10 ms. >>>> >>>> Currently the taps in my FIR filter are computed from an inverse FFT >>>> where >>>> I've set the bins to whatever freq response I want. From that I get an >>>> impulse of 2x the number of bins. This produces a symmetrical >>>> impulse (or >>>> at least after I shift it into the proper position). I'm currently >>>> working >>>> with 8192 bins, which gives me an impulse of 16384, where the main >>>> spike >>>> portion is of course near the center, about 8192 samples in. If I'm >>>> correct, that means I'm probably going to hear about a 185 ms delay >>>> between >>>> input vs output. What I'd like to do is convert that impulse into >>>> something more like that of an IIR where the initial spike (don't >>>> know what >>>> else to call it) is at the front and the trailing ripples come after >>>> that. The question is how? Can I do this with the impulse file >>>> itself, or do I >>>> mess around with the phases in the bins before I do the inverse FFT? >>>> >>>> Thanks for any help. >>>> >>>> -Elhardt >>>> >>>> >>>> >>> I'm sure there's a clever way to do this with FIR filters. >>> >>> What you want is a minimum phase FIR filter; FIR filters are usually >>> implemented because they're symmetric around their center point, >>> which requires them to _not_ be minimum phase. >>> >>> Doing a web search on "non-minimum phase FIR filter synthesis" may >>> cough up the right answer. >>> >>> In theory you could get your FIR filter, factor it as a polynomial in >>> z^-1, and change all of the roots with magnitude greater than 1 into >>> their reciprocals. In practice if you tried this for any >>> realistically long FIR you'd lose your desired frequency response >>> into a sea of numerical difficulties with the factoring. >>> >>> I suspect that there may be a a way to do this using the properties >>> of the Fourier transform, taking the desired magnitude response and >>> allowing the phase response to do whatever it needed to do in order >>> to yield a minimum-phase answer. In practice I started doing this, >>> filled up half an 8-1/2 x 11 sheet of paper and didn't get the >>> answer, and that's my limit for free consultation today. >> >> I'm not satisfied that minimum-phase filters will work. I suspect, >> from the OP's phrase "filter bank" in his opening post, that the >> several signals are to be recombined after filtering. Phase needs to >> be carefully managed if that's so. >> >> Jerry > > Mmm. Good point. > > How do analog graphics equalizers handle this problem?I'm not sure. I imagine that they aren't as sharp as users would like to imagine. Using analog circuits developed for speaker crossovers might work just fine. I'd need to play around with IIR filters to see if O could make them work. I smell a chance below fs/4. Jerry -- Engineering is the art of making what you want from things you can get. �����������������������������������������������������������������������
Reply by ●August 4, 20082008-08-04
Jerry Avins wrote:> Tim Wescott wrote:(snip)>> How do analog graphics equalizers handle this problem?> I'm not sure. I imagine that they aren't as sharp as users would like to > imagine. Using analog circuits developed for speaker crossovers might > work just fine. I'd need to play around with IIR filters to see if O > could make them work. I smell a chance below fs/4.There is a design by Motorola for a graphic equalizer for the 56001. (Yes, that old.) I believe it is available on the web. I don't remember how fast it is. I believe it is 10 band, which would be about an octave each. -- glen
Reply by ●August 4, 20082008-08-04
elhardt wrote:> I want to convert a non-realtime audio filter bank I wrote into one that > works in realtime with low enough latency as not to be noticed when playing > intruments through it. That usually means no more than about 10 ms. > ... > What I'd like to do is convert that impulse into > something more like that of an IIR where the initial spike (don't know what > else to call it) is at the front and the trailing ripples come after that. > The question is how? Can I do this with the impulse file itself, or do I > mess around with the phases in the bins before I do the inverse FFT?The impulse response of a minimum-phase system concentrates the greatest energy in the earliest time period. Oppenheim & Shafer describe a method to create a minimum phase system from its magnitude response, (pg 357 of "Digital Signal Processing", 1975), but it's not easy. A good step-by-step can be found here: http://tech.groups.yahoo.com/group/hifi_dsp/message/98 but I think that you'll have to become a Yahoo Groups member and join the hifi_dsp group in order to view it. Some results from that method can be found here: http://home.pacbell.net/donwm/index.html To make this work, you will probably have to oversample to an extremely high sampling rate. This is because ln(Magnitude) decreases very slowly, even for a high-order lowpass system, resulting in aliasing if the sampling/cutoff frequency ratio is not high enough. In the example cited above, he had to sample at 12 MHz in order to get good results up to 20 kHz. Greg






