DSPRelated.com
Forums

Hilbert transform FIR size

Started by jungledmnc August 6, 2010
On 8/7/2010 12:33 AM, Vladimir Vassilevsky wrote:
> > > jungledmnc wrote: >> Thanks. Could you please point me to some keywords to search for? > > The keyword is DIY. A +/-45 degree IIR phase shifter is typical numeric > optimization problem (minimizing error vector magnitude). For the audio > purposes, you will likely need a filter of the order of 6...8.
I think the necessary order depends on the effective bandwidth. Using analog circuits to cover the telephone voice decade (300 .. 3000 Hz) three all-passes per channel are enough. The overall phase shift increases steadily with frequency -- each all-pass section ultimately adds 180 degrees -- but the difference remains close to 90 degrees where it counts. Parallel all-pass chains are superior to a HT in one channel and a delay in the other because of the effects of ripple in the HT approximation. I think I remember that Clay Turner wrote an article on the design of parallel IIR chains. Perhaps he will point you to it. Jerry -- Engineering is the art of making what you want from things you can get. �����������������������������������������������������������������������
On Aug 6, 6:01 pm, Vladimir Vassilevsky <nos...@nowhere.com> wrote:
> jungledmnc wrote: > > Hi, > > I want to create a frequency shifter for audio. First I need to get an > > analytical signal via a hilbert transformer. I started by checking out how > > long the Hilbert FIR would be. Unfortunately I ended with 20ms, which seems > > to be related to -3dB at 50Hz (1/0.02). Isn't there another way to do that? > > I mean 20ms is a relatively long delay for realtime processing and also 800 > > taps would need relatively lots of CPU power. > > Don't use Hilbert FIR. Use IIR allpass filter. >
On Aug 7, 12:33&#4294967295;am, Vladimir Vassilevsky <nos...@nowhere.com> wrote:
> ... A +/-45 degree IIR phase shifter is typical numeric > optimization problem (minimizing error vector magnitude). For the audio > purposes, you will likely need a filter of the order of 6...8.
for a broadbanded frequency shifter, i am not very confident that you can do this; accomplish a reasonably flat +/- pi/4 phase shift over several octaves of audio, with an 8th-order IIR APF. in fact, i just don't believe it. do you mean some linear phase + pi/4 and the same linear phase - pi/4? r b-j

Jerry Avins wrote:

> On 8/7/2010 12:33 AM, Vladimir Vassilevsky wrote: > >> jungledmnc wrote: >> >>> Thanks. Could you please point me to some keywords to search for? >> >> >> The keyword is DIY. A +/-45 degree IIR phase shifter is typical numeric >> optimization problem (minimizing error vector magnitude). For the audio >> purposes, you will likely need a filter of the order of 6...8. > > > I think the necessary order depends on the effective bandwidth. Using > analog circuits to cover the telephone voice decade (300 .. 3000 Hz) > three all-passes per channel are enough. The overall phase shift > increases steadily with frequency -- each all-pass section ultimately > adds 180 degrees -- but the difference remains close to 90 degrees where > it counts.
The goal is minimizing total error vector rather then just the error of phase. So the filters don't have to be exactly allpass. This provides for additional degree of freedom; you may get by lower orders.
> Parallel all-pass chains are superior to a HT in one channel and a delay > in the other because of the effects of ripple in the HT approximation. I > think I remember that Clay Turner wrote an article on the design of > parallel IIR chains. Perhaps he will point you to it.
Clay presented neat idea of using the same FIR filter in +45 and -45 paths of HT, so the magnitude in both channels is identical by design. However I am unaware of IIR methods other then bruteforce optimization. Vladimir Vassilevsky DSP and Mixed Signal Design Consultant http://www.abvolt.com
On 8/7/2010 11:12 AM, Vladimir Vassilevsky wrote:
> > > Jerry Avins wrote: > >> On 8/7/2010 12:33 AM, Vladimir Vassilevsky wrote: >> >>> jungledmnc wrote: >>> >>>> Thanks. Could you please point me to some keywords to search for? >>> >>> >>> The keyword is DIY. A +/-45 degree IIR phase shifter is typical numeric >>> optimization problem (minimizing error vector magnitude). For the audio >>> purposes, you will likely need a filter of the order of 6...8. >> >> >> I think the necessary order depends on the effective bandwidth. Using >> analog circuits to cover the telephone voice decade (300 .. 3000 Hz) >> three all-passes per channel are enough. The overall phase shift >> increases steadily with frequency -- each all-pass section ultimately >> adds 180 degrees -- but the difference remains close to 90 degrees >> where it counts. > > The goal is minimizing total error vector rather then just the error of > phase. So the filters don't have to be exactly allpass. This provides > for additional degree of freedom; you may get by lower orders. > >> Parallel all-pass chains are superior to a HT in one channel and a >> delay in the other because of the effects of ripple in the HT >> approximation. I think I remember that Clay Turner wrote an article on >> the design of parallel IIR chains. Perhaps he will point you to it. > > Clay presented neat idea of using the same FIR filter in +45 and -45 > paths of HT, so the magnitude in both channels is identical by design. > However I am unaware of IIR methods other then bruteforce optimization.
There are symmetries that can be exploited. Once symmetry constraints are applied. t relatively simple one-decade case becomes dependent on a single parameter that trades phase ripple for bandwidth. Jerry -- Engineering is the art of making what you want from things you can get. &#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;
On Aug 7, 11:12&#4294967295;am, Vladimir Vassilevsky <nos...@nowhere.com> wrote:
> Jerry Avins wrote: > > On 8/7/2010 12:33 AM, Vladimir Vassilevsky wrote: > > >> jungledmnc wrote: > > >>> Thanks. Could you please point me to some keywords to search for? > > >> The keyword is DIY. A +/-45 degree IIR phase shifter is typical numeric > >> optimization problem (minimizing error vector magnitude). For the audio > >> purposes, you will likely need a filter of the order of 6...8. > > > I think the necessary order depends on the effective bandwidth. Using > > analog circuits to cover the telephone voice decade (300 .. 3000 Hz) > > three all-passes per channel are enough. The overall phase shift > > increases steadily with frequency -- each all-pass section ultimately > > adds 180 degrees -- but the difference remains close to 90 degrees where > > it counts. > > The goal is minimizing total error vector rather then just the error of > phase. So the filters don't have to be exactly allpass. This provides > for additional degree of freedom; you may get by lower orders. > > > Parallel all-pass chains are superior to a HT in one channel and a delay > > in the other because of the effects of ripple in the HT approximation. I > > think I remember that Clay Turner wrote an article on the design of > > parallel IIR chains. Perhaps he will point you to it. > > Clay presented neat idea of using the same FIR filter in +45 and -45 > paths of HT, so the magnitude in both channels is identical by design. > However I am unaware of IIR methods other then bruteforce optimization.
Clay's idea (similar to one that i have had previously and i've seen this +/- 45 degree thing somewhere else, maybe even a grad school textbook) is FIR, not IIR. i haven't come to a conclusion regarding this, but in a regular 90- degree delayed Hilbert transformer, half-band symmetry can be used to eliminate (set to zero) every other FIR tap (except the center tap). i am wondering if half-band symmetry can also be used with the 45 degree delayed Hilbert. Jerry, Clay, do you know offhand? i s'pose i can look at this and work it out. r b-j
Jerry Avins <jya@ieee.org> wrote:
(previously snipped discussion on audio frequency shifter)

