@thi.ng/dsp
Version:
Composable signal generators, oscillators, filters, FFT, spectrum, windowing & related DSP utils
30 lines (29 loc) • 588 B
JavaScript
import { foldback as _foldback } from "@thi.ng/math/interval";
import { AProc } from "./aproc.js";
const foldback = (thresh, amp) => new Foldback(thresh, amp);
class Foldback extends AProc {
constructor(_thresh = 1, _amp = 1 / _thresh) {
super(0);
this._thresh = _thresh;
this._amp = _amp;
}
next(x) {
return this._val = _foldback(this._thresh, x) * this._amp;
}
threshold() {
return this._thresh;
}
setThreshold(t) {
this._thresh = t;
}
amp() {
return this._amp;
}
setAmp(a) {
this._amp = a;
}
}
export {
Foldback,
foldback
};