Client-side Microphone Analysis of Notes
So I'm hoping to build an RIA that allows for the analysis of audio streaming from a user's microphone at any given point in time so I can detect what note this is. I think I ca开发者_Python百科n do the note detection with the frequency fairly easily but this kind of on-the-fly processing seems impossible in flash (my preferred choice) and I haven't found much on it I can understand in the form of a java applet (less preferred but ok).
Can anyone point me in the right direction? Is there any way to do it in flash without huge lag by sending it to my server and back? If not, how can I do it in Java?
Thanks
You can use the SoundMixer to compute the spectrum. To detect the actual pitch you need further processing of the spectrum.
SoundMixer.computeSpectrum(ba,true,0);
http://en.wikipedia.org/wiki/Pitch_detection_algorithm
With the frequency spectrum you can do that in ActionScript on the client side. Computation is easy so it won't bother the user.
You might want to look at my spectrum analyzer code as well. https://gerrybeauregard.wordpress.com/2010/08/06/real-time-spectrum-analysis/ It uses the FFT class and real-time microphone input. To make a really simple pitch detector, you can just find the highest peak in the magnitude spectrum, and do a quadratic interpolation of the peak and the bins on either side to get sub-bin frequency resolution. Using the highest peak works fine if you're trying to identify single notes, and the instruments overtone structure is such that the fundamental is the strongest harmonic (which is often the case).
精彩评论