• Welcome to ASR. There are many reviews of audio hardware and expert members to help answer your questions. Click here to have your audio equipment measured for free!

Using Cross Corelation to lower influence of ADC for DAC measurements

In order to "align fundamental to a FFT bin center" your 'Samples' needs to be a multiple of 48, the period of a 1000 Hz wave sampled at 48 kHz. Try Samples=32736, or Samples=48000.
 
I'm launching another thing

The "flat top HFT248D" weighting window

Multitone has had it for years. It's called Flattop 10 there. Here's a comparison of BH7 (blue), HFT248d (green) and Keiser 12 (red). 32k FFT:

1723202954223.png
 
Audio precision and Virtins MI also have Flat Top.

For real-life audio measurements, a side-lobe rejection of below -200dB isn't remotely necessary. Blackman-Harris 7 window is plenty sufficient and has a better (0.5x smaller) ENBW than HFT248d or Kaiser 12, so may be a better compromise for measurements. Chebyshev 200 is fairly similar to BH7.

Edit: Zooming on the peak of the fundamental, you can see why HFT248d is a flat-top window:

1723209303106.png
 
Last edited:
In order to "align fundamental to a FFT bin center" your 'Samples' needs to be a multiple of 48, the period of a 1000 Hz wave sampled at 48 kHz. Try Samples=32736, or Samples=48000.
To align, you change your fundamental frequency to adapt to your sf and FFT size.
You choose your exact frequency as
[gf]=ROUND([ff]/[sf]×[FFTs],0) x [sf] / [FFTs]
where
[gf]= generator frequency
[sf] = sampling frequency
[FFTs]= FFT Size
[ff] = desired fundamental frequency

So, as an example, for [sf]=44100, [FFTs]=32768 and [ff]=1000, we get
[gf]= round(1000/44100×32768,0)×44100/32768
=743×44100/32768
=999.948 Hz

Most tools have an option to do that for you.
(REW, MT, MI,...)
 
To align, you change your fundamental frequency to adapt to your sf and FFT size.
You choose your exact frequency as
[gf]=ROUND([ff]/[sf]×[FFTs],0) x [sf] / [FFTs]
where
[gf]= generator frequency
[sf] = sampling frequency
[FFTs]= FFT Size
[ff] = desired fundamental frequency

So, as an example, for [sf]=44100, [FFTs]=32768 and [ff]=1000, we get
[gf]= round(1000/44100×32768,0)×44100/32768
=743×44100/32768
=999.948 Hz

Most tools have an option to do that for you.
(REW, MT, MI,...)
Oh yes of course, it's quite
normal, I hadn't thought about it.
I implement it in my frequency
generator.

I didn't understand what "FFT bin center" was

Thanks Thank you Thank you

I learn more think today
 
Last edited:
For real-life audio measurements, a side-lobe rejection of below -200dB isn't remotely necessary. Blackman-Harris 7 window is plenty sufficient and has a better (0.5x smaller) ENBW than HFT248d or Kaiser 12, so may be a better compromise for measurements. Chebyshev 200 is fairly similar to BH7.

Edit: Zooming on the peak of the fundamental, you can see why HFT248d is a flat-top window:

View attachment 385486
All is right .

Finally a tool that has HFT248
I will implement Kaiser-Bessel 12 for fun .
 
I'm launching another thing

The "flat top HFT248D" weighting window

This is the most precise weighting window
in amplitude and which has the lowest noise floor
that I know of.
As with all windows, there is a trade-off. The noise floor comes at the expense of a very high noise bandwidth and very wide main lobe.
 
As with all windows, there is a trade-off. The noise floor comes at the expense of a very high noise bandwidth and very wide main lobe.
Right .

But I find that its precision benefit strongly compensates
for the doubling of its bandwidth .

Moreover, as I have just learned, we can align
on what you call ::

"align fundamental to a FFT bin center"

Which is untranslatable in French .

So we lose, for the fundamental, the benefit of precision.

I implemented this thing in my generator .

There is another advantage to the HFT248, its measurement precision
for a frequency that tends towards 0 .

You stop in REW at 1Hz so you can't see it.