> I think the necessary order depends on the effective bandwidth. Using > analog circuits to cover the telephone voice decade (300 .. 3000 Hz) > three all-passes per channel are enough. The overall phase shift > increases steadily with frequency -- each all-pass section ultimately > adds 180 degrees -- but the difference remains close to 90 degrees where > it counts.
This reminds me of some experiments someone I knew was doing some years ago on feedback reduction in audio systems. The idea was to use a balanced mixer to shift the frequencies by a small amount, maybe a few Hz. The suggestion was that an appropriate shift would not be too audible (with voice, anyway) but would reduce the ability for audio feedback oscillation. -- glen
On 8/7/2010 2:22 PM, glen herrmannsfeldt wrote:
> Jerry Avins<jya@ieee.org> wrote: > (previously snipped discussion on audio frequency shifter) > >> I think the necessary order depends on the effective bandwidth. Using >> analog circuits to cover the telephone voice decade (300 .. 3000 Hz) >> three all-passes per channel are enough. The overall phase shift >> increases steadily with frequency -- each all-pass section ultimately >> adds 180 degrees -- but the difference remains close to 90 degrees where >> it counts. > > This reminds me of some experiments someone I knew was doing > some years ago on feedback reduction in audio systems. The idea > was to use a balanced mixer to shift the frequencies by a small > amount, maybe a few Hz. The suggestion was that an appropriate > shift would not be too audible (with voice, anyway) but would > reduce the ability for audio feedback oscillation.
I actually did that around 1954, using tubes and heterodyne techniques. A shift of about 3 to5 Hz was acceptible for voice and offered about 10 dB extra gain in most halls. The box used an IF of IIRC 225 KHz using aircraft IF transformers, filtered out the upper sideband, and then heterodyned back to audio with an oscillator below the remaining sideband. A major problem was keeping the oscillators stable. They were too far apart to make pulling a problem. Jerry -- Engineering is the art of making what you want from things you can get. &#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;
Thanks to all of you. I take it there is no simple way to compute the
allpass coefficients, except for brute-force search. So I did it. I wrote a
simple app, which searches for requested number of allpass sections
evaluating results like this:

H1 = Hallpass_A1(z) * Hallpass_A2(z) * ..
H2 = Hallpass_B1(z) * Hallpass_B2(z) * ..
where everything is complex. |H1| = |H2| = 1 as expected.

Finally phase1 = atan2(H1.R, H1.I) + PI/2, phase2 = atan2(H2.R, H2.I)
Difference = phase1 - phase2, and some wrapping.
Difference should be as close to 0 as possible.

I tried 4 biquad sections (so I guess 8th order) and the results are pretty
close to 90 degrees in all frequencies in my range, tried 50 - 15000 Hz. So
I tried to use the filters in an analyzer, which simply feeds it with delta
and FFTs the results and unfortunately it was for from being that good. In
some small interval of frequencies around say 100 - 400 Hz it was close to
90 degrees, but then it goes to hell and at about 7000 Hz the phase
response of both filters even crossed each other (0 degrees difference in
phase shift).

What am I doing wrong? I tried to find bugs, but everything seems working
fine, so there must be some logical error.
On Aug 7, 8:24&#4294967295;pm, "jungledmnc" <jungledmnc@n_o_s_p_a_m.gmail.com>
wrote:
> I take it there is no simple way to compute the > allpass coefficients, except for brute-force search. So I did it.
exactly what? how did you search for your optimal coefs and what did you get?
> I wrote a > simple app, which searches for requested number of allpass sections > evaluating results like this: > > H1 = Hallpass_A1(z) * Hallpass_A2(z) * .. > H2 = Hallpass_B1(z) * Hallpass_B2(z) * .. > where everything is complex. |H1| = |H2| = 1 as expected. > > Finally phase1 = atan2(H1.R, H1.I) + PI/2, phase2 = atan2(H2.R, H2.I) > Difference = phase1 - phase2, and some wrapping. > Difference should be as close to 0 as possible.
difference should be close to 0 or close to pi/2?
jungledmnc wrote:

> I want to create a frequency shifter for audio.
Are you sure you want a frequency shifter and not a pitch shifter? Pitch shifers are much more commonly used for audio than frequency shifters. Pitch shifters do: for all Fin : Fout = Fin * a which preserves the relationship between harmonics of a single note. Frequency shifters do: for all Fin : Fout = Fin + a which might be useful when used subtly for an audio effect, but will not give you what you want if what you want is a pitch shifter. Erik -- ---------------------------------------------------------------------- Erik de Castro Lopo http://www.mega-nerd.com/