Last active
August 10, 2021 07:58
-
-
Save J2TEAM/d52eba84a041f815dc26f215e7b7546f to your computer and use it in GitHub Desktop.
A URL-based graphic eq (demo: https://www.facebook.com/J2TEAM.ManhTuan/videos/1346181608854508/)
This file contains 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
<!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