The problem you are describing is called "Pitch Detection" in the music
world, and the algorithms use in commercial equipment in recent years
are getting pretty good at PD. There are various algorithms that
provide various approaches to PD.
Wikipedia has some info on the problem:
http://en.wikipedia.org/wiki/Pitch_detection_algorithm
Here's an overview paper on various PD methods:
http://www-ccrma.stanford.edu/~pdelac/154/m154paper.htm
Here's a PD technique using autocorrelation:
http://cnx.org/content/m11714/latest/
This gadget listens to your voice, detects the pitch, and adds vocal
harmonies to it.
http://www.tc-helicon.com/VoiceWorksPlus
This gadget listens to your guitar chords and produces harmony to your
singing voice.
http://www.digitech.com/products/Vocalist_Live2/
The Band-in-a-Box software can listen to recorded music, figure out the
chords being played using PD, generate a MIDI file from the notes, and
write out the music notes being played! This software has been around
for 15 years, and is continually improved every year The Pitch Detection
stuff has only been added in the last couple of years. BB is one of the
most interesting commercial music synthesis/development packages out
there. BB can take a chord progression you specify, and generate a tune
to fit it. Or take any tune and play it in a specific style (waltz,
cha-cha). Or harmonize with your real-time improvisation on a tune. All
for $99.
http://www.pgmusic.com/
Skip
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm