How t开发者_JAVA技巧o detect music note and chords programmatically (in iPhone SDK) ??
You would need to do a Fourier transform (usually a FFT) of the incoming sound wave and find the dominant frequency, then look up that frequency in a table of notes with their corresponding frequencies.
FFT is part of iOS since iOS4 and is located in the Accelerate framework.
Look at this other SO thread for more info and sample code.
To detect a chord is done by the same principle, but it's much trickier, since you need to find all the notes that make up the chord.
精彩评论