* create polymetric join - `polyJoin`
* add `poly` as an op alignment to support e.g. `"c e f [g a]".add.poly("0 12 7")`
This commit is contained in:
Alex McLean 2024-08-30 13:24:08 +01:00 committed by GitHub
parent 812ed6b60d
commit 39006e4d71
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -386,6 +386,15 @@ export class Pattern {
return this.fmap(func).squeezeJoin(); return this.fmap(func).squeezeJoin();
} }
polyJoin = function () {
const pp = this;
return pp.fmap((p) => p.s_extend(pp.tactus.div(p.tactus))).outerJoin();
};
polyBind(func) {
return this.fmap(func).polyJoin();
}
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
// Utility methods mainly for internal use // Utility methods mainly for internal use
@ -754,6 +763,10 @@ export class Pattern {
const otherPat = reify(other); const otherPat = reify(other);
return otherPat.fmap((b) => this.fmap((a) => func(a)(b))).restartJoin(); return otherPat.fmap((b) => this.fmap((a) => func(a)(b))).restartJoin();
} }
_opPoly(other, func) {
const otherPat = reify(other);
return this.fmap((b) => otherPat.fmap((a) => func(a)(b))).polyJoin();
}
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
// End-user methods. // End-user methods.
@ -1062,7 +1075,7 @@ function _composeOp(a, b, func) {
func: [(a, b) => b(a)], func: [(a, b) => b(a)],
}; };
const hows = ['In', 'Out', 'Mix', 'Squeeze', 'SqueezeOut', 'Reset', 'Restart']; const hows = ['In', 'Out', 'Mix', 'Squeeze', 'SqueezeOut', 'Reset', 'Restart', 'Poly'];
// generate methods to do what and how // generate methods to do what and how
for (const [what, [op, preprocess]] of Object.entries(composers)) { for (const [what, [op, preprocess]] of Object.entries(composers)) {