filters

This module provides some syntactic sugar over the AudioContext.createBiquadFilter function.

Source:
Example
import { conn, square, lowpass, filter, master } from 'synth-kit'

master.start(conn(square('C4'), lowpass('C5')))
master.start(conn(square('A4'), filter({ type: 'hipass', Q: 10, freq: 1000 }))

Methods

(static) bandpass(config) → {AudioNode}

Create a bandpass filter. An alias for filter({ type: 'bandpass', ... })

Parameters:
Name Type Description
config Object

same as filter function but without type

Source:
See:
  • filter
Returns:

the bandpass filter

Type
AudioNode
Example
conn(square(800), bandpass(400))

(static) filter(config) → {AudioNode}

Create a filter (a BiquadFilterNode)

Parameters:
Name Type Description
config Object

it may include:

  • frequency (or freq, or note or midi): the frequency expressed in hertzs (or midi note number or note name)
  • type: one of the BiquadFilterNode types
  • detune: the detune of the frequency in cents (can be a number or a signal)
  • Q: the Q of the filter (can be a number or a signal)
  • context: the audio context to use

Instead of a configuration object you can pass a frequency number of note name just to specify the frequency.

Source:
Returns:

the BiquadFilterNode

Type
AudioNode
Example
conn(square(800), filter({ type: 'lowpass', freq: 600 }))

(static) hipass(config) → {AudioNode}

Create a hipass filter. An alias for filter({ type: 'hipass', ... })

Parameters:
Name Type Description
config Object

same as filter function but without type

Source:
See:
  • filter
Returns:

the hipass filter

Type
AudioNode
Example
conn(square(800), hipass(400))

(static) lowpass(config) → {AudioNode}

Create a lowpass filter. An alias for filter({ type: 'lowpass', ... })

Parameters:
Name Type Description
config Object

same as filter function but without type

Source:
See:
  • filter
Returns:

the lowpass filter

Type
AudioNode
Example
conn(square('C4'), lowpass(400))