Created
June 11, 2019 06:59
-
-
Save vitaliy-bobrov/6b62630ee54a1c299302c8ef8d891d4c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const control = document.querySelector('.gain-control'); | |
control.addEventListener('change', (event) => { | |
const parsed = parseFloat(event.target.value); | |
const value = Number.isNaN(parsed) ? 1 : parsed; | |
const clamped = clamp(value); | |
gainNode.gain.setTargetAtTime(clamped, context.currentTime, 0.01); | |
}); | |
function clamp(min, max, value) { | |
return Math.min(Math.max(value, min), max); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment