@thi.ng/dsp
Version:
Composable signal generators, oscillators, filters, FFT, spectrum, windowing & related DSP utils
23 lines (22 loc) • 392 B
JavaScript
import { AGen } from "./agen.js";
const reciprocal = (step) => new Reciprocal(step);
class Reciprocal extends AGen {
constructor(_step = 1) {
super(1);
this._step = _step;
this.reset();
}
_n;
reset() {
this._n = 1 - this._step;
return this;
}
next() {
this._n += this._step;
return this._val = 1 / this._n;
}
}
export {
Reciprocal,
reciprocal
};