How to measure the frequency of a person humming?

In summary, the conversation revolves around a project to determine the musical note of someone humming by using a microphone, amplifier, and bandpass filter. The question of using FFT to determine the frequency of the fundamental is raised, and the concept of FFT is explained in layman's terms. It is also suggested to use a DFT implementation for better accuracy. The conversation also discusses the potential problems with counting the number of zero crossings and the need for a good quality microphone and amplifier. Additionally, it is mentioned that someone has successfully built a guitar tuner using a similar approach and it is recommended to explore this option further.
  • #1
gotem3303
29
0
Im currently enrolled in embedded systems (so bare with me, I am not too experienced) and we had to come up with a final project for ourselves. Well, I would greatly appreciate some help in understanding some concepts of DSP.

I am working with the freescale DEMOACKIT with the coldfire MCF51AC256.

My project will have someone hum into a microphone, and output to a display the musical note that person was humming.

I want to know if I could get by accomplishing this by amplifying the microphone output, putting it through a bandpass filter, then counting the number of zero passes and determing the frequency of the note that way. Would this work? I am not going for dead on accuracy everytime I use the device, as long as it gets it right most of the time I would be very happy. But, if there is a better way that is doable for me that would get me 100% accuracy, or close to it, I would definitely try.

Would there be a better way? Again, I am very new to the subject, especially DSP, so layman's terms would be very helpful!
 
Engineering news on Phys.org
  • #2
Why not simply use FFT to determine the frequency of the fundamental?
 
  • #3
f95toli said:
Why not simply use FFT to determine the frequency of the fundamental?

Every time I see a topic on finding frequencies I see someone suggest FFT. However, I have no clue how to do this. I'm trying to do some research on this but it seems very complicated, because up until 2 days ago I never even knew it existed.

Can you explain to me what a FFT actually does in layman's terms? What exactly is involved in doing a FFT on an incoming signal? Would counting the number of zero crossings not work as an estimate of the pitch? Even if I were to average?
 
  • #4
The Fast Fourier transform is only a way of doinh the Discrete Fourier Transfrom quickly.
Learning about the FFT isn't useful until you know what the DFT does. I recommend the wolfram page about it:

http://mathworld.wolfram.com/DiscreteFourierTransform.html"

Also look at the Fourier transform page.
 
Last edited by a moderator:
  • #5
Why would counting the number of zero crossings not work? Just wondering
 
  • #6
Why would counting the number of zero crossings not work? Just wondering

It would work OK. Just amplify it and feed it into a frequency counter.

If you have one, you should observe the output of your amplifier on an oscilloscope to verify that there isn't enough mains hum (60 Hz or 120 Hz) in the waveform to matter.

You can also estimate the frequency by using the oscilloscope calibrations. eg 5 mS is the period of a 200 Hz waveform.

Also, you need to find a good quality microphone and amplifier. Humming is low frequency sound and this is not detected or amplified well with cheap equipment.
Even then, the person humming should be very close to the microphone.
 
  • #7
vk6kro said:
Why would counting the number of zero crossings not work? Just wondering

It would work OK. Just amplify it and feed it into a frequency counter.

If you have one, you should observe the output of your amplifier on an oscilloscope to verify that there isn't enough mains hum (60 Hz or 120 Hz) in the waveform to matter.

You can also estimate the frequency by using the oscilloscope calibrations. eg 5 mS is the period of a 200 Hz waveform.

Also, you need to find a good quality microphone and amplifier. Humming is low frequency sound and this is not detected or amplified well with cheap equipment.
Even then, the person humming should be very close to the microphone.


Can you recommend a good microphone and amp I could use?

Also, if I build this and find I have a lot of mains hum messing with my results, how could I fix it?
 
Last edited:
  • #8
gotem3303 said:
Why would counting the number of zero crossings not work? Just wondering

It has problems because the amount of harmionics present in "humming" can be large so you actually have a waveform that's more complex than a simple sine wave. As a result you'll often count several zero crossings per cycle of fundamental unless you bandpass filter first. Now there's the problem that the humming frequency may vary considerably from sample to sample so you don't know (apriori) at what frequency to filter.

