0
votes

I want to capture sound from mic or other input device and to store that data in the array and after that analize it with FFT using javascript, searched tons of sites and topics, couldn't find anything useful

1
With pure JavaScript? No way. Perhaps some integration with a Flash makes it possible. - Havenard
@Havenard that's what I'm trying to avoid, is there some other way to do that not using a java applet / Flash ? - Yuriy Kravets
take a look here. html5rocks.com/en/tutorials/getusermedia/intro few browsers support audio(/video) capture. I don't know if you can manage the captured media with js, I don't think. Anyway the link I agave you is a good point to start investigate - Paolo
It's draft etc. But i think you're looking for WebRTC webrtc.org - Marvin Smit

1 Answers

1
votes

Sure you can, the API also provides an FFT analyzer (but only for live audio streams). It's called Web Audio API and is currently a draft, but is well supported by WebKit (you'll need to use prefixes) and a little less by Gecko. Look also http://caniuse.com/#feat=audio-api.

To get microphone audio, you'll need to use the getUserMedia method, defined in the Media Capture and Streams draft, once you get the MediaStream you can create a MediaStreamAudioSourceNode, and attach it to the other nodes. To record audio samples, I'd suggest to try ScriptProcessorNode, the other useful node is the Analyzer node.

Here is a little experiment I did some months ago, I tried it only on Chrome, but should work with any WebKit browser. It basically takes the microphone audio stream and passes it to an analyzer node, which performs every frame (screen frame) an FFT, which is draw on the canvas and use to determinate the note (you only have to set the threshold with a mouse click anywhere on the canvas). Then the guessed note is reproduced on an oscillator node.