Created
November 11, 2017 02:16
-
-
Save hibuno/b09f1d0e7e1117c63fd06c71592c99f0 to your computer and use it in GitHub Desktop.
Script for Audio Context Tutorial at my medium account (https://medium.com/@muhibbudins)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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