signals

Methods

(static) bypass(config) → {AudioNode}

Create a node that bypasses the signal

Parameters:
Name Type Description
config Object

may include:

  • context: the audio context to use
Source:
Returns:

the bypass audio node

Type
AudioNode
Example
conn(sine('C4'), add(bypass(), dly(0.2)))

(static) constant(value, options) → {AudioNode}

Create a constant signal. Normally you will use it in combination with envelopes or modulators.

Parameters:
Name Type Description
value Integer

the value of the constant

options Object

(Optional) options may include:

  • context: the audio context to use to create the signal
Source:
Returns:

the constant audio node

Type
AudioNode
Example
sine(constant(440)).start()

(static) gain(config) → {AudioNode}

Create a GainNode

Parameters:
Name Type Description
config Object

may include:

  • value (or gain): the gain (can be a number or a signal)
  • dB (or db): the gain in dB (only if gain is not specified)
  • level: the gain in a logaritmic scale from 0 to 100
  • context: the audio context to use to create the signal

This funcion accepts a number with the gain value instead of a config object.

Source:
Returns:

a GainNode

Type
AudioNode
Example
gain({ dB: -3, context: <AudioContext> })
// with modulation (kind of tremolo)
conn(sine(400), gain({ value: sine(10) }))
// passing a number instead of an object
conn(sine('C4'), gain(0.3))

(static) mult(value, signal)

Multiply a signal.

Parameters:
Name Type Description
value Integer

the value

signal Integer | AudioNode

the signal to multiply by

Source:
Example
// a vibrato effect
sine(440, { detune: mult(500, sine(2)) })

(static) scale(min, max, source) → {AudioNode}

Scale a signal. Given a signal (between -1 and 1) scale it to fit in a range.

Parameters:
Name Type Description
min Integer

the minimum of the range

max Integer

the minimum of the range

source AudioNode

the signal to scale

Source:
Returns:

the scaled signal node

Type
AudioNode
Example
// create a frequency envelope between 440 and 880 Hz
sine(scale(440, 880, adsr(0.1, 0.01, 1, 1)))

(static) signal(value, options) → {AudioParam}

Create a signal source. You will use signals to change parameters of a audio node after starting. See example.

Parameters:
Name Type Description
value Integer

the value of the constant

options Object

(Optional) options may include:

  • context: the audio context to use to create the signal
Source:
Returns:

the constant audio node

Type
AudioParam
Example
var freq = signal(440)
sine(freq).start()
freq.value.linearRampToValueAtTime(880, after(5))