From 6c6a7cf136993acfc65758ef1e6efd2719c64bb8 Mon Sep 17 00:00:00 2001 From: Felix Roos Date: Thu, 17 Mar 2022 22:11:56 +0100 Subject: [PATCH] add euclidLegato --- repl/src/euclid.mjs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/repl/src/euclid.mjs b/repl/src/euclid.mjs index c05a64ee..9ba93a1e 100644 --- a/repl/src/euclid.mjs +++ b/repl/src/euclid.mjs @@ -1,4 +1,4 @@ -import { Pattern } from '../../strudel.mjs'; +import { Pattern, timeCat } from '../../strudel.mjs'; import bjork from 'bjork'; import { rotate } from '../../util.mjs'; @@ -14,4 +14,15 @@ Pattern.prototype.euclid = function (pulses, steps, rotation = 0) { return this.struct(euclid(pulses, steps, rotation)); }; +Pattern.prototype.euclidLegato = function (pulses, steps, rotation = 0) { + const bin_pat = euclid(pulses, steps, rotation); + const firstOne = bin_pat.indexOf(1); + const gapless = rotate(bin_pat, firstOne) + .join('') + .split('1') + .slice(1) + .map((s) => [s.length + 1, true]); + return this.struct(timeCat(...gapless)).late(firstOne / steps); +}; + export default euclid;