Re: Help with THD+N calculations




"rcoup" <robert.coup@xxxxxxxxx> wrote in message
news:1149047348.326166.195250@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Hi All,

My DSP knowledge is far too rusty and I've been hitting my head against
the wall for a little while now. Archives of the group have got
tantalisingly close but I'm still confused. The fun situation is
calculating THD+N of an audio signal.

What I'm doing:
a. 1KHz sine wave is my fundamental.
b. Notch Filter to remove the 1KHz
c. FFT (8Kpoint)
d. Get magnitudes (mag[] = sqrt(re[]^2 + im[]^2))
e. Calculate the total energy over the range 20Hz to 20KHz
Ex = sum(sqr(mag[k])) with k in 3-3143 (the FFT bins i'm
interested in)
f. thdn = sqrt(Ex) / (3143-3+1)

Now I need to compare that with the amplitude of the fundamental to get
my %age... whats an easy way to do that? Have I messed up anything so
far (i'm thinking i should be removing DC...)?

You didn't say what the sample rate was / is.

With 8k points and 20kHz bandwidth (?) and some reasonable margin in
sampling rate, the sample rate might be 50kHz and 4K samples would be around
25kHz??? and 3143 would be (3143/4000)*25kHz = 19643.75Hz so maybe the
sample rate is 3143/4000 = 20,000/fs/2 so fs= 20,000 *(4000/3143)*2 =
50906.78Hz??

The frequency resolution then is 50906.78/8000 = 6.37Hz and 1kHz falls quite
closely to being an integer multiple of 6.37 - which is good.

I'm not sure of the best procedure for separating THD and N if that's what
you want or how accurately you need to separate them if at all. Anyway, the
THD is the ratio of rms values.

I don't see the mean being calculated above - or at least not where I'd
expect it to be.
I also don't see the magnitude of the signal at 1kHz being used as a
reference.

An estimate of the THD would be the sqrt of the mean of the sum of the
squared magnitudes at 2kHz, 3kHz, 4kHz, etc. divided by the magnitude at
1kHz.

An estimate of the noise would be the sqrt of the mean of the sum of the
squared magnitudes at all other frequencies - so, divided by the magnitude
at 1kHz would be the SNR.

I think that's correct....

Fred


.



Relevant Pages

  • Re: Help with THD+N calculations
    ... sampling rate, the sample rate might be 50kHz and 4K samples would be around ... squared magnitudes at 2kHz, 3kHz, 4kHz, etc. divided by the magnitude at ... squared magnitudes at all other frequencies - so, ...
    (comp.dsp)
  • Re: Comparison of signal generators
    ... evaluation of an amplifier needs to have THD an order ... of magnitude below that of the unit under test. ... Digital synthesis is the way to go. ...
    (rec.audio.tubes)
  • Re: Comparison of signal generators
    ... evaluation of an amplifier needs to have THD an order ... of magnitude below that of the unit under test. ... Digital synthesis is the way to go. ...
    (rec.audio.tubes)
  • Re: Comparison of signal generators
    ... evaluation of an amplifier needs to have THD an order ... of magnitude below that of the unit under test. ... Digital synthesis is the way to go. ...
    (rec.audio.tubes)