# Best way to measure precise harmonics?

Discussion in 'Electronic Design' started by eromlignod, Oct 18, 2007.

1. ### Martin BrownGuest

That goes with the territory. To obtain a +/- 0.001 Hz frequency
resolution you would have to measure the signal for ~1000 seconds (you
might get away with 250s using some mathematical symmetry tricks if
you can control the initial conditions well enough).

For an upper frequency limit of A at 440Hz and oversampled by x2 that
is roughly 1,000,000 samples and should be doable with relative ease
in software on a PC. Your required precision seems to be severe
overkill, but let that pass. To go beyond the edge of human hearing at
20kHZ and oversampled x2 it is 40,000,000 samples which is still
doable but a fair bit slower - and you might want to go for 40kHz for

BTW You probably want to measure your signal for a fixed number of
cycles of the fundamental.
FFT will do it if you can supply enough data in the time domain
(choose a 2^N FFT). Practical implementations will require potentially
anti-alias regridding and a few other tweaks to sort out boundary
conditions.

Some hardware FFT based analysers can zoom in on a region of interest,
but non of them can get around the uncertainty principle. A short
burst of pure tone decaying in amplitude always contains a range of
frequencies around the fundamental.

Regards,
Martin Brown

2. ### Ken S. TuckerGuest

Question: How good are todays A to D Converters?
Will the conversion introduce serious artifacts?

I'm thinking that once the wave form is in digital
form it's just software to compare that to a perfect
sine wave at various frequencies. I'm sure that's
be done.
Regards
Ken

3. ### Martin BrownGuest

Good enough for studio quality digital audio to have taken over from
analogue.
Shouldn't do if it is done correctly. The most important thing is to
have an analogue brick wall filter to ensure that no out of band
frequencies reach the input to the ADC. Any timing phase jitter in the
converter will also hurt.
Just a SMOP... But for these volumes of data it requires some skill to
obtain the optimum results for a high dynamic range spectrum
containing a fundamental and a bunch of its near harmonics.

FFT is just a quick way to decompose a signal into its frequency
components. Classical slow DFT would be glacially slow on large
datasets unless you were only looking at a handful of likely
frequencies.

Regards,
Martin Brown

4. ### Tom BruhnsGuest

We've been building FFT analyzers for many years; I can assure you
that ADCs that are very linear do a great job in these analyzers. The
advent of delta-sigma converters made life a lot easier, and of course
for audio they are pretty much universal now. Obviously, if you are
looking for overtones in the spectrum of an excited string, and those
overtones are very close to the frequency of harmonics of the
fundamental, you'll want to know just how much harmonic distortion is
being introduced in the signal path. It can come from the transducer
that goes from acoustic to electrical, and in the amplifiers ahead of
the ADC, and in the ADC itself. It's quite possible to get distortion
in the electrical path lower than -100dBc in the audio range, but it's
also pretty difficult (in my experience) to find hard specs on the
distortion introduced by the acoustic to electrical transducer:
microphone or other pickup. If the overtone and fundamental are both
pure enough tones, and if the harmonics are enough different in
frequency from the overtones, the analyzer can resolve them.

Given a stream of samples from a good audio "card" (or external USB
audio port or whatever), the processor in a modern PC should have no
trouble at all keeping up doing "zooming" and decimating. That makes
the display of the results somewhat easier and the FFT processing can
be done real-time, since you're doing FFTs on relatively small blocks
of data at a slow data rate (after decimation). Does anyone sell
software that actually does all this (nearly) real-time? We used to
do it for audio-range analyzers using a custom ASIC chip set, but
these days, there's certainly plenty of processing power in a typical
PC. We still do it with an ASIC, but now much, much faster.

With respect to determining frequencies, _IF_ I know a priori that I'm
dealing with a pure tone (and therefore stable in phase and
amplitude), and the signal-to-noise ratio is good, I can determine the
frequency to within 0.001Hz with well under 100 seconds of data. The
reason is that I know exactly the response of each FFT point to any
frequency, and the response of a set of FFT points to the waveform can
only have happened with a particular input. It's equivalent, I guess,
to fitting a sinusoid to the digitized points; if I am quite sure the
input is a sinusoid with unknown frequency, phase, amplitude and
perhaps DC offset, I don't need very many samples to nail down those
four unknowns. Of course, the difficulty is that I almost never can
be really SURE that my input is a pure sinusoid. I must also have
enough data points to sufficiently average out whatever noise there
is; thus, a really good SNR allows fewer points to determine the
sinusoid.

You mentioned filtering to avoid aliasing. That's something else that
has been aided a whole lot by the delta sigma converters, since the
sample rate is much higher than the highest input frequency of
interest. The analog filter can be relatively gentle, and the
filtering becomes mainly a digital process; it can be linear phase FIR
filters, which makes corrections somewhat easier, too.

Even when you don't know what the input waveform really is, or when
you know it contains harmonics and overtones and the like, maybe even
multiple "fundamentals," an FFT analyzer can give you a very good
picture of what your signal looks like, spectrally. You do need to
understand things like "windowing" and what happens if your input
frequencies are not integer multiples of 1/(time record length)
though.

Cheers,
Tom

5. ### Ken S. TuckerGuest

Interesting, I'll pull this quote,
" hard specs on the distortion introduced
by the acoustic to electrical transducer:"

subject, I/we designed this unit,

http://www.trak4.com/earco/index.html

and I respect the problem of acoustic transducers.
At that site are recorded wave forms of Loons,
(let me know if you have any problems getting
their call, my current system hasn't got audio).

I'd get the Loons to yell by recording them and
then replaying their call over the lake. They'd
show at my dock yelling back. So I relied on
my "tin ear" (and others) to inform me of distortion.
I wasn't crazy about the science of the test but
what choice did I have?
Regards
Ken S. Tucker

6. ### AndrewGuest

Adobe Audition,(Previously known as Cool Edit Pro) I believe has this
sort of thing built in and IIRC you can write your own plugins.

http://www.cnet.com.au/mp3players/musicsoftware/0,239029154,240001669,00.htm

"Beat detection, tempo and pitch shifting, and vocal/instrumental
channel extraction (for a cappella and karaoke) are just a sampling of
the powerful audio-manipulation tools you'll find within Audition. You
can also restore and sweeten individual tracks with filters and effects
such as high-quality click/pop eliminators, noise and hiss reduction,
time stretching, sample rate conversion, and even pitch correction (for
fixing off-key notes). We're particularly impressed with the app's
Spectral view, which isolates individual instruments and transients and
permits full editing in the frequency space. All audio is processed
internally in high-fidelity 32-bit and sample rates up to 10MHz."

Andrew

7. ### Tom BruhnsGuest

No problem getting the loon sounds to play, though there's a
tremendous amount of echo in them, it seems like!

best off-the-shelf audio converters I know about are 24 bit, can
digitize with output rate of 96k and 192k samples/second in addition
to the old 48k, and have distortion products typically at the part per
million level. The noise is pretty darned good too. I suspect it's
unlikely that you'll find a transducer that linear, at least not with
loud sounds, and it's not trivial by any means to make a preamp with
such low distortion (though some of the modern op amps have helped a
lot with that).

One way to view an FFT is that it compares the input signal with sines
and cosines at the frequencies corresponding to the FFT points (also
commonly called "bins"). An advantage of the DFT is that you can do
that comparison for any spot frequency, and you're not limited to the
linear frequency spacing of the FFT; but of course, it's much slower
if you want to do a LOT of points. On the other hand, there's a DFT
algorithm that lets you calculate as the data comes in, and as soon as
you've finished collecting the data, just a very few operations gives
you the final answer from the DFT -- you can run several of those in
parallel if you want.

And of course, you can design a filter or detector that is "optimal"
in some sense, using things you know about the waveform you're
analyzing. An FFT is a good general-purpose spectral analysis tool,
but it likely won't be the _best_ tool for some specific application.

Cheers,
Tom

Cheers,
Tom

8. ### JosephKKGuest

eromlignod posted to sci.electronics.design:

In that case you could get a studio grade microphone and 24-bit
digitizer and sample for about 5 minutes for the lowest note. And
feed that to an FFT program. The file should be over 300 MiB.
For higher notes use correspondingly less time and get smaller files
as a bonus.

9. ### PieterGuest

If you only do this on one string at one frequency, I would use
filters. I have an old but nice B&K 2110 filter (Audio Frequency
Spectrometer) that can be used for such things. 1/3 octave filtering
should do, removes enough and keeps the signal intact enough. You can
compare the filtered output to a reference, precise signal on a scope
and see the difference (one sine will "walk", or make a lissajous
figure.

Or read several seconds of data into a computer and do FFT etc.

You will need a reference somewhere.

You can also do it the other way around: with a coil driven by a
precise sine source, you can bring the string into resonance and
measure the peaks. Notice that you must place the coil where you
expect the peak: at exactly the middle of the string, you can generate
the base tone, NOT the double frequency - for that the coil must be
app. at 1/4th of the string length.

Pieter

10. ### Phil AllisonGuest

"Pieter"

** Like what ???????????????

Crypic advice is just as worthless as the purest of bullshit.

Be prepared to justify the use of magnetic force drive.

....... Phil

11. ### Glen WalpertGuest

I suspect that a good part of the echo and the general poor quality of
the recording (compared to other loon recordings or the real thing)
are in part due to putting the microphone in the birdhouse-like box.
Realizing the full capabilities of a microphone requires that the
sound being measured directly hit the microphone without passing
through any apertures or reflecting from nearby surfaces. For
precision lab measurements the protective screen over the microphone
diaphragm is usually removed. (Measurement microphones come with
callibration curves with and without the screen, and they are
significantly different, without always being much better.)

All of the really good loon or other bird recordings I have heard were
made with a microphone at the focus of a parabolic reflector aimed
directly at the sound source. The pre-microphone signal gain with no
gain on indirect noise sources cannot be matched in any other way.
Without a good sound signal to the microphone, the microphone,
amplifier and A/D performance are almost irrelevant; even perfect
components would not give you a good recording. Put the microphone in
a box, and you might as well use the cheapest components you can find,
it won't make much difference in the recorded sound quality.

12. ### Ken S. TuckerGuest

Thanks for your "feeback" (pun intended) Tom.

Thanks for listening.
The Loons were a few hundred yards from shore
and recorded at night, so the shoreline trees
would bounce the sound quite a bit, those guys
are loud! That haunting echo might be part of the
uniqueness of the recording.
My audio frequency ADC experience was with
audio scramblers for security, like spy stuff.
The audio was digitized via an ADC-ROM and
anti-ROM'd at the recieving end.
I worked with servicing and developing Medical
Ultrasound equipment, where the audio frequency
runs to 10Mhz, that's fun stuff. Stuff is ingenious,
all dedicated to get a good image.
Regards
Ken

13. ### PieterGuest

Scanning through frequencies, one can find points where the string
gets into resonance. It will differ from a piano, as a piano strikes a
string, more like a pulse and will give a combination of base tone and
harmonics. With this coil, one can find resonace peaks without the
need for that base tone. Notice that if the frequency depends a (tiny
little) bit on the base tone, the harmonics get modulated a little by
that base tone, what will not happen with the coil measurement.

Pieter

14. ### JosephKKGuest

Ken S. Tucker posted to sci.electronics.design:
I personally found the recordings unacceptable. The noise was far
larger than the loon calls were. Make a point of checking an audio

15. ### Ken S. TuckerGuest

Thanks Joseph & Mr. Walpert as well.

Thanks for pointing that out.
The noise is mainly from a nearby waterfall, which
generates white noise, we should put that on the
site.
I've tried to eliminate "waterfall" noise using a
graphics equalizer but with mixed results.
I designed a filter in the EAR that softly favors

We recorded the sounds on to cassette, then
fed them into the wavefile back in the 90's.

Incidentally, we've only had one field failure.
A Woodpecker started pecking the hole and
that's were the microphone is, behind a light
screen, and it damaged the mike.
The customer (a wealthy bird watcher) makes
an appointment and comes to the office.
I swapped in a new PCB at cost (\$50), and
put heavy screening over the hole.
He bought another one because he wanted
stereo, putting one at each end of his river
front property.
I expected lightning striking the units but that
hasn't been reported.

We did echo testing of the mounting and
minimized that effect with foam.
All customers are satisfied, but we're working
on improvements!
Regards
Ken S. Tucker

16. ### JosephKKGuest

Ken S. Tucker posted to sci.electronics.design:
What i heard was more like excess gain going into oscillation.
Squeals and hums and such. It was kind of weird, when the loon calls
broke through they were clear.

17. ### Tom BruhnsGuest

Well, the file is 8 bit uncompressed at 11025 samples/second. Don't
expect a whole lot out of that, of course. I'm looking, right now, at
a section from near the start of the recording, about 8 seconds from
the start. I can see some energy at 60Hz and its harmonics, up to
about 360Hz, but by far the most energy is in the 0.8kHz to 1.8kHz
range. A typical segment is a warble between 1.0 and 1.2kHz, about 10
cycles of warble per second, with a very slightly falling average
frequency. That lasts about half a second, and is followed a very
short gap later by either about the same thing, or something similar
but at generally not quite as distinct from about 1.2 to 1.4kHz, same
sort of warble.

Perhaps the most remarkable thing to me is that the recording goes on
for several seconds at a time with only two or three dB variation in
amplitude. Seems like that would get monotonous very quickly. ;-)

Cheers,
Tom

18. ### Ken S. TuckerGuest

Our estimate is the EAR unit is 20 db better than
the human ear, so little things like crickets, frogs,
etc will be heard in the absence of loud sounds,
but the gain is dynamic, reducing as the output
goes to high, to prevent clipping. That's a handy
thing to provide wider dynamic range, via sound
"compression". I'm guessing that's the effects
you heard.
Regards
Ken

19. ### Ken S. TuckerGuest

Yeah! We worked hard to eliminate 60Hz...etc,
fancy filtering, shielded cable is standard too,
it's another trade-off, costs go up to take the 60hz
down a bit more for increasingly expensive filters.
Mainly it's a subjective call, boosting the amp
volume to where 60hz is audiable would also make
a cricket sound like a "rock concert".
Hmmm, might make a good cell phone "ringtone".
Yup, after awhile you just tune them out,
them Loons will spend all night humping,
sort of a lullaby.
Thanks Tom.
Ken

20. ### JosephKKGuest

Ken S. Tucker posted to sci.electronics.design:
You may never know until you use a couple of different machines to
play it back with.