Skip to content

Instantly share code, notes, and snippets.

@rileyjshaw
Created April 18, 2019 06:04
Show Gist options
  • Save rileyjshaw/722a5dfbac901f9d236c353181f0a7e2 to your computer and use it in GitHub Desktop.
Save rileyjshaw/722a5dfbac901f9d236c353181f0a7e2 to your computer and use it in GitHub Desktop.
ascii equalizer based on https://twitter.com/jake_albaugh/status/1118611365508337665; trying to fit this into a single tweet (280 characters)
n=(l='▁▂▃▄▅▆▇█'.split(''),x=new AudioContext(),d=new Uint8Array(16),a=x.createAnalyser()).fftSize=32
navigator.mediaDevices.getUserMedia({audio:1}).then(s=>{x.createMediaStreamSource(s).connect(a)
setInterval(_=>{a.getByteFrequencyData(d)
location.hash=[...d].map(v=>l[0|v/n]).join('')},n)})
@rileyjshaw
Copy link
Author

Warning: this really thrashes your browser history. Consider replacing location.hash with document.title before running.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment