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)