I am interested in determining the musical key of an audio sample. How would (or could) an algorithm go about trying to approximate the key of a musical audio sample?
<
It's a complex topic, but a simple algorithm for determining a single key (single note) would look like this:
Do a fourier transformation on let's say 4096 samples (exact size depends on your resolution demands) on a part of the sample which contains the note. Determine the power peak in the spectrum - this is the frequency of the note.
Things are getting tighter if you have a chord, different "instruments/effects" or a non-homophonic music pattern.