Skip to main content
Version: Next

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.

ParameterTypeDefault
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
NameTypeDescription
curveFloat32Array | nullThe shaping curve used for the waveshaping effect.
oversampleOverSampleTypeSpecifies what type of oversampling should be used when applying the shaping curve.

Errors​

Error typeDescription
InvalidStateErrorcurve has already been set, or the provided curve has fewer than two values.

Methods​

Inherits all methods from AudioNode.

AudioNodemethods

WaveShaperNode 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 curve option or by assigning to this property. Subsequent assignments throw InvalidStateError.
  • The constructor accepts a number[] or Float32Array; the property getter always returns a Float32Array or null.

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';