Skip to content

Instantly share code, notes, and snippets.

View Kiser360's full-sized avatar

Devin Kiser Kiser360

View GitHub Profile
@westc
westc / createAmplifier.js
Last active January 8, 2023 22:18
Function that can be used to amplify the volume of a media element (<audio> or <video>).
function amplifyMedia(mediaElem, multiplier) {
var context = new (window.AudioContext || window.webkitAudioContext),
result = {
context: context,
source: context.createMediaElementSource(mediaElem),
gain: context.createGain(),
media: mediaElem,
amplify: function(multiplier) { result.gain.gain.value = multiplier; },
getAmpLevel: function() { return result.gain.gain.value; }
};