@thi.ng/dsp
Version:
Composable signal generators, oscillators, filters, FFT, spectrum, windowing & related DSP utils
27 lines (26 loc) • 658 B
JavaScript
import { AGen } from "./agen.js";
const mul = (factor, start, clamp) => new Mul(factor, start, clamp);
class Mul extends AGen {
constructor(_factor = 1, _start = 1, _clamp) {
super(0);
this._factor = _factor;
this._start = _start;
this._clamp = _clamp;
this.reset();
}
copy() {
return new Mul(this._factor, this._start, this._clamp);
}
reset() {
this._val = this._start / this._factor;
return this;
}
next() {
let v = this._val * this._factor;
return this._val = this._clamp !== void 0 ? this._start < this._clamp ? Math.min(v, this._clamp) : Math.max(v, this._clamp) : v;
}
}
export {
Mul,
mul
};