descriptinc / web-audio-js

Pure JS implementation of the Web Audio API
60 stars 8 forks source link

Two bug fixes around BiquadFilterNode (and other nodes) #8

Closed marcello3d closed 4 years ago

marcello3d commented 4 years ago

Initialize new BiquadFilterKernels with existing Node coefficients

This bug arises when the number of channels increases during playback. BiquadFilterNode creates a new BiquadFilterKernel for each channel, but it doesn't initialize the coefficients correctly (so they stay at [0,0,0,0,0] and produce silence).

Fix AudioNode delayed disable race condition

When AudioNode.disableOutputsIfNecessary is called, it calls this.getTailTime() which can returns a "delay" time before the node is actually disabled. This is 0 for most nodes, but has a value for BiquadFilterNode and DelayNode (and Infinity for ScriptProcessorNode).

If the the node is enabled again within that time, we need to clear the disable countdown (this is the bug fix).

(Also rename "suicideAtSampleFrame" to "disableAtSampleFrame" because it's a crude name and it isn't even accurate.)

Testing