-
Notifications
You must be signed in to change notification settings - Fork 172
Description
Describe the feature
If I read the specification right, setting the curve on the WaveShaperNode multiple times is not allowed
https://webaudio.github.io/web-audio-api/#dom-waveshapernode-curve
To set the curve attribute, execute these steps:
Let new curve be a Float32Array to be assigned to curve or null. .
If new curve is not null and [[curve set]] is true, throw an InvalidStateError and abort these steps.
If new curve is not null, set [[curve set]] to true.
Assign new curve to the curve attribute.
Currently however, all browsers seem to allow this. Check for an example here: https://jsbin.com/vagevo/edit?js,output
Some usage in the wild depending on this behaviour
- https://github.com/trys/pedalboard/blob/746041e1d9292cf3ff0d5e69b036c5af6e2f4f12/assets/src/pedals/overdrive.js#L60
- https://github.com/jkyle/austinjs-web-audio/blob/dd064121861fd166ee490d6be99d4f2142da477d/src/Distortion.js#L46
- https://github.com/DanieleCapuano/soundo/blob/2284418bb222ddd6e2d6cd0484eb43084e5cfec1/src/op/WS.js#L66
The web platform tests do not guard for this behaviour. Only a test for setting it back to null is present: https://github.com/web-platform-tests/wpt/blob/90f328adfdbd9ea14a8fc57f042525451980e862/webaudio/the-audio-api/the-waveshapernode-interface/waveshaper-simple.html#L50
To me it seems it would be useful and consistent if the curve could be changed. If we allow users to set it back to null, why not allow it to be set to any other curve? Similar to allowing multiple calls to OscillatorNode.setPeriodicWave
Is there a prototype?
All browsers appear to support this feature (tested on desktop Firefox, Chrome, Safari)
Describe the feature in more detail
Allow updating the curve in the next render quantum after the user has set the new value. This may produce artifacts if the curve is very different from the previous version.