Best way to measure precise harmonics?

as you also suggest filtering and period measurement, I would suggest doing the filtering digitally, its just as easy to then do the period measurement while it is still digitised.

a pc soundcard would probably be sufficient for this.

Colin =^.^=

Reply to
colin
Loading thread data ...

Is this for that self-tuning piano someone was talking about a year or so ago? Was that you?

Thanks, Rich

Reply to
Rich Grise

You will not be able to get that resolution. There are to many factors involves. When a string vibrates it does so with at a range of frequencies. (They are not integer multiples of the fundamental and higher harmonics differ drastically.)

Your 0.001Hz in the upper range, say, C4 = 261hz, gives you an error of

0.002/261 = 7.6*10^(-6) but in the upper partials, say C8 = 4186, has error that is 1/4000th of that. (so your error actually decreases drastically as you increase frequency, but that surely doesn't make sense)

Think about it this way, the average musician can usually hear a frequency difference of 5 cents. This corresponds to a range C4 +- 0.751 hz but at C8 this is about +- 13hz.

As you probably already know, humans ear "logarithmically". Your error needs to take that into account or it actually ends up being much more precise in the higher frequencies than the lows.

Of course you could have something, that say, gives you your 0.001hz at C1 but then your 100x more than what is needed for 5 cent approximation(surely you'll want more but how much?). but at C8 your 13000x better.

So if you can get 0.001hz it does you no good in the higher frequencies and its just a huge waste.

Either settle for less accuracy in the lower range or develope a better technique that works seperately for the two different domains.

This is not to say you can't do it quite easily. You should realize that sounds produced by any instrument is not mathematical and cannot be described exactly by mathematics. Your going to have to settle for some approximation.

Increase your sampling size or average over periods and take the most probable frequency(the highest point). That is probably the best your going to do. I don't think you'll ever get 0.001hz because no string vibrates within that range.... even if it could no one could tell the difference between two tunings there were 0.008 hz apart(unless the fundamental was like 0.1hz).

So essentially your anaysis is unrealistic and doesn't reflect reality. Not only that, even the device measuring the frequency will introduce its own distortions. You need to ask yourself what your really trying to do here.

Reply to
Jon Slaughter

The low midrange are two strings in parallel, and the mid to top range are three strings in parallel (physically, of course) they're deliberately detuned from each other to give a "richer, fuller" tone, if you'll forgive the 'phool terminology.

A piano tuned with the strings exactly dead-nuts would sound awful.

Thanks, Rich

Reply to
Rich Grise

Please read the rest of my postings in this thread. I know what I'm doing.

Don

Reply to
eromlignod

Yeah, that's me, but no, this is a different project. You can read about the self-tuner here if you're interested:

formatting link

formatting link

formatting link

I can obtain very precise single readings of the fundamental all day long. That's a done-deal for me. Now I'd like to be able to compare relative harmonics (yes, I know they're "overtones", but the two terms are usually used interchageably in music). I can't tell you a whole lot about what I'm up to, since this patent hasn't issued yet, but thanks for the help.

Don A. Gilmore Kansas City

Reply to
eromlignod

If you knew what you were doing you wouldn't have asked such a thing... Anyways, your going to do what your going to do so do it.

Reply to
Jon Slaughter

I'm sorry Jon; I didn't mean to come across like a smartass.

I currently have methods to determine pitch with very high accuracy and I'm well aware of the musical ramifications of my work. I was just hoping that there was a product out there with similar accuracy, but that would allow me to compare each harmonic frequency, not just measure the fundamental alone.

As has been suggested, it looks like I'll have to use my device in conjunction with a tuneable band-pass filter and measure each harmonic one at a time.

Don

Reply to
eromlignod

You said you wanted to find the frequencies of the harmonics in a waveform. FFT-based spectral analysis will work fine for that. Use a spectrum over a frequency range appropriate to capture the essence of the harmonics you want to look at more carefully, and then zoom in on each one as appropriate: set the center frequency to the nominal harmonic frequency, and set the span low enough to capture what you want. Used properly, it will give you much more information than the period of the waveform does. The period, for example, does not tell you if a harmonic is exactly a multiple of the fundamental, or not. The FFT can easily do that, at least up to the limits of the dynamic range of the instrument.

Cheers, Tom

Reply to
Tom Bruhns

Well, I'm not going to read your other posts. Sorry. Maybe you do explain in more detail whats going on but I have my own projects I have to work on.

I think though what your failing to realize is that the signal your trying to measure is not stable. That is, the frequency is time dependent. This means no matter how accurate you measure you will still get a "blur" of frequencies and also there amplitudes(which I know you are not worried about in this case).

Think of vibrato but on a much smaller scale. If you are measuring frequencies changes past this level it does no good.

For example, Lets suppose you have perfect pitch and can determine the frequency within 1 cent. Now suppose someone is playing a not on a guitar and using vibrato. Do you think you can determine the frequency within

1cent? No, its impossible! Why? Because there is no frequency. There is an average frequency which you can use to determine the average pitch but even that might be wrong because they might not be vibrating around a fixed pitch.

So the point is not so much your measuring methods but that the vibrations themselfs are time-dependent.

A simple model might be something like this:

x(t) = cos(f*t)

then we say that the frequency is f. This is a mathematical model though(note that its fourier transform is dirac(w + f) + dirac(w - f)... which are only idealized anyways).

What we really have is something like

x(t) = cos(f(t)*t)

Suppose f(t) is a perfect vibrato around some fixed frequency f

then you have

x(t) = cos((f + A*cos(m*t))*t)

where A is the strength and m is the frequency.

Hopefully you can appreciate that x(t)'s frequencies are spread out around f. Obviously it depends on both m and A.

I think though that you'll find any real string isn't going to behave as ideally as you think it is. I could be wrong here as I haven't done any extensive research on it. One way to sorta see whats going on is look at a STFFT and watch the frequencies change with time. The fundamentals are not such a big deal because they are so low and you'll barely see them move but the higher up you go the more drastic the effect becomes.

If you remember my calculations before, we had C4 was 0.761hz while C8 was

13hz. This means that going through 4 octaves gave a factor of 17. That might not seem like much but when you consider the higher overtones above 10khz it becomes more signficant(assuming you take the human and his imperfect ear out of the picture).

In any case, it really depends on what your trying to accomplish. I'll leave it up to you since you know more about what your trying to do. I'm just trying to get the point across that your not dealing with a mathematical model and so you have to work within the confines of reality. From my brief glimpse of other posts it seems your trying to get the frequencie of a vibrating piano strings. But again, there is no "frequency" because its always changing. But what you can do is get an average frequency which will center around an "ideal" frequency and then you can use that ideal one for whatever calculations you want. Since most errors will be normally distributed and most imperfections will be symmetric(for the most part) will also be distributed symmetrically any type of averaging will reduce them. A simple average won't work because of potential analomous behavior(outliers) but taking that into account you'll get a pretty good result(most likely).

If I were you, since you seem concerned with getted the most precise result, I would look into just how much a normal vibrating string deviates from the ideal. You should first know what your up against because it might be impossible to do what you want. (I had a similar problem when trying to do some pitch shifting stuff)

Reply to
Jon Slaughter

formatting link

A "fortnight"? Did you actually say that, in a real conversation? ;-P I like "Don Gilmore, an inventor..." :-)

So, when do we get to hear the .wav of one working?

Thanks, Rich

Reply to
Rich Grise

Sorry. I assumed it was a piano by the description, mostly because I'm familiar with its operation. From the description, the strings in question could be anything from an independently suspended piece of music wire during manufacturing, to any of a number of musical instruments. I can't tell which.

Dunno. As I understand it, any differences in velocity along the wire, at the different frequencies, will cause inharmonicity:

Piano wire is a compromise between external hardness (for that bell like sound) and tensile strength (for the tension required) resulting in some non-linearity. I won't pretend to be an expert on music wire metallurgy, but there appears to be some old books on the subject in reference to affecting inharmonicity.

Well, more measurements are always a good thing. If there's sufficient time, a series of measurements can be made, along with a histogram of the various resonance measurements. That will give a better average for calculating the exact frequency, while also offering a clue if there are any imperfections or variations from a known good reference.

That's why music is an art instead of a science. I found that my abilities in piano tuning was seriously lacking. Yet, I have a friend that's been doing concert piano and does his own tuning for most of his long life. Not only can he tune a piano by ear, but he can also supply the exact notes of any music he hears. I'm jealous. Most people are in between these extremes. Whether an electronic instrument can be built to do this electronically, I'll leave as an exercise for those that still have hair to pull out in frustration.

When the basic accuracy is roughly 1 part in 63 million, we're down in the area where clock oscillator jitter, zero crossing threshold, and front end (microphone and amplifier) noise figure, become important issues. I also suspect that the microphone is capable of generating as many harmonics as it hears, due to it's potential for non-linearity.

I'm sure glad this isn't my headache.

--
# Jeff Liebermann 150 Felker St #D Santa Cruz CA 95060
# 831-336-2558            jeffl@comix.santa-cruz.ca.us
# http://802.11junk.com               jeffl@cruzio.com
# http://www.LearnByDestroying.com               AE6KS
Reply to
Jeff Liebermann

You mention that this is for piano strings, so you really mean overtones. EE's get it pounded into our heads in school that a harmonic is at an exact integer multiple of the fundamental frequency.

You're going to have a big time vs. noise vs. accuracy of measurement problem. Trying to make this work by counting zero crossings or doing FFTs is probably not going to lead to joy, particularly because the sound will decay long before you've collected 1000 seconds worth of sample. You're in a particular bind because you're trying to get (or make) an instrument to compete head to head against one of the things that the human nervous system does very well.

Fortunately, if you can control the noise well, you do _not_ have to measure the thing for 1000 seconds. I'd do this by recording a good long chunk of sound, then doing a best fit of a simulated signal with fundamental + overtones. Once I'd found the best fit I'd look at the frequencies that I used for the overtones, and call it "right".

--
Tim Wescott
Control systems and communications consulting
http://www.wescottdesign.com

Need to learn how to apply control theory in your embedded system?
"Applied Control Theory for Embedded Systems" by Tim Wescott
Elsevier/Newnes, http://www.wescottdesign.com/actfes/actfes.html
Reply to
Tim Wescott

How are you getting infinite sustain time, and how do you keep your infinite sustain from disturbing the overtones?

BTW, I don't think you _need_ the infinite sustain to do your measurement.

--
Tim Wescott
Control systems and communications consulting
http://www.wescottdesign.com

Need to learn how to apply control theory in your embedded system?
"Applied Control Theory for Embedded Systems" by Tim Wescott
Elsevier/Newnes, http://www.wescottdesign.com/actfes/actfes.html
Reply to
Tim Wescott

I didn't write any of the above stuff that's attributed to me.

That makes me not not even wrong.

John

Reply to
John Larkin

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 added headroom.

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

Reply to
Martin Brown

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

Reply to
Ken S. Tucker

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

Reply to
Martin Brown

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

Reply to
Tom Bruhns

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

Just so you guys know I'm serious about this subject, I/we designed this unit,

formatting link

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

Reply to
Ken S. Tucker

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.