From 7b914e7f2259ac21241b16be3ca0ff38c2ef52f9 Mon Sep 17 00:00:00 2001 From: "Jade (Rose) Rowland" Date: Thu, 2 Jan 2025 22:33:04 -0500 Subject: [PATCH] working --- packages/core/pattern.mjs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/packages/core/pattern.mjs b/packages/core/pattern.mjs index f3f19f87..db1d9d0b 100644 --- a/packages/core/pattern.mjs +++ b/packages/core/pattern.mjs @@ -3100,3 +3100,23 @@ export let xfade = (a, pos, b) => { Pattern.prototype.xfade = function (pos, b) { return xfade(this, pos, b); }; + + +/** + * creates a structure pattern from divisions of a cycle + * especially useful for creating rhythms + * @name onSubCycle + * @synonyms onSub, os + * @example + * s("bd").os("0:7:10", 16) + * @example + * s("sd").os("4:12", 16) + */ +export const {onSubCycle, onSub, os} = register(['onSubCycle', 'onSub', 'os'], (times, div, pat) => { + if (typeof times === 'number') { + times = [times] + } + return stack( + ...times.map(t => pat.pressBy(_mod(t, div)/div).duration(1/div)) + )} +)