mirror of
https://github.com/eliasstepanik/strudel-docker.git
synced 2026-01-11 21:58:31 +00:00
undegrade, sometimes, sometimesBy, sometimesByPre, often, rarely, almostNever, almostAlways, never, always
This commit is contained in:
parent
dca8b46abf
commit
8abbaf2e56
@ -1,5 +1,5 @@
|
||||
import { Hap } from './hap.mjs';
|
||||
import { Pattern, fastcat, reify, silence } from './pattern.mjs';
|
||||
import { Pattern, fastcat, reify, silence, stack } from './pattern.mjs';
|
||||
import Fraction from './fraction.mjs';
|
||||
import { id } from './util.mjs';
|
||||
|
||||
@ -101,4 +101,38 @@ Pattern.prototype._degrade = function () {
|
||||
return this._degradeBy(0.5);
|
||||
};
|
||||
|
||||
Pattern.prototype.patternified.push('degradeBy', 'degrade');
|
||||
Pattern.prototype._undegradeBy = function (x) {
|
||||
return this._degradeByWith(rand.fmap((r) => 1 - r), x);
|
||||
};
|
||||
|
||||
Pattern.prototype._undegrade = function () {
|
||||
return this._undegradeBy(0.5);
|
||||
};
|
||||
|
||||
Pattern.prototype._sometimesBy = function (x, func) {
|
||||
return stack(this._degradeBy(x), func(this._undegradeBy(1-x)));
|
||||
};
|
||||
|
||||
Pattern.prototype.sometimesBy = function (patx, func) {
|
||||
const pat = this;
|
||||
return reify(patx).fmap((x) => pat._sometimesBy(x, func)).innerJoin();
|
||||
};
|
||||
|
||||
Pattern.prototype._sometimesByPre = function (x, func) {
|
||||
return stack(this._degradeBy(x), func(this).undegradeBy(1-x));
|
||||
};
|
||||
|
||||
Pattern.prototype.sometimesByPre = function (patx, func) {
|
||||
const pat = this;
|
||||
return reify(patx).fmap((x) => pat._sometimesByPre(x, func)).innerJoin();
|
||||
};
|
||||
|
||||
Pattern.prototype.sometimes = function (func) {
|
||||
return this._sometimesBy(0.5, func);
|
||||
};
|
||||
|
||||
Pattern.prototype.sometimesPre = function (func) {
|
||||
return this._sometimesByPre(0.5, func);
|
||||
};
|
||||
|
||||
Pattern.prototype.patternified.push('degradeBy', 'undegradeBy');
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user