Skip to content

Instantly share code, notes, and snippets.

@J2TEAM
Last active August 10, 2021 07:58
Show Gist options
  • Save J2TEAM/d52eba84a041f815dc26f215e7b7546f to your computer and use it in GitHub Desktop.
Save J2TEAM/d52eba84a041f815dc26f215e7b7546f to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="author" content="Jake Albaugh">
<title>JUNO_OKYO</title>
</head>
<body>
<!-- Simple audio playback -->
<audio src="cam.mp3" controls>
Your browser does not support the <code>audio</code> element.
</audio>
<script>
const audio = document.querySelector('audio');
audio.onplay = start;
let l, x, a, d;
function start(e) {
l = ['▁', '▂', '▃', '▄', '▅', '▆', '▇', '█'];
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);
let s = [];
d.forEach(v => s.push(l[Math.floor((v / 255) * 8)]));
location.hash = document.title = s.join('');
}
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment