diff --git a/packages/core/pattern.mjs b/packages/core/pattern.mjs index f3f19f874..db1d9d0b7 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)) + )} +)