Skip to content

Instantly share code, notes, and snippets.

@Jbithell
Created April 18, 2019 10:27
Show Gist options
  • Save Jbithell/8da16c2591be05cc22c186eec8260dc8 to your computer and use it in GitHub Desktop.
Save Jbithell/8da16c2591be05cc22c186eec8260dc8 to your computer and use it in GitHub Desktop.
Graphical EQ based on a tweet
<script>
//https://twitter.com/jake_albaugh/status/1118611365508337665
var l = ["▁", "▂", "▃", "▄", "▅", "▆", "▇", "█"];
var x;
var a;
var d;
document.onclick = function () { //jb edit to work with chrome 70
x = new AudioContext();
a = x.createAnalyser();
a.fftSize = 32;
d = new Uint8Array(16);
navigator.mediaDevices.getUserMedia({ audio: true }).then(s => {
x.createMediaStreamSource(s).connect(a);
z();
});
};
function z() {
setTimeout(z, 40);
a.getByteFrequencyData(d);
var s = [];
d.forEach(v => s.push(l[Math.floor((v / 255) * 8)]));
location.hash = document.title = s.join("");
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment