WaveShaperNode
The WaveShaperNode interface represents non-linear signal distortion effects.
Non-linear distortion is commonly used for both subtle non-linear warming, and more obvious distortion effects.
Constructor
constructor(context: BaseAudioContext, options?: WaveShaperOptions)
WaveShaperOptions
Inherits all properties from AudioNodeOptions.
| Parameter | Type | Default | |
|---|---|---|---|
curve Optional | number[] | Float32Array | - | Initial value for curve. |
oversample Optional | OverSampleType | 'none' | Initial value for oversample. |
You can also create a WaveShaperNode via the BaseAudioContext.createWaveShaper() factory method, which uses default values.
Properties
Inherits all properties from AudioNode.
AudioNodeproperties| Name | Type | Description |
|---|---|---|
curve | Float32Array | null | The shaping curve used for the waveshaping effect. |
oversample | OverSampleType | Specifies what type of oversampling should be used when applying the shaping curve. |
Errors
| Error type | Description |
|---|---|
InvalidStateError | curve has already been set, or the provided curve has fewer than two values. |
Methods
Inherits all methods from AudioNode.
AudioNodemethodsWaveShaperNode does not define any additional methods.
Remarks
curve
- Default value is
null. - Must contain at least two values when not
null. - Can be set only once — either via the constructor
curveoption or by assigning to this property. Subsequent assignments throwInvalidStateError. - The constructor accepts a
number[]orFloat32Array; the property getter always returns aFloat32Arrayornull.
oversample
- Default value is
'none'. - Values of
'2x'or'4x'can increase the quality of the effect, but in some cases it is better not to use oversampling for a very accurate shaping curve.
OverSampleType


Type definitions
// Do not oversample | Oversample two times | Oversample four times
type OverSampleType = 'none' | '2x' | '4x';