From e2cdce5ac9454f9c242fcb0e410a6888c89c496f Mon Sep 17 00:00:00 2001 From: "Lu[ke] Wilson" Date: Fri, 29 Aug 2025 15:35:41 +0100 Subject: [PATCH] add flux function --- packages/core/pattern.mjs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/packages/core/pattern.mjs b/packages/core/pattern.mjs index f1ebbe3e9..154643c74 100644 --- a/packages/core/pattern.mjs +++ b/packages/core/pattern.mjs @@ -2337,6 +2337,17 @@ export const { juxBy, juxby } = register(['juxBy', 'juxby'], function (by, func, return stack(left, right).setSteps(__steps ? lcm(left._steps, right._steps) : undefined); }); +/** + * Like juxBy, except it flips the ears each cycle. + * @name fluxBy + * @synonyms fluxby + * @example + * s("bd lt [~ ht] mt cp ~ bd hh").fluxBy(".8", rev) + */ +export const { fluxBy, fluxby } = register(['fluxBy', 'fluxby'], function (by, func, pat) { + return slowcat(pat._juxBy(by, func, pat), pat._juxBy(-by, func, pat)); +}); + /** * The jux function creates strange stereo effects, by applying a function to a pattern, but only in the right-hand channel. * @example @@ -2350,6 +2361,19 @@ export const jux = register('jux', function (func, pat) { return pat._juxBy(1, func, pat); }); +/** + * Like jux, but flips the ears each cycle. + * @example + * s("bd lt [~ ht] mt cp ~ bd hh").flux(rev) + * @example + * s("bd lt [~ ht] mt cp ~ bd hh").flux(press) + * @example + * s("bd lt [~ ht] mt cp ~ bd hh").flux(iter(4)) + */ +export const flux = register('flux', function (func, pat) { + return pat._fluxBy(1, func, pat); +}); + /** * Superimpose and offset multiple times, applying the given function each time. * @name echoWith