The bottom line is that you might be better off to use a DFT implementation. BTW, several years ago I built a guitar tuner using exactly this procedure and it works quite well. It also works for other instruments including "humming". :)
 
  • #9
uart said:
It has problems because the amount of harmionics present in "humming" can be large so you actually have a waveform that's more complex than a simple sine wave. As a result you'll often count several zero crossings per cycle of fundamental unless you bandpass filter first. Now there's the problem that the humming frequency may vary considerably from sample to sample so you don't know (apriori) at what frequency to filter.

The bottom line is that you might be better off to use a DFT implementation. BTW, several years ago I built a guitar tuner using exactly this procedure and it works quite well. It also works for other instruments including "humming". :)

Thats cool man! So you basically used a microphone, amplified it, sent it through a bandpass filter, and perfromed a FFT on the signal, and that's where you analyzed the signal in your processor to see what note its in?

BTW, how hard was it to implement this device? Would you recommend a DFT approach for someone new to embedded systems? Or should I maybe stick with the zero crossings, even though it may not be as accurate? Did you have to manually write the DFT algorithm or was there already a C implementation written up for you somehwere that you found? How accurate is your device? I would love to learn how you accomplished this.
 
  • #10
Measuring the frequency of someone humming is amusing for about 10 seconds and then you start whistling and this gets boring after about a minute.

So, I'd suggest you go with whatever microphone or amplifier you can get hold of easily.

You might have access to an old tape deck. These had microphone inputs and line outputs and were often excellent quality. Some of them even came with matching microphones.

Nobody wants them because the belts in the tape decks have rotted, but the amplifiers probably still work.
 
  • #11
One way is to use a simple modulator circuit like in the thumbnail. Be sure to set the resistors to operate the transistors in the linear region. Use headphones to listen to the output. Use a signal generator to give about a volt on the emitter of the top transistor. Use a microphone to provide the hummer signal to lower transistor. Now, Adjust the signal generator frequency and beat the hummer with the signal generator until the beat frequency goes to zero.
Bob S
 

Attachments

  • Modulator_ckt.jpg
    Modulator_ckt.jpg
    30.2 KB · Views: 477
  • #12
Here is another solution. I have a free program named Audacity installed on my computer. It has a microphone input (as well as other inputs), and is able to record analog audio streams digitally. It also has a FFT transform built in and can plot frequency spectrums (spectra?).
Bob S
 
  • #13
Good idea.

I have a computer program called Spectran which gives a direct readout of the strongest audio frequency it is receiving. It doesn't matter if other signals or harmonics are present.

This program is available, free, from:
http://www.sdrham.com/spectran.html
 
  • #14
The freeware Matlab clone, Scilab, is wonderful at showing all the harmonics but takes a lot more effort to get working than Audacity (I used scilab to determine the fundamental resonant frequency of the body of my guitar).
 
  • #15
There is a really good demonstration of the way Fourier series work at this link:
http://www.falstad.com/fourier/
The link provides a Java applet which allows the viewer to play with the amplitudes of the sin and cos harmonics so they can see what is going on.
 
  • #16
gotem3303 said:
Would you recommend a DFT approach for someone new to embedded systems? Or should I maybe stick with the zero crossings, even though it may not be as accurate?

It's hard to say, you might be able to get the zero crossing method to work reliably enough if you normalize the amplitude and apply enough hysteresis to avoid "double crossings". Whether or not you'd choose an FFT implementation would also depend on the availability (or otherwise) of floating point operations on your embedded system. FFT is definitely a lot easier if floating point is available.

Though your target implementation is the embedded system there is no reason why you can't experiment with algorithms etc with just your PC and some basic waveform editor software. You should try capturing some humming samples on soundcard and take a look at what you're up against. Do you have matlab? If not then download one of the freeware "clones" like "gnu octave".

Here's an example for you. I hummed into my (headset) microphone and captured a few seconds in a waveform editor. My professional guitar tuner told me it was "A" at about 20% of a semitone flat, which equates to approx 145 Hz. Attached is an approx 0.5 second sample of the raw waveform (sampled at 44100Hz) along with a plot of the both time domain and FFT signals.

As you can see, from the FFT it is very easy to identify the correct frequency of about 145Hz (along with copious 2nd and 3rd harmonics). A simple zero crossing analysis of the raw data however returned a count of 263 zero crossing corresponding to an incorrect frequency reading of about 259 Hz.
 

Attachments

  • time_domain.jpg
    time_domain.jpg
    35.4 KB · Views: 494
  • FFT.jpg
    FFT.jpg
    16.2 KB · Views: 394
  • hmm.zip
    37.4 KB · Views: 235
  • #17
uart said:
It's hard to say, you might be able to get the zero crossing method to work reliably enough if you normalize the amplitude and apply enough hysteresis to avoid "double crossings". Whether or not you'd choose an FFT implementation would also depend on the availability (or otherwise) of floating point operations on your embedded system. FFT is definitely a lot easier if floating point is available.

Though your target implementation is the embedded system there is no reason why you can't experiment with algorithms etc with just your PC and some basic waveform editor software. You should try capturing some humming samples on soundcard and take a look at what you're up against. Do you have matlab? If not then download one of the freeware "clones" like "gnu octave".

Here's an example for you. I hummed into my (headset) microphone and captured a few seconds in a waveform editor. My professional guitar tuner told me it was "A" at about 20% of a semitone flat, which equates to approx 145 Hz. Attached is an approx 0.5 second sample of the raw waveform (sampled at 44100Hz) along with a plot of the both time domain and FFT signals.

As you can see, from the FFT it is very easy to identify the correct frequency of about 145Hz (along with copious 2nd and 3rd harmonics). A simple zero crossing analysis of the raw data however returned a count of 263 zero crossing corresponding to an incorrect frequency reading of about 259 Hz.

Wow, interesting results. It definitely seems like doing an FFT on the signal would be the best way to go about this. Thank you for those images.

Does anyone know of a place I can see samples of actual FFT code performed on some sort of signal? I am trying to learn as much as I can about this process right now, but I have to have this done in about 5 weeks, and this is pretty complicated by what I've seen so far. I would love to actually see something written out so I can actually see it rather than try to conceptualize it all.
 
  • #18
What level of 'code' do you want to see? I could direct you to the example files for FFT on 'Scilab', which you could download and install in half an hour. The example routine first makes a signal out of trig functions, then analyses it using the FFT. You'd see how the syntax of the application works and be able to apply it to your your own .wav files.
If this sounds like what you want simply download the appliction (very easy to find on the web) and start hacking. Please feel free to contact me personally and tell me how you're getting on, since I know that it took me some time to learn this software and I expect it'll be the same for you.
 
  • #19
Well I am using CodeWarrior with Processor Expert for my project and learned that Processor Expert actually has a FFT bean! Which is good news for me, but only after I actually learn a little more about the transformation.

When performing a FFT on the data I'm feeding in from the microphone, would I be performing a Real forward FFT? I have 4 choices of Real forward, real backward, complex forward, or complex backward.

Also, the FFT bean I have performs the Fast Hartley transform. Is this the one I should be using?
 
Last edited:
  • #20
A forward fft takes you from time domain to frequency domain, the backward fft takes you the other way.
I wonder whether the 'complex' options require 2 arguments (real, imaginary) in each channel of signal? Though I'm rather sticking my neck out here I'd say you have only the option of 'real' analysis on your single-channel signal.
Fast Hartley?
 
  • #21
As you can see, from the FFT it is very easy to identify the correct frequency of about 145Hz (along with copious 2nd and 3rd harmonics). A simple zero crossing analysis of the raw data however returned a count of 263 zero crossing corresponding to an incorrect frequency reading of about 259 Hz.

