javascript-oscillator

(Web Audio API) Oscillator node error: cannot call start more than once

我的未来我决定 提交于 2019-12-30 03:50:29
问题 When I start my oscillator, stop it, and then start it again; I get the following error: Uncaught InvalidStateError: Failed to execute 'start' on 'OscillatorNode': cannot call start more than once. Obviously I could use gain to "stop" the audio but that strikes me as poor practice. What's a more efficient way of stopping the oscillator while being able to start it again? code (jsfiddle) var ctx = new AudioContext(); var osc = ctx.createOscillator(); osc.frequency.value = 8000; osc.connect(ctx