# Hilbert Transform

Started by December 31, 2012
```Hi all,

I want to understand what the number of taps in time domain Hilbert
transform is translated to.

For example, let's say I create analytic signal from real signal using 32th
order and 64th order FIR filter which are designed to perform Hilbert
transform. What am I gaining by performing more computation?
Thanks!

Thomas

```
```Since the fir hilbert transform filter is anti symmetric, the phase is always 90 degrees regardless of filter length.

So the trade-offs involve the frequency range over which the filter will try to hold the amplitude response at 1.0,  and the amplitude ripple over this range. It's impossible to have 90 degrees phase shift at DC or fs/2,  so if you try to specify a filter with flat amplitude that gets very close to these limits you will find that the required number of taps grows very large.

You probably know that these filters are not causal, and therefore you need to right-shift the impulse response by N/2 taps, which means the 90 degree criteria will be valid between the filter output and an N/2-sample delayed version of the input.

If you need to hold the 90 degree criteria down to a very low frequency, you are often better off with two parallel paths of cascaded iir allpass filters, where the allpass frequencies are interleaved in such a way as to hold the 90 degree phase-shift condition to a given accuracy. Note that unlike the fir approach, the amplitude response is exactly unity, but the differential phase response will have some ripple around the ideal value. Such filters have been discussed several times previously on comp.dsp, and generally require a good optimizer.
```
```>Since the fir hilbert transform filter is anti symmetric, the phase is
alwa=
>ys 90 degrees regardless of filter length. =20
>
>So the trade-offs involve the frequency range over which the filter will
tr=
>y to hold the amplitude response at 1.0,  and the amplitude ripple over
thi=
>s range. It's impossible to have 90 degrees phase shift at DC or fs/2,  so
=
>if you try to specify a filter with flat amplitude that gets very close to
=
>these limits you will find that the required number of taps grows very
larg=
>e.
>
>You probably know that these filters are not causal, and therefore you
need=
> to right-shift the impulse response by N/2 taps, which means the 90
degree=
> criteria will be valid between the filter output and an N/2-sample
delayed=
> version of the input.
>
>If you need to hold the 90 degree criteria down to a very low frequency,
yo=
>u are often better off with two parallel paths of cascaded iir allpass
filt=
>ers, where the allpass frequencies are interleaved in such a way as to
hold=
> the 90 degree phase-shift condition to a given accuracy. Note that unlike
=
>the fir approach, the amplitude response is exactly unity, but the
differen=
>tial phase response will have some ripple around the ideal value. Such
filt=
>ers have been discussed several times previously on comp.dsp, and
generally=
> require a good optimizer.
>

I wonder if it is related to ripple in magnitude response or phase
response? My question started a couple of weeks ago when I implemented
Hibert FIR based on the textbook I have (understanding DSP by Dr. Lyons) in
Matlab. When I created an analytic signal from a real sine wave and compute
the angle of each complex sample and calculated difference in angle in two
consecutive samples, I thought it would be a constant.... However, it was
not. I went through the script, but it seemed right.
Could you point me to any reference please?
Thanks,

Thomas

```
```gongdori wrote:
> Hi all,
>
> I want to understand what the number of taps in time domain Hilbert
> transform is translated to.
>
> For example, let's say I create analytic signal from real signal using 32th
> order and 64th order FIR filter which are designed to perform Hilbert
> transform. What am I gaining by performing more computation?
> Thanks!
>
> Thomas
>

This is more a general FIR filter question.

All FIR filters are approximations. More taps mean a
better approximation.

http://www-users.cs.york.ac.uk/~fisher/mkfilter/

there's a "Hilbert transform designer" at the link; you could
gen a wav file, cadge the result from the website into
a 'C' program, then measure the error from four iterations
through a 32 and then a 64 tap Hilbert.

This is a classic implementation trade, and I'd do a bit of
analysis or experiment to quantify the costs.

I put together a Hilbert transformer ( for fake stereo )
out of FFTW parts and the four-cycle test returned the original
file ( for 16 bit 44100 audio files ) . It is, for the bit
depth and sample rate, a "perfect" Hilbert transformer.

--
Les Cargill

```
```On 12/31/12 2:26 PM, gongdori wrote:
>> Since the fir hilbert transform filter is anti symmetric, the phase is
>> always 90 degrees regardless of filter length.
>>
...
> I wonder if it is related to ripple in magnitude response or phase
> response?

Bob is saying no ripple in the phase.  and he's correct.  just like you
can make a phase-linear or constant-delay filter with a relative phase
(relative to the fixed delay) of 0 degrees, you can do the same with a
relative phase of -90 degrees.

but when you're using these two orthogonal phase filters to mix and
create a different constant relative phase (say 45 degrees by mixing
equal proportions of the constant-delay filter and a Hilbert Transformer
with the same delay), the ripple in the magnitude response will
translate to a ripple in the phase.

> My question started a couple of weeks ago when I implemented
> Hibert FIR based on the textbook I have (understanding DSP by Dr. Lyons) in
> Matlab. When I created an analytic signal from a real sine wave and compute
> the angle of each complex sample and calculated difference in angle in two
> consecutive samples, I thought it would be a constant.... However, it was
> not.

okay, so you are measuring the phase between a constant-delay flat
filter and a Hilbert transformer with the same delay.  how are you
measuring that?  with zero-crossings, because if you're measuring the
phase difference with a dot-product, you have to normalize (as a
function of frequency) the amplitude of the two quadrature sine waves.

> I went through the script, but it seemed right.

what does the MATLAB script say?  or a subset of it.

--

r b-j                  rbj@audioimagination.com

"Imagination is more important than knowledge."

```
```If you are generating time-domain quadrature signals by applying signals to a Hilbert filter, you want to make sure that you are only analyzing the filter outputs after the filter has reached its steady-state output. For an N-tap filter you should wait at least N samples before capturing the output. If you are not doing this, it could cause the error you are seeing.

Bob

```
```"Robert Adams" <robert.adams@analog.com> wrote in message
Since the fir hilbert transform filter is anti symmetric, the phase is
always 90 degrees regardless of filter length.

So the trade-offs involve the frequency range over which the filter will try
to hold the amplitude response at 1.0,  and the amplitude ripple over this
range. It's impossible to have 90 degrees phase shift at DC or fs/2,  so if
you try to specify a filter with flat amplitude that gets very close to
these limits you will find that the required number of taps grows very
large.

You probably know that these filters are not causal, and therefore you need
to right-shift the impulse response by N/2 taps, which means the 90 degree
criteria will be valid between the filter output and an N/2-sample delayed
version of the input.

If you need to hold the 90 degree criteria down to a very low frequency, you
are often better off with two parallel paths of cascaded iir allpass
filters, where the allpass frequencies are interleaved in such a way as to
hold the 90 degree phase-shift condition to a given accuracy. Note that
unlike the fir approach, the amplitude response is exactly unity, but the
differential phase response will have some ripple around the ideal value.
Such filters have been discussed several times previously on comp.dsp, and
generally require a good optimizer.

"Filter Design for Signal Processing" by Lutovac, Vosic & Evans describes a
method of designing IIR Hilbert transforms. See Theodor A. Prosch,  "A
Minimalist Approximation of the Hilbert Transform", Sept/Oct 2012 QEX,  pp
25-31 for an example.

```