Search code examples
javascriptaudioweb-audio-apifrequency-analysis

Simple code to calculate frequency of Live Mic Audio using WebAudio API


I have website in which I need to display the frequency of the Live Mic Audio. I have a this code, but its extremely difficult to understand (It uses Fourier Transform and all). On some research I got to know of getByteFrequencyData() which returns the frequency of the audio. Has anyone used it before with Live Mic Audio preferably in Web Audio API?


Solution

  • "Displaying the frequency" can mean many things. Actually, my PitchDetect demo DOESN'T use a Fourier Transform - it uses autocorrelation. But that will only give you a single pitch, at high accuracy. If your signal has multiple simultaneous notes - well, that's a hard problem.

    If you want to see a frequency analysis breakdown of the live mic input, check out http://webaudiodemos.appspot.com/AudioRecorder/index.html (code at https://github.com/cwilso/AudioRecorder). That uses the built-in FFT in the RealtimeAnalyser to show a frequency spectrum graph of a live audio signal.