diff --git a/packages/core/signal.mjs b/packages/core/signal.mjs index a2f0e4e4..a6868937 100644 --- a/packages/core/signal.mjs +++ b/packages/core/signal.mjs @@ -88,3 +88,17 @@ export const perlinWith = (pat) => { }; export const perlin = perlinWith(time); + +Pattern.prototype._degradeByWith = function (withPat, x) { + return this.fmap((a) => (_) => a).appLeft(withPat._filterValues((v) => v > x)); +}; + +Pattern.prototype._degradeBy = function (x) { + return this._degradeByWith(rand, x); +}; + +Pattern.prototype._degrade = function () { + return this._degradeBy(0.5); +}; + +Pattern.prototype.patternified.push('degradeBy', 'degrade');