Skip to content

Instantly share code, notes, and snippets.

@mr21
Created September 28, 2019 02:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mr21/e11513ff8219ccf92fa1b088ed434f69 to your computer and use it in GitHub Desktop.
Save mr21/e11513ff8219ccf92fa1b088ed434f69 to your computer and use it in GitHub Desktop.
var vid = document.querySelector( "video" );
var audioCtx = new AudioContext();
var source = audioCtx.createMediaElementSource( vid );
var compressor = audioCtx.createDynamicsCompressor();
var now = audioCtx.currentTime;
compressor.threshold.setValueAtTime( -50, now );
compressor.knee.setValueAtTime( 40, now );
compressor.ratio.setValueAtTime( 32, now );
compressor.attack.setValueAtTime( 0, now );
compressor.release.setValueAtTime( .25, now );
source.connect( compressor );
compressor.connect( audioCtx.destination );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment