@thi.ng/dsp
Version:
Composable signal generators, oscillators, filters, FFT, spectrum, windowing & related DSP utils
30 lines (29 loc) • 574 B
JavaScript
import { AGen } from "./agen.js";
const impulse = (on = 1) => new Impulse(on, 0);
const impulseT = (on, off) => new Impulse(on, off);
const impulseB = (start = true) => new Impulse(start, !start);
class Impulse extends AGen {
constructor(_on, _off) {
super(_on);
this._on = _on;
this._off = _off;
}
copy() {
return new Impulse(this._on, this._off);
}
reset() {
this._val = this._on;
return this;
}
next() {
const x = this._val;
this._val = this._off;
return x;
}
}
export {
Impulse,
impulse,
impulseB,
impulseT
};