I've owned a few frequency counters and built a few more and I have never seen one that counted zero crossings.
Invariably, the input signal drives a counter chip or a gate and these operate below a certain level for a zero and above another level for a 1. These might be below 1 volt for a Zero and above 4 volts for a 1.

If you have one that uses zero crossings, don't use it. It would give oddball readings.

Also, don't overdrive a frequency counter. Small harmonic bumps can get big enough to get counted on their own.
 
  • #22
vk6kro said:
As you can see, from the FFT it is very easy to identify the correct frequency of about 145Hz (along with copious 2nd and 3rd harmonics). A simple zero crossing analysis of the raw data however returned a count of 263 zero crossing corresponding to an incorrect frequency reading of about 259 Hz.

I've owned a few frequency counters and built a few more and I have never seen one that counted zero crossings.
Invariably, the input signal drives a counter chip or a gate and these operate below a certain level for a zero and above another level for a 1. These might be below 1 volt for a Zero and above 4 volts for a 1.

If you have one that uses zero crossings, don't use it. It would give oddball readings.

Also, don't overdrive a frequency counter. Small harmonic bumps can get big enough to get counted on their own.

Yes of course that naive zero crossing example I gave was simply to point potential pitfalls of counting frequency.

"These might be below 1 volt for a Zero and above 4 volts for a 1." Yes that's exactly equivalent to having some "hysteresis" like a Schmitt trigger before the zero crossing detector. That is what I was suggesting to the OP. I showed the waveform will a simple ZC detector to demonstrate why it's needed. :) As I pointed out earlier you need to control the waveform amplitude in relation to the hysteresis thresholds in order to make that work reliably.
 
  • #23
Yes I am definitely going to go the FFT route with this project. Even though it seems a lot harder because I'm having to learn a complex subject in a very limited amount of time, I think I'll be able to. Plus hopefully it will turn out to do exactly what I want it to do. Thats alway nice :)

So Ill definitely be doing a real forward FFT on my signal correct? And is the Fast Hartley okay for this?

So, just to do a little flow chart real quick, the signal will be coming in through the microphone. I will then pass it through an amplifier, probably an LM358?. I will then pass it through a bandpass filter (this is necessary correct?), and then pass that to the ADC in my processor. I will then fill an array with a lot of samples from the inputted sound, and after its filled will pass it through the FFT and out comes a frequency. Then all I need to do is have a bunch of conditions to match the frequency to an A or B or whatever, then output the result to my screen.

Am I missing something?
 
  • #24
Last edited:

1. How do I measure the frequency of a person humming?

To measure the frequency of a person humming, you will need a device called a frequency counter. This device measures the number of vibrations per second, or hertz (Hz), in a sound wave. Simply have the person hum into the device and it will display the frequency.

2. Can I use a regular microphone to measure the frequency of a person humming?

No, a regular microphone is not designed to measure frequency. It is designed to pick up and amplify sound. You will need a specific frequency counter to accurately measure the frequency of a person humming.

3. What is the ideal range of frequency for a person humming?

The ideal range of frequency for a person humming is typically between 100 Hz to 1500 Hz. This range may vary slightly depending on the person's vocal range and pitch.

4. How does the frequency of a person humming change with age?

The frequency of a person humming typically decreases with age. This is due to changes in vocal cords and muscles as we age, resulting in a lower pitch and frequency when humming.

5. Can I measure the frequency of a person humming without a device?

No, it is not possible to accurately measure the frequency of a person humming without a frequency counter or other specialized equipment. Humming produces a low volume and subtle sound, making it difficult for the human ear to distinguish the frequency. A device is needed to accurately measure and display the frequency.

Similar threads

Replies
10
Views
454
  • Electrical Engineering
Replies
12
Views
1K
  • Electrical Engineering
Replies
8
Views
2K
  • Electrical Engineering
Replies
12
Views
1K
  • Electrical Engineering
Replies
6
Views
843
Replies
14
Views
2K
  • Electrical Engineering
2
Replies
41
Views
4K
  • Electrical Engineering
Replies
27
Views
1K
Replies
8
Views
2K
Replies
5
Views
4K
Back
Top