Skip to content

Instantly share code, notes, and snippets.

@Deliaz
Created June 14, 2017 08:42
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 Deliaz/a62265a8bf7c177cb8b52eee4bb19698 to your computer and use it in GitHub Desktop.
Save Deliaz/a62265a8bf7c177cb8b52eee4bb19698 to your computer and use it in GitHub Desktop.
Just some tips apply filters to an audio from video stream
// # 1st way
var context = new AudioContext();
var source = context.createMediaElementSource(document.querySelector('.video-stream.html5-main-video'));
//Now we want to create a filter
var filter = context.createBiquadFilter();
source.connect(filter); //and of course connect it
filter.type = "highshelf"; //this is a lowshelffilter (try excuting filter1.LOWSHELF in your console)
filter.frequency.value = 200; //as this is a lowshelf filter, it strongens all sounds beneath this frequency
filter.gain.value = 50; //the gain with which it should increase
//now we want to connect that to the output
filter.connect(context.destination);
// # 2nd way
var context = new AudioContext();
var source = context.createMediaElementSource(document.querySelector('.video-stream.html5-main-video'));
var gainNode = context.createGain();
gainNode.gain.value = 10;
source.connect(gainNode);
gainNode.connect(context.destination);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment