Here is a brief explanation of why we hear clicks (this is the human ear) and good examples of how to get around this using the web audio API here: http://alemangui.imtqy.com/blog//2015/12/26/ramp -to-value.html
The main conclusion from the article is that exponential methods for click removal work better; exponentialRampToValueAtTime and setTargetAtTime .
Using setTargetAtTime to remove a click
var context = new AudioContext(); var oscillator = context.createOscillator(); var gainNode = context.createGain(); oscillator.connect(gainNode); gainNode.connect(context.destination) oscillator.start(); stopButton.addEventListener('click', function() { gainNode.gain.setTargetAtTime(0, context.currentTime, 0.015); });
Using exponentialRampToValueAtTime to Remove a Click
var context = new AudioContext(); var oscillator = context.createOscillator(); var gainNode = context.createGain(); oscillator.connect(gainNode); gainNode.connect(context.destination) oscillator.start(); stopButton.addEventListener('click', function() {
Both of them worked for me in my use case, with exponentialRampToValueAtTime working a little better. I still heard a faint click using setTargetAtTime .
source share