A sound rarely has only one frequency. Only a pure sine wave sound has a single frequency. If you sing a certain note then the sound you produce contains a whole range of frequencies.
You could find out the
frequency spectrum of a sound by doing spectrum analysis, for example by using an
FFT. Advanced digital signal processing algorithms like that are not built-in in the standard Java API, but if you really want to do this, then you can find Java implementations of the FFT online.
Once you have the frequency spectrum of a piece of sound, you could detect what the dominant frequency in the sound is. I don't know how you'd have to do that - it might not be as simple as looking at the highest peak in the spectrum.
[ April 18, 2007: Message edited by: Jesper Young ]