Skip to content

WaveShaperNode: allow updating the curve #2655

@orottier

Description

@orottier

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

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Needs DiscussionThe issue needs more discussion before it can be fixed.category: new featureSubstantive changes that add new functionality. https://www.w3.org/policies/process/#class-4

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions