Skip to content

Instantly share code, notes, and snippets.

@quimbs
Last active August 29, 2015 14:17
Show Gist options
  • Save quimbs/44f68f011c2c36690f2e to your computer and use it in GitHub Desktop.
Save quimbs/44f68f011c2c36690f2e to your computer and use it in GitHub Desktop.
Sample of usage of MediaStream as an input to an AnalyserNode in WebAudio API
var analyserAudioNode, sourceAudioNode, micStream;
var streamReceived = function(stream) {
micStream = stream;
analyserAudioNode = audioContext.createAnalyser();
analyserAudioNode.fftSize = 2048;
sourceAudioNode = audioContext.createMediaStreamSource(micStream);
sourceAudioNode.connect(analyserAudioNode);
/* This is our pitch detection algorithm.
You can find its implementation in the Autocorrelation section of this demo. */
detectPitch();
};
navigator.getUserMedia({audio: true}, streamReceived);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment