Skip to content
This repository has been archived by the owner on Sep 22, 2021. It is now read-only.
/ digital-filter Public archive

Collection of digital filters

Notifications You must be signed in to change notification settings

scrapjs/digital-filter

Repository files navigation

digital-filter experimental Build Status

Collection of digital filters, for audio & dsp applications.

Usage

npm install digital-filter

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

leakyIntegrator(samples, {lambda: 0.95, y: 0})

Leaky integrator.

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})

Moving average.

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)
}

bilinear(data, {order: 1, })

loudness(data, {type: ''})

Implemented filter types:

See also

About

Collection of digital filters

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published