digital-filter
Collection of digital filters, for audio & dsp applications.
Usage
Produce 1024 samples of grey noise:
const noise = require('colors-of-noise/white')
const filter = require('digital-filter/loudness')
//generate frame of grey noise
let data = filter(noise(new Float32Array(1024)))
Filters
- [x] leaky integrator
- [ ] moving average
- [ ] biquad
- [ ] loudness
- [ ] lowpass
- [ ] hipass
- [ ] rumble
- [ ] flutter
- [ ] noise
- [ ] bessel
- [ ] butterworth
- [ ] matched
- [ ] elliptical
- [ ] linkwitz-riley
- [ ] chebyshev
- [ ] savitzky-golay
- [ ] curve (custom f-curve)
leakyIntegrator(samples, {lambda: 0.95, y: 0})
[FIR]
Takes input array samples
and params object, modifies samples
in-place. Params object should be shared between subsequent calls.
Params:
-
lambda
− defines amount of "leak". -
y
− keeps value of last sample, updated after every call.
let leaky = require('digital-filter/leaky-integrator')
let opts = {lambda: .5}
//render 3 frames
for (let i = 0; i < 3; i++) {
let data = new Float32Array(1024)
leaky(data, opts)
}
movingAverage(samples, {memory: 8})
[FIR]
Takes input array samples
and params object, modifies samples
in-place. Params object should be shared between subsequent calls.
Params:
-
memory
− array with initial values of memory. If number, this will create an array of that size.
let ma = require('digital-filter/moving-average')
//average of 5 items
let opts = {memory: 5}
for (let i = 0; i < 3; i++) {
let data = new Float32Array(1024)
ma(data, opts)
}
loudness(data, {type: ''})
Implemented filter types:
-
a
— A-weighting -
b
— B-weighting -
c
— C-weighting -
d
— D-weighting -
z
— Z-weighting (zero weighting) -
itu
— ITU-R 468 weighting
See also
- audio-filter − digital filters for audio infrastructure
- colors-of-noise − collection of noise generators