I did some distortion correction simulations with
the distortion correction equation of the "SABRE ES9039Q2M"

I noticed that the digital offset that we see on
the E1DA cosmos ADC which has the same type of correction is
due to this compensation.

The continuous value seen at the ADC output is directly proportional
to the correction of H2.

I leave you my "octave" simulation which contains comments,
to understand.

Hello and thank you for spending time for us.
 

Attachments

"align fundamental to a FFT bin center"
Which is untranslatable in French
Why would that be "untranslatable" ?

Try "Aligner la fondamentale avec le centre d'un échantillon de la TFR".
(Il n'y a là-dedans rien qui soit pour la poubelle, à mon avis ;))
 
Last edited:
Hello everyone

As everyone is waiting for
John to publish his version with the
correlation functionality, I will try to explain
Here what a correlator is.

There will not be much math, just the
necessary.

It starts well we will start from the equation of
cross correlation.

View attachment 385432
We see that the cross correlation function is a function
of time it is composed of a multiplication + an
integral, "Teta" can be replaced by t, "to" is a
time shift of one of the functions.

In electronics we can make this function by
putting a multiplier + integrator.

This circuit does not output the correlation function but the
correlation coefficient if at the input the frequencies are
fixed, it will be necessary to slide a signal (phase variation)
to obtain the correlation function.

To get rid of the division by time, we can
put a low-pass filter in place of the integrator,
this will be sufficient in the frequency range of your analysis.

--------------------------------------------------------------------
1st exercise: extracting a signal drowned in noise.

Let's imagine that we have a "Morse" signal, I don't know
how to say it in English, but this drawing ".--..-.---..."
will tell you something.

. and - will be replaced by a 1000Hz frequency train of
respective duration.
"." short 1000Hz train
"-" long 1000Hz train

You don't see this signal in the noise, so you are unable
to decode it.

We know that this signal contains 1000Hz trains.

So we put this signal on one input and a 1000Hz signal of infinite duration on the other.

A bit of math:

if there is no "morse" signal.

Let's see what happens for one of the noise frequencies called Fnoise.

we multiply Fnoise by our 1000Hz reference signal.

so at the output of the multiplier we have ::

A*sin(2*pi*Fnoise*t)*B*sin(2*pi*1000*t). A and B the amplitudes.

Yes but

sin A * sin B = 1/2((cos(A-B) - cos(A+B))

the 2nd part, we see, is a periodic signal.

If A-B and A+B belong to our measurement frequency range.
the output of the integral or the low-pass filter will give "0" so
no signal.

So for all the noise frequencies will be eliminated,
except the noise at 1000Hz which I hope will be very small.

Now we multiply a frequency train by our 1000Hz reference signal

at the output of the multiplier we will have:

A*sin(2*pi*1000)*B*sin(2*pi*1000), I'll spare you the phase
it's the mind that counts.
so

(sin A)^2 = 1/2 -1/2 cos 2*A .

We see that this time a continuous value "1/2" will be detected at the
integrator output, therefore signal detection.

In summary, it is only a small trigonometric function that switches the
visibility and decoding of our "morse" signal.

I think that now if you extrapolate this example to the cross correlation that
we are trying to set up we understand better.

replace the 2 previous signals with the same signal from the 2 channels of our ADC.

The first signal will be our noisy signal, the 2nd our reference signal, for
each frequency of our reference signal we apply what was done above.

I'll let you think about it.

-----------------------------------------------------------------------------

2nd example: let's build a spectrum analyzer with a correlator.

Yes ... it exists in HF, in the 80s (Yes, Yes, I'm old ...)
A person had made an HF spectrum analyzer in a small box
that was connected to an oscilloscope in this way, one channel contained
the output signal of the correlator the other channel a ramp representing the
frequency.

Let's take our correlator again.

On one of the inputs you have your signal to analyze, on the other a
sinus reference signal whose frequency increases linearly with time.

For each frequency of the reference signal you apply what was
said in the detection of a signal drowned in noise.

The analyzer will output a peak each time a frequency line is detected
in the signal to analyze.

So you get a spectrum analyzer ....

A spectrum analyzer is nothing more than a system that can extract signals
from noise either by FFT or by correlation.

I'll let you imagine all that can be done with a correlator.

Look at this paper from Zurich Industry that only talks about correlators:

Zurick Industry correlator application link
Thanks for all the info. And here's the link to the best AI translator that' gonna make it a little easier for you to follow this thread:

 
Last edited:
Why would that be "untranslatable" ?

Try "Aligner la fondamentale avec le centre d'un échantillon de la TFR".
(Il n'y a là-dedans rien qui soit pour la poubelle, à mon avis ;))
"bin center" for me , i don't understand
But with your equations today is clear
I have implemented in my generator this morning
 
FFT is about dividing the computing in small "bins". That's what the FFT size is about: the number of bins you use, which has to be an exponent of 2
I understand it in a slightly different way.

The calculation is always correct.

As the signal is sampled in time
the FFT is sampled in frequency.
Normal, as the FFT calculates discrete values
we will only find discrete values to the output.

What you call "bins" is the deltaF
of sampling of the FFT, like deltaT
for the signal in time.

I use your acronyms

deltaF = sf/FFTs = 1/(Duration of the FFT) = also
at the first calculated point of the FFT.

The first value of the FFT being the
power spectral density of the frequencies
between "0Hz and 1*deltaF" below 1*deltaF
the calculation of the FFT is in the process of being done
so the value equals zero.

I immediately understood the impact of your equation as soon as I saw it.
and thank for this .
 
But the THD is impacted by the weighting windows.
Only if the implementation is poor. THD calculations should not rely on single bin amplitudes. The energy in the fundamental and harmonics is distributed across bins according to their frequency and the spreading span of the window, but energy is not lost regardless of the window choice.

V5.40 beta 49 is now available with the cross correlation feature.
 
Only if the implementation is poor. THD calculations should not rely on single bin amplitudes. The energy in the fundamental and harmonics is distributed across bins according to their frequency and the spreading span of the window, but energy is not lost regardless of the window choice.

V5.40 beta 49 is now available with the cross correlation feature.
I agree there is no loss of energy
whatever the frequency, the calculation of THD+N
shows it well, since it goes through the calculation
of the energy and there is no difference
whatever the window.

Ok I only take the Max value
of the THD lines.

So my implementation is poor.

So I have to calculate for each line
its energy in a frequency band around
the line.

All I have to do is find the bandwidth
in which to do the calculation, and redo
my THD calculation

It's a good deal.

I had thought of this scenario what blocked me
is the bandwidth around the distortion lines
which is difficult to find.

Thanks for the direction to take for the calculation of the THD.

It is not finished yet my distortion calculation script, and it tends to be better.
 
Last edited:
Only if the implementation is poor. THD calculations should not rely on single bin amplitudes. The energy in the fundamental and harmonics is distributed across bins according to their frequency and the spreading span of the window, but energy is not lost regardless of the window choice.

V5.40 beta 49 is now available with the cross correlation feature.
Hi John

I don't know your software very well
I tried your Beta version on
reference *.wav but I don't understand
all of the explanation of the "cross correlation"
that you give.

What is "loopback" how to
configure it, I tried to search in the
documentation but I can't find it.

Where do we enter the parameters in RTA

Averages: forever ???
stop at: 1000 ???
overlap: 50% ???

In the selection of inputs what should we choose

Left / Right / Both ->???

If I put 1000 in "stop at" and I play a wav,

It doesn't stop and starts again at "0" and does a round.

And nothing is displayed.

Attached are 2 png ..
 

Attachments

  • RTA_wav_input.png
    RTA_wav_input.png
    17.3 KB · Views: 83
  • RYA_window_correl.png
    RYA_window_correl.png
    205 KB · Views: 85
V5.40 beta 49 is now available with the cross correlation feature.
Thank you very much! I did some first experiments yesterday and all seems to work fine, although the exact channel routing appeared to be a bit obscured. Also, it seems that stereo .WAV import is not implemented yet (may follow, though?) -- but I can work around that atm, using ADI-2 Pro in digital loopback, to test with reproducible known signals to get a feel for this new (to me) technique.
 
Back
Top Bottom