Skip to content

Instantly share code, notes, and snippets.

@muhibbudins
Created November 11, 2017 02:16
Show Gist options
  • Save muhibbudins/b09f1d0e7e1117c63fd06c71592c99f0 to your computer and use it in GitHub Desktop.
Save muhibbudins/b09f1d0e7e1117c63fd06c71592c99f0 to your computer and use it in GitHub Desktop.
Script for Audio Context Tutorial at my medium account (https://medium.com/@muhibbudins)
function stream() {
const
audio = new(window.AudioContext || window.webkitAudioContext)(),
analyser = audio.createAnalyser();
player.addEventListener('canplay', (e) => {
let source = audio.createMediaElementSource(player);
source.connect(analyser);
analyser.connect(audio.destination);
analyser.fftSize = 128;
frequencyLength = analyser.frequencyBinCount;
let frequency = new Uint8Array(frequencyLength);
analyser.getByteFrequencyData(frequency);
console.log(frequency)
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment