Skip to content

Instantly share code, notes, and snippets.

@wchargin
Created July 2, 2024 22:38
Show Gist options
  • Save wchargin/cd9a41195d463d871f401f7e744ac12b to your computer and use it in GitHub Desktop.
Save wchargin/cd9a41195d463d871f401f7e744ac12b to your computer and use it in GitHub Desktop.
bookmarklets for audio manipulation (speed and panning)
javascript:((pan) => { if (!window.__wcharginPanState) { const ctx = new AudioContext(); const panner = new StereoPannerNode(ctx); panner.connect(ctx.destination); const vsrcSymbol = Symbol("mediaSourceOutput"); window.__wcharginPanState = { ctx, panner, vsrcSymbol };}; const {ctx, panner, vsrcSymbol} = window.__wcharginPanState; for (const video of document.querySelectorAll("video")) { if (!video[vsrcSymbol]) { video[vsrcSymbol] = ctx.createMediaElementSource(video); video[vsrcSymbol].connect(panner); } } panner.pan.value = pan; })(Number(prompt("pan? (-1 to 1)")));
javascript:(function() { const r = prompt("New playback rate? Was: " + (document.querySelector("video") || {playbackRate: null}).playbackRate); if (r == null) return; for(const v of [...document.querySelectorAll("video"), ...document.querySelectorAll("audio")]) v.playbackRate = Number(r) || 1.0; })();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment