Tone.WaveShaper

↳ EXTENDS Tone.SignalBase

Wraps the native Web Audio API WaveShaperNode.

CONSTRUCTOR

new Tone.WaveShaper (
mapping
, [
bufferLen
= 1024 ] )
mapping

The function used to define the values. The mapping function should take two arguments: the first is the value at the current position and the second is the array position. If the argument is an array, that array will be set as the wave shaping function. The input signal is an AudioRange [-1, 1] value and the output signal can take on any numerical values.

type: function or Array or Number
bufferLen

The length of the WaveShaperNode buffer.

type: Number
default: 1024

EXAMPLE

var timesTwo = new Tone.WaveShaper(function(val){
	return val * 2;
}, 2048);
 

EXAMPLE

//a waveshaper can also be constructed with an array of values
var invert = new Tone.WaveShaper([1, -1]);

Members

.curve

Array #

The array to set as the waveshaper curve. For linear curves array length does not make much difference, but for complex curves longer arrays will provide smoother interpolation.

</>

.oversample

string #

Specifies what type of oversampling (if any) should be used when applying the shaping curve. Can either be “none”, “2x” or “4x”.

</>

Methods

.dispose ( )

#
↪ returns Tone.WaveShaper

this

Clean up.

</>

.setMap ( )

#
mapping

The function used to define the values. The mapping function take two arguments: the first is the value at the current position which goes from -1 to 1 over the number of elements in the curve array. The second argument is the array position.

type: function
↪ returns Tone.WaveShaper

this

Uses a mapping function to set the value of the curve.

EXAMPLE

//map the input signal from [-1, 1] to [0, 10]
shaper.setMap(function(val, index){
	return (val + 1) * 5;
})
</>
inherited from Tone.SignalBase

.connect ( )

#
node
type: AudioParam or AudioNode or Tone.Signal or Tone
outputNumber

The output number to connect from.

type: number
default: 0
inputNumber

The input number to connect to.

type: number
default: 0
↪ returns Tone.SignalBase

this

When signals connect to other signals or AudioParams, they take over the output value of that signal or AudioParam. For all other nodes, the behavior is the same as a default connect.

</>
docs generated Sep 15 2019