From 9ac7212f9cdbd9a33cf41ba84cd578e44844ff4f Mon Sep 17 00:00:00 2001 From: Felix Roos Date: Wed, 16 Feb 2022 20:09:23 +0100 Subject: [PATCH] add bypass + hush --- strudel.mjs | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/strudel.mjs b/strudel.mjs index ad87815b..a9085968 100644 --- a/strudel.mjs +++ b/strudel.mjs @@ -109,8 +109,12 @@ class TimeSpan { } withTime(func_time) { - // Applies given function to both the begin and end time value of the timespan""" - return(new TimeSpan(func_time(this.begin), func_time(this.end))) + // Applies given function to both the begin and end time value of the timespan""" + return(new TimeSpan(func_time(this.begin), func_time(this.end))) + } + withEnd(func_time) { + // Applies given function to both the begin and end time value of the timespan""" + return(new TimeSpan(this.begin, func_time(this.end))) } intersection(other) { @@ -575,6 +579,15 @@ class Pattern { edit(...funcs) { return stack(...funcs.map(func => func(this))); } + + _bypass(on) { + on = Boolean(parseInt(on)); + return on ? silence : this; + } + + hush() { + return silence; + } } // methods of Pattern that get callable factories @@ -773,6 +786,10 @@ Pattern.prototype.define = (name, func, options = {}) => { } } +// Pattern.prototype.define('early', (a, pat) => pat.early(a), { patternified: true, composable: true }); +Pattern.prototype.define('hush', (pat) => pat.hush(), { patternified: false, composable: true }); +Pattern.prototype.define('bypass', (pat) => pat.bypass(on), { patternified: true, composable: true }); + // call this after all Patter.prototype.define calls have been executed! (right before evaluate) Pattern.prototype.bootstrap = () => { // makeComposable(Pattern.prototype);