From 52da8552ef51683a4ea5e93c464ba4cc941d16f9 Mon Sep 17 00:00:00 2001 From: Felix Roos Date: Fri, 4 Mar 2022 00:06:26 +0100 Subject: [PATCH] add Pattern.len --- strudel.mjs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/strudel.mjs b/strudel.mjs index 5cbb6924..137efa4e 100644 --- a/strudel.mjs +++ b/strudel.mjs @@ -744,6 +744,11 @@ class Pattern { hush() { return silence; } + + _len(value) { + // return this.withEventSpan((span) => new TimeSpan(span.begin, span.begin.add(span.end.sub(span.begin).mul(value)))); + return this.withEventSpan((span) => new TimeSpan(span.begin, span.begin.add(value))); + } /* _resolveTies() { return this._withEvents((events)=>{ @@ -763,7 +768,7 @@ class Pattern { } // methods of Pattern that get callable factories -Pattern.prototype.patternified = ['apply', 'fast', 'slow', 'early', 'late']; +Pattern.prototype.patternified = ['apply', 'fast', 'slow', 'early', 'late', 'len']; // methods that create patterns, which are added to patternified Pattern methods Pattern.prototype.factories = { pure, stack, slowcat, fastcat, cat, timeCat, sequence, polymeter, pm, polyrhythm, pr}; // the magic happens in Pattern constructor. Keeping this in prototype enables adding methods from the outside (e.g. see tonal.ts)