Skip to content

Instantly share code, notes, and snippets.

@amiika
Created January 30, 2026 17:08
Show Gist options
  • Select an option

  • Save amiika/64b8a8266bc816d8207b5bec523eb25b to your computer and use it in GitHub Desktop.

Select an option

Save amiika/64b8a8266bc816d8207b5bec523eb25b to your computer and use it in GitHub Desktop.
Bytebeat in browser console
window.bytebeat = async (f, d=0.2) => {
if (!f) return window.ctx?.close().then(() => { delete window.ctx; delete window.bb; });
window.ctx = window.ctx || new AudioContext();
await window.ctx.resume();
if (!window.bb) {
const c = `registerProcessor('bb', class extends AudioWorkletProcessor {
constructor() { super(); this.t = 0; this.f = t => 0; this.d = 0.2;
this.port.onmessage = e => {
this.d=e.data.d;
try {let n=new Function('t','return '+e.data.f); n(0); this.f=n;} catch(x) { console.error(x) }
}
}
process(_, o) {
let l=o[0][0];
for (let i=0; i<l.length; i++) {
l[i] = ((this.f(this.t|0)&255)-128)/128;
this.t += this.d ;
}
return true;
}
})`;
const u = URL.createObjectURL(new Blob([c], {type: 'application/javascript'}));
await window.ctx.audioWorklet.addModule(u);
window.bb = new AudioWorkletNode(window.ctx, 'bb', {outputChannelCount: [1]});
window.bb.connect(window.ctx.destination);
}
window.bb.port.postMessage({f,d});
};
@amiika
Copy link
Author

amiika commented Feb 14, 2026

  1. Run in browser console to inject bytebeat function
  2. bytebeat("t>>3|(t>>42&t>>6)*t&t>>4+(t>>14&4)") // Run bytebeat
  3. bytebeat("t>>3|(t>>20&t>>10)*t&t+(t>>14&4)") // Update live
  4. bytebeat() // Shut down

@amiika
Copy link
Author

amiika commented Feb 14, 2026

If you try to run this when github page is open you will get error like "Refused to load the script ...". You need to open some other page and open console there. Either some random webpage (Most webpages do not block external scripts) or something running on localhost that is not blocking the script. Note: Start page will also block scripts, so you need to have some webpage open.

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