# spectral peak-estimation by cross-correlation

Started by March 8, 2008
```>One interesting technique applicable in high SNR situations for
>estimating two poorly separated tones involves use of a Gaussian
>window on data in an FFT and using the bins, off peak on the side away
>from the interfering signal to estimate the frequency and amplitude.
>Take a look at:
>
>http://www.edn.com/archives/1994/030394/graph/05df1fg1.htm
>
>There is a figure 1 you can click on to enlarge to see an example of
>the performance capability on the data set fred harris used to discuss
>frequency resolution. C code is provided. This is from a back issue of
>EDN magazine.
>
>The Gaussian window was chosen to:
>1) widen mainlobe response
>2) increase sidelobe rolloff
>3) simplify calculation of frequency and magnitude from the ratio of
>the amplitudes of two non-peak bins.
>

That looks interesting!
And it's simple to implement - which is great.
So I will immediately start to check if that will help my
analysis.  Now I am really curious to see how that method performs
with more narrow filters (the example in the paper uses
an fft size of 64 .. I need much higher resolution).

gr.
Bjoern

```
```On Mar 10, 1:53&#2013266080;am, "banton" <bant...@web.de> wrote:
> >On Mar 9, 6:54 am, "banton" <bant...@web.de> wrote:
> >> >3) Do you want to identify two close peaks as separate?
>
> >> Yes. &#2013266080;But I am not talking about Peaks which are so close
> >> that they just cause beating. &#2013266080;I mean Peaks which can easily
> >> be identified by eye, if you look at plots of the spectrum.

Human perception can, in general, not be easily reproduced
by means of DSP. Questions of the type 'I can easily identify
whatever when I hear or see the data - how can I achieve the
same with DSP or image processing?' are very common, but
only the very simplest can be answred. Most of what is
'easily' identifyable by humans is not at all easy to
identify by use of computers.

> >> But it is still the interference between them which causes trouble.
>
> >Simple magnitude peak finding methods with FFT results will
> >likely encounter problems if there are less than some small
> >number, say 2 or 3, of beats per frame. &#2013266080;
>
> You say: "simple magnitude peak finding methods" - and I wonder
> what other methods I could try.
> Any suggestions/references?

One could try statistical methods which analyze the
magnitude of the spectrum coeffcients and somehow evaluate
them against the genral shape of the spectrum, to try and
decide where peaks might exist, at the same time one discards
local maxima caused by noise.

I have never seen that done, though.

Rune
```
```> Rune Allnor wrote:
>> >> But it is still the interference between them which causes trouble.
>>
>> >Simple magnitude peak finding methods with FFT results will
>> >likely encounter problems if there are less than some small
>> >number, say 2 or 3, of beats per frame. =A0
>>
>> You say: "simple magnitude peak finding methods" - and I wonder
>> what other methods I could try.
>> Any suggestions/references?
>
>One could try statistical methods which analyze the
>magnitude of the spectrum coeffcients and somehow evaluate
>them against the genral shape of the spectrum, to try and
>decide where peaks might exist, at the same time one discards
>local maxima caused by noise.
>
>I have never seen that done, though.

Exactly something like this is what crosses my mind all the time
while working on this.
By examining the results from the things I have tried so far, I can
see one interesting point which might help to do this:

The parabolic-interpolation-based peak estimator catches at least
the existence of the peaks.  Just the estimated parameters are
sometimes quite off.
But if I additionally look at the frame-to-frame phase deltas of
2-3 surrounding bins on each side, I can see that the correct values
often show up in most of them.  I think some people call that
spectral clustering (Miller Puckette?).
Intuitively I think that this information combined with the
right statistical method could lead to much better results.
But .. oh well, "the right statistical method" is
certainly not easy to come up with.  At least I can use
this phase-information to make my system aware of its errors.

gr.
Bjoern

```
```On Mar 10, 9:02&#2013266080;am, "banton" <bant...@web.de> wrote:

> Intuitively I think that this information combined with the
> right statistical method could lead to much better results.
> But .. oh well, "the right statistical method" is
> certainly not easy to come up with. &#2013266080;At least I can use
> this phase-information to make my system aware of its errors.

I can't help with the details, but it seems you have a pretty
realistic view on how to proceed, what to try, as well as where
and why problems might occur.

Rune
```
```>> Rune Allnor wrote:
>>> >> But it is still the interference between them which causes
trouble.
>>>
>>> >Simple magnitude peak finding methods with FFT results will
>>> >likely encounter problems if there are less than some small
>>> >number, say 2 or 3, of beats per frame. =A0
>>>
>>> You say: "simple magnitude peak finding methods" - and I wonder
>>> what other methods I could try.
>>> Any suggestions/references?
>>
>>One could try statistical methods which analyze the
>>magnitude of the spectrum coeffcients and somehow evaluate
>>them against the genral shape of the spectrum, to try and
>>decide where peaks might exist, at the same time one discards
>>local maxima caused by noise.
>>
>>I have never seen that done, though.
>
>Exactly something like this is what crosses my mind all the time
>while working on this.
>By examining the results from the things I have tried so far, I can
>see one interesting point which might help to do this:
>
>The parabolic-interpolation-based peak estimator catches at least
>the existence of the peaks.  Just the estimated parameters are
>sometimes quite off.
>But if I additionally look at the frame-to-frame phase deltas of
>2-3 surrounding bins on each side, I can see that the correct values
>often show up in most of them.  I think some people call that
>spectral clustering (Miller Puckette?).
>Intuitively I think that this information combined with the
>right statistical method could lead to much better results.
>But .. oh well, "the right statistical method" is
>certainly not easy to come up with.  At least I can use
>this phase-information to make my system aware of its errors.

And this idea of finding a statistical method is also the root
of the idea to use cross-correlation with the transform of the window.
A single non-modulated sinusoid would correlate perfectly.
In praxis that would never happen.
Now there are different causes for the "deformation" of the peak.
Amplitude modulation, frequency modulation and near-by peaks -
all will cause deviations in the peak (deviations from the
shape of a peak that a non-modulated windowed sinusoid would result in).
The question is: Is it possible to identify the cause by the symptomes?

gr.
Bjoern
>
>
```
```
banton wrote:

> I am working on a plugin that involves estimation of spectral
> peaks

[...]

> In most cases that works sufficiently well, but when sinusoids
> are involved that are too close together (but still a few bins arpart),
> the sidelobes overlap too much and the whole thing gives pretty

[...]

> compute the cross-correlation:
> A[n] = sum(k = -N...N,  X[n] * W[n+k])
>
> Then I want to use peaks in A[n] to calculate sinusoidal parameters.

The results will be much sharper if you normalize the corellation to the
energy of the signals.

DSP and Mixed Signal Design Consultant
http://www.abvolt.com
```
```>Vladimir Vassilevsky wrote:
>
>banton wrote:
>
>> I am working on a plugin that involves estimation of spectral
>> peaks
>
>[...]
>
>> In most cases that works sufficiently well, but when sinusoids
>> are involved that are too close together (but still a few bins
arpart),
>> the sidelobes overlap too much and the whole thing gives pretty
>
>[...]
>
>> compute the cross-correlation:
>> A[n] = sum(k = -N...N,  X[n] * W[n+k])
>>
>> Then I want to use peaks in A[n] to calculate sinusoidal parameters.
>
>The results will be much sharper if you normalize the corellation to the

>energy of the signals.

I need further explanations.
How do I normalize the correlation?
I am sure that must mean something else then just _one_ scaling
factor for the correlation results, since I can't see how this
would change anything.
I found Rune's explanation