Determine Frequency of an Audio Signal

Hello,

I would like to be able to determine the frequency of a sound (e.g., a simple audible sine wave) using a piezo buzzer or some other simple microphone apparatus. For example, it would be nice to get a scalar output, like the number "440" Hertz, for a "middle-A" note.

Any ideas would be greatly appreciated.

Read this post for frequency counter Lib and work from there
http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1231326297

No piezo buzzer. They are tailored to work at one frequency (usualy around 44kHz). Look at a microphone. You can find at Sparkfun (or any other) a small board with a mike and an amplifier.

But don't forget, in real life you rarely encounter pure sine wave.

No piezo buzzer. They are tailored to work at one frequency (usualy around 44kHz)

A 44KHz buzzer will only be of interest to dogs and bats, that is over the hearing range. He probably means piezo transducer that can act as a microphone or a buzzer, these resonate at about 2.5KHz and while they are useful for detecting a impact like a drum they are not very useful for sin waves.
A microphone is the way to go but as you say real life has few sin waves and the othe stuff you get makes this not a simple project.

what about a fast-fourier transform for detecting the approximate frequencies of a sound?

There is an Avr FFT here (Audio Spectrum Monitor) and a chain here about detetcting guitar freqency. (http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1210554551)

Won't be exact (and may take all the memory of the AVR), but ...

Yeah, I was thinking of a piezo transducer or "contact mic" when I said "piezo buzzer"...but it looks like microphones will work best, so I'll look further into that option.

My goal is to basically have a little robot creature that receives sine wave signals through its microphone, processes the sound's frequency through its black box, and outputs a new sine wave signal based on the frequency of the sine wave that it received into its microphone.

I know there may be issues with acoustical interferences in the room, etc. but the signals that it receives will be transmitted as pure sine waves, and I think the only reason I might ever need to do a fast-Fourier transform would be to extract the fundamental frequency of the sound, and if the integrity of the "sine wave transmitter/speaker" and "sine wave receiver/microphone" are good nuff, then I should be OK not doing the FFT??

I still think it would be hard to do that very reliably in code without FFT...

You could analogread until you find a peak of the wave, then analogread until you find the valley of the wave, and then measure the time diff - and magically have half a sine-wave.

But, I don't know if the arduino is fast enough at human audible frequencies, nor if you could reliably do that with the feedback from the robot itself - assuming the A/D could do it cleanly.

I guess one could probably test that with a pot, varying the resistance quickly left-to-right-to-left to test that theory while debugging...

Interesting project!

Hmm, perhaps I should look into a different approach?

I should mention that this is a year-long project that I am starting for my undergraduate thesis, and I plan on building as many of these creatures as possible so that they can interact socially and produce interesting dynamics. I wanted the collective emergent dynamic to sound "musical", so the "black box" I mentioned earlier would be some kind of musical scale explorer that would decide (probabilistically?) which notes Creature A should chirp out after listening to the notes chirped by the surrounding Creatures B, C, D, E, F, etc. I would not want the creatures to chirp simultaneously, so I'd need to figure out timing, and I would want them to cluster together by gravitating towards the loudest (nearest) neighbor. I realize this might not be easy, so I am trying to see what will be feasible.

I don't know if it would be easy to have an arduino (say, "Arduino A") committed solely to doing the Fourier transform, while being coupled to another arduino ("Arduino B") that would do additional processing (with the info processed by Arduino A).

Another idea comes to mind... If I avoid audio inputs (microphone) completely and instead, transmit the information through WiFi or infrared. That is to say, the creature will receive only radio/WiFi information (no audio information), but this information will convey to the creature that she is "hearing" an "A" note or whatever, and it will in-turn process this information followed by the output an audible signal (say, a "C" note) AND the corresponding radio signal conveying that a "C" note was just chirped. So the human observers will hear an "A" note and the creatures response to it (a "C" note), but really there is "extra-sensory" communication (WiFi) going on between the creatures.

Sorry for such a lengthy response and problem. I appreciate all the help I've gotten thus far.

If you got your creatures the chirp DTMF, you could use ready-made decoders, or have a look at Goertzel's Algorithm.

Hi,

you could use a varicap to create a resonator that sweeps its resonancy frequency from 20hz to 20Khz (or you could also reduce the range...if no varicap is able to change its capacity so much).

You can "pilot" the varicap using one of the pwm pin, sweep along the range, using the analog input pin to detect which is the frequency with the maximum response from the resonator.

This in theory should work...