UNPKG

@thi.ng/dsp

Version:

Composable signal generators, oscillators, filters, FFT, spectrum, windowing & related DSP utils

32 lines (31 loc) 591 B
import { AProc } from "./aproc.js"; const integrator = (coeff, start) => new Integrator(coeff, start); class Integrator extends AProc { constructor(_coeff = 1, _start = 0) { super(_start); this._coeff = _coeff; this._start = _start; } _coeff; _start; copy() { return new Integrator(this._coeff, this._start); } reset() { this._val = this._start; return this; } next(x) { return this._val = this._val * this._coeff + x; } coeff() { return this._coeff; } setCoeff(c) { this._coeff = c; } } export { Integrator, integrator };