@thi.ng/dsp
Version:
Composable signal generators, oscillators, filters, FFT, spectrum, windowing & related DSP utils
30 lines (29 loc) • 571 B
JavaScript
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;
}
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
};