|
| 1 | +--- |
| 2 | +sidebar_position: 1 |
| 3 | +--- |
| 4 | + |
| 5 | +import AudioNodePropsTable from "@site/src/components/AudioNodePropsTable" |
| 6 | +import { ReadOnly } from '@site/src/components/Badges'; |
| 7 | + |
| 8 | +# BiquadFilterNode |
| 9 | + |
| 10 | +The `BiquadFilterNode` interface represents a low-order filter. It is an [`AudioNode`](/core/audio-node) used for tone controls, graphic equalizers, and other audio effects. |
| 11 | +Multiple `BiquadFilterNode` instances can be combined to create more complex filtering chains. |
| 12 | + |
| 13 | + |
| 14 | +#### [`AudioNode`](/core/audio-node#read-only-properties) properties |
| 15 | +<AudioNodePropsTable numberOfInputs={1} numberOfOutputs={1} channelCount={2} channelCountMode={"max"} channelInterpretation={"speakers"} /> |
| 16 | + |
| 17 | +## Constructor |
| 18 | + |
| 19 | +[`BaseAudioContext.createBiquadFilter()`](/core/base-audio-context#createbiquadfilter) |
| 20 | + |
| 21 | +## Properties |
| 22 | + |
| 23 | +| Name | Type | Rate | Description | |
| 24 | +| :--: | :--: | :----------: | :-- | |
| 25 | +| `frequency` | [`AudioParam`](/core/audio-param) | [`a-rate`](/core/audio-param#a-rate-vs-k-rate) | The filter’s cutoff or center frequency in hertz (Hz) | |
| 26 | +| `detune` | [`AudioParam`](/core/audio-param) | [`a-rate`](/core/audio-param#a-rate-vs-k-rate) | Amount by which the frequency is detuned in cents | |
| 27 | +| `Q` | [`AudioParam`](/core/audio-param) | [`a-rate`](/core/audio-param#a-rate-vs-k-rate) | The filter’s Q factor (quality factor). | |
| 28 | +| `gain` | [`AudioParam`](/core/audio-param) | [`a-rate`](/core/audio-param#a-rate-vs-k-rate) | Gain applied by specific filter types, in decibels (dB) | |
| 29 | +| `type` | `string` | — | Defines the kind of filtering algorithm the node applies (e.g. `"lowpass"`, `"highpass"`). | |
| 30 | + |
| 31 | +#### BiquadFilterType enumeration description |
| 32 | +| `type` | Description | `frequency` | `Q` | `gain` | |
| 33 | +|:------:|:-----------:|:-----------:|:---:|:------:| |
| 34 | +| `lowpass` | Second-order resonant lowpass filter with 12dB/octave rolloff. Frequencies below the cutoff pass through; higher frequencies are attenuated. | The cutoff frequency. | Determines how peaked the frequency is around the cutoff. Higher values result in a sharper peak. | Not used | |
| 35 | +| `highpass` | Second-order resonant highpass filter with 12dB/octave rolloff. Frequencies above the cutoff pass through; lower frequencies are attenuated. | The cutoff frequency. | Determines how peaked the frequency is around the cutoff. Higher values result in a sharper peak. | Not used | |
| 36 | +| `bandpass` | Second-order bandpass filter. Frequencies within a given range pass through; others are attenuated. | The center of the frequency band. | Controls the bandwidth. Higher values result in a narrower band. | Not used | |
| 37 | +| `lowshelf` | Second-order lowshelf filter. Frequencies below the cutoff are boosted or attenuated; others remain unchanged. | The upper limit of the frequencies where the boost (or attenuation) is applied. | Not used | The boost (in dB) to be applied. Negative values attenuate the frequencies.| |
| 38 | +| `highshelf` | Second-order highshelf filter. Frequencies above the cutoff are boosted or attenuated; others remain unchanged. | The lower limit of the frequencies where the boost (or attenuation) is applied. | Not used | The boost (in dB) to be applied. Negative values attenuate the frequencies. | |
| 39 | +| `peaking` | Frequencies around a center frequency are boosted or attenuated; others remain unchanged. | The center of the frequency range where the boost (or an attenuation) is applied. | Controls the bandwidth. Higher values result in a narrower band. | The boost (in dB) to be applied. Negative values attenuate the frequencies. | |
| 40 | +| `notch` | Notch (band-stop) filter. Opposite of a bandpass filter: frequencies around the center are attenuated; others remain unchanged. | The center of the frequency range where the notch is applied. | Controls the bandwidth. Higher values result in a narrower band. | Not used | |
| 41 | +| `allpass` | Second-order allpass filter. All frequencies pass through, but changes the phase relationship between the various frequencies. | The frequency where the center of the phase transition occurs (maximum group delay). | Controls how sharp the phase transition is at the center frequency. Higher values result in a sharper transition and a larger group delay. | Not used | |
| 42 | + |
| 43 | +## Methods |
| 44 | + |
| 45 | +### `getFrequencyResponse` |
| 46 | + |
| 47 | +| Parameters | Type | Description | |
| 48 | +| :--------: | :--: | :---------- | |
| 49 | +| `frequencyArray` | `Float32Array` | Array of frequencies (in Hz), which you want to filter. | |
| 50 | +| `magResponseOutput` | `Float32Array` | Output array to store the computed linear magnitude values for each frequency. For frequencies outside the range [0, sampleRate / 2], the corresponding results are NaN. | |
| 51 | +| `phaseResponseOutput` | `Float32Array` | Output array to store the computed phase response values (in radians) for each frequency. For frequencies outside the range [0, sampleRate / 2], the corresponding results are NaN. | |
| 52 | +| `length` | `number` | The number of frequency values to process. It should match the length of all input and output arrays. | |
| 53 | + |
| 54 | +#### Returns `undefined`. |
| 55 | + |
| 56 | +## Remarks |
| 57 | +#### `frequency` |
| 58 | +- float, default value is 350. |
| 59 | +#### `detune` |
| 60 | +- float, default value is 0. |
| 61 | +#### `Q` |
| 62 | +- float, default value is 1. |
| 63 | +#### `gain` |
| 64 | +- [`BiquadFilterType`](#biquadfiltertype-enumeration-description), default is "lowpass". |
0 commit comments