Reference p5.Filter

p5.Filter

A p5.Filter uses a Web Audio Biquad Filter to filter the frequency response of an input source. Subclasses include:

p5.LowPass: Allows frequencies below the cutoff frequency to pass through, and attenuates frequencies above the cutoff.
p5.HighPass: The opposite of a lowpass filter.
p5.BandPass: Allows a range of frequencies to pass through and attenuates the frequencies below and above this frequency range.

The .res() method controls either width of the bandpass, or resonance of the low/highpass cutoff frequency.

This class extends p5.Effect. Methods amp(), chain(), drywet(), connect(), and disconnect() are available.

Examples

Syntax

p5.Filter([type])

Parameters

type
String:

'lowpass' (default), 'highpass', 'bandpass'

Fields

biquadFilter

The p5.Filter is built with a Web Audio BiquadFilter Node.

Methods

process

Filter an audio signal according to a set of filter parameters.

set

Set the frequency and the resonance of the filter.

freq

Set the filter frequency, in Hz, from 10 to 22050 (the range of human hearing, although in reality most people hear in a narrower range).

res

Controls either width of a bandpass frequency, or the resonance of a low/highpass cutoff frequency.

gain

Controls the gain attribute of a Biquad Filter. This is distinctly different from .amp() which is inherited from p5.Effect .amp() controls the volume via the output gain node p5.Filter.gain() controls the gain parameter of a Biquad Filter node.

toggle

Toggle function. Switches between the specified type and allpass

setType

Set the type of a p5.Filter. Possible types include: "lowpass" (default), "highpass", "bandpass", "lowshelf", "highshelf", "peaking", "notch", "allpass".

Notice any errors or typos? Please let us know. Please feel free to edit lib/addons/p5.sound.js and open a pull request!

Related References