Skip to content

Instantly share code, notes, and snippets.

@antoninadert
Last active April 18, 2019 13:50
Show Gist options
  • Save antoninadert/f7b3ec2d7c7572b33b662415ccaae849 to your computer and use it in GitHub Desktop.
Save antoninadert/f7b3ec2d7c7572b33b662415ccaae849 to your computer and use it in GitHub Desktop.
Animated waveform in URL and page title (from jake albaugh)
FROM https://twitter.com/jake_albaugh/status/1118656204438482944
var l = ["▁", "▂", "▃", "▄", "▅", "▆", "▇", "█"];
var x = new AudioContext();
var a = x.createAnalyser();
a.fftSize = 32;
var 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("");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment