From 7b914e7f2259ac21241b16be3ca0ff38c2ef52f9 Mon Sep 17 00:00:00 2001 From: "Jade (Rose) Rowland" Date: Thu, 2 Jan 2025 22:33:04 -0500 Subject: [PATCH 1/8] 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)) + )} +) From 1d144faed71e65d240dae549ca1d5543344414d3 Mon Sep 17 00:00:00 2001 From: "Jade (Rose) Rowland" Date: Thu, 2 Jan 2025 22:39:56 -0500 Subject: [PATCH 2/8] update snapshot --- packages/core/pattern.mjs | 11 +++------ test/__snapshots__/examples.test.mjs.snap | 30 +++++++++++++++++++++++ 2 files changed, 34 insertions(+), 7 deletions(-) diff --git a/packages/core/pattern.mjs b/packages/core/pattern.mjs index db1d9d0b..170e1633 100644 --- a/packages/core/pattern.mjs +++ b/packages/core/pattern.mjs @@ -3101,7 +3101,6 @@ 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 @@ -3112,11 +3111,9 @@ Pattern.prototype.xfade = function (pos, b) { * @example * s("sd").os("4:12", 16) */ -export const {onSubCycle, onSub, os} = register(['onSubCycle', 'onSub', 'os'], (times, div, pat) => { +export const { onSubCycle, onSub, os } = register(['onSubCycle', 'onSub', 'os'], (times, div, pat) => { if (typeof times === 'number') { - times = [times] + times = [times]; } - return stack( - ...times.map(t => pat.pressBy(_mod(t, div)/div).duration(1/div)) - )} -) + return stack(...times.map((t) => pat.pressBy(_mod(t, div) / div).duration(1 / div))); +}); diff --git a/test/__snapshots__/examples.test.mjs.snap b/test/__snapshots__/examples.test.mjs.snap index 7c21d464..d258afe2 100644 --- a/test/__snapshots__/examples.test.mjs.snap +++ b/test/__snapshots__/examples.test.mjs.snap @@ -4902,6 +4902,36 @@ exports[`runs examples > example "often" example index 0 1`] = ` ] `; +exports[`runs examples > example "onSubCycle" example index 0 1`] = ` +[ + "[ 0/1 → 1/1 | s:bd duration:0.0625 ]", + "[ 7/16 → 1/1 | s:bd duration:0.0625 ]", + "[ 5/8 → 1/1 | s:bd duration:0.0625 ]", + "[ 1/1 → 2/1 | s:bd duration:0.0625 ]", + "[ 23/16 → 2/1 | s:bd duration:0.0625 ]", + "[ 13/8 → 2/1 | s:bd duration:0.0625 ]", + "[ 2/1 → 3/1 | s:bd duration:0.0625 ]", + "[ 39/16 → 3/1 | s:bd duration:0.0625 ]", + "[ 21/8 → 3/1 | s:bd duration:0.0625 ]", + "[ 3/1 → 4/1 | s:bd duration:0.0625 ]", + "[ 55/16 → 4/1 | s:bd duration:0.0625 ]", + "[ 29/8 → 4/1 | s:bd duration:0.0625 ]", +] +`; + +exports[`runs examples > example "onSubCycle" example index 1 1`] = ` +[ + "[ 1/4 → 1/1 | s:sd duration:0.0625 ]", + "[ 3/4 → 1/1 | s:sd duration:0.0625 ]", + "[ 5/4 → 2/1 | s:sd duration:0.0625 ]", + "[ 7/4 → 2/1 | s:sd duration:0.0625 ]", + "[ 9/4 → 3/1 | s:sd duration:0.0625 ]", + "[ 11/4 → 3/1 | s:sd duration:0.0625 ]", + "[ 13/4 → 4/1 | s:sd duration:0.0625 ]", + "[ 15/4 → 4/1 | s:sd duration:0.0625 ]", +] +`; + exports[`runs examples > example "orbit" example index 0 1`] = ` [ "[ 0/1 → 1/6 | s:hh delay:0.5 delaytime:0.25 orbit:1 ]", From f5127147de9947c0a742a7a6812c24e1b75cbf62 Mon Sep 17 00:00:00 2001 From: "Jade (Rose) Rowland" Date: Wed, 8 Jan 2025 00:43:02 -0500 Subject: [PATCH 3/8] channge function name --- packages/core/pattern.mjs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/packages/core/pattern.mjs b/packages/core/pattern.mjs index 170e1633..89c88a61 100644 --- a/packages/core/pattern.mjs +++ b/packages/core/pattern.mjs @@ -3104,14 +3104,13 @@ Pattern.prototype.xfade = function (pos, b) { /** * creates a structure pattern from divisions of a cycle * especially useful for creating rhythms - * @name onSubCycle - * @synonyms onSub, os + * @name beat * @example - * s("bd").os("0:7:10", 16) + * s("bd").beat("0:7:10", 16) * @example - * s("sd").os("4:12", 16) + * s("sd").beat("4:12", 16) */ -export const { onSubCycle, onSub, os } = register(['onSubCycle', 'onSub', 'os'], (times, div, pat) => { +export const { beat } = register(['beat'], (times, div, pat) => { if (typeof times === 'number') { times = [times]; } From 7410ac5cecd58bb67da3713768fccb28a77f74c2 Mon Sep 17 00:00:00 2001 From: "Jade (Rose) Rowland" Date: Wed, 8 Jan 2025 00:44:40 -0500 Subject: [PATCH 4/8] snapshot --- test/__snapshots__/examples.test.mjs.snap | 60 +++++++++++------------ 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/test/__snapshots__/examples.test.mjs.snap b/test/__snapshots__/examples.test.mjs.snap index d258afe2..0f649c36 100644 --- a/test/__snapshots__/examples.test.mjs.snap +++ b/test/__snapshots__/examples.test.mjs.snap @@ -954,6 +954,36 @@ exports[`runs examples > example "bank" example index 0 1`] = ` ] `; +exports[`runs examples > example "beat" example index 0 1`] = ` +[ + "[ 0/1 → 1/1 | s:bd duration:0.0625 ]", + "[ 7/16 → 1/1 | s:bd duration:0.0625 ]", + "[ 5/8 → 1/1 | s:bd duration:0.0625 ]", + "[ 1/1 → 2/1 | s:bd duration:0.0625 ]", + "[ 23/16 → 2/1 | s:bd duration:0.0625 ]", + "[ 13/8 → 2/1 | s:bd duration:0.0625 ]", + "[ 2/1 → 3/1 | s:bd duration:0.0625 ]", + "[ 39/16 → 3/1 | s:bd duration:0.0625 ]", + "[ 21/8 → 3/1 | s:bd duration:0.0625 ]", + "[ 3/1 → 4/1 | s:bd duration:0.0625 ]", + "[ 55/16 → 4/1 | s:bd duration:0.0625 ]", + "[ 29/8 → 4/1 | s:bd duration:0.0625 ]", +] +`; + +exports[`runs examples > example "beat" example index 1 1`] = ` +[ + "[ 1/4 → 1/1 | s:sd duration:0.0625 ]", + "[ 3/4 → 1/1 | s:sd duration:0.0625 ]", + "[ 5/4 → 2/1 | s:sd duration:0.0625 ]", + "[ 7/4 → 2/1 | s:sd duration:0.0625 ]", + "[ 9/4 → 3/1 | s:sd duration:0.0625 ]", + "[ 11/4 → 3/1 | s:sd duration:0.0625 ]", + "[ 13/4 → 4/1 | s:sd duration:0.0625 ]", + "[ 15/4 → 4/1 | s:sd duration:0.0625 ]", +] +`; + exports[`runs examples > example "begin" example index 0 1`] = ` [ "[ 0/1 → 1/2 | s:rave begin:0 ]", @@ -4902,36 +4932,6 @@ exports[`runs examples > example "often" example index 0 1`] = ` ] `; -exports[`runs examples > example "onSubCycle" example index 0 1`] = ` -[ - "[ 0/1 → 1/1 | s:bd duration:0.0625 ]", - "[ 7/16 → 1/1 | s:bd duration:0.0625 ]", - "[ 5/8 → 1/1 | s:bd duration:0.0625 ]", - "[ 1/1 → 2/1 | s:bd duration:0.0625 ]", - "[ 23/16 → 2/1 | s:bd duration:0.0625 ]", - "[ 13/8 → 2/1 | s:bd duration:0.0625 ]", - "[ 2/1 → 3/1 | s:bd duration:0.0625 ]", - "[ 39/16 → 3/1 | s:bd duration:0.0625 ]", - "[ 21/8 → 3/1 | s:bd duration:0.0625 ]", - "[ 3/1 → 4/1 | s:bd duration:0.0625 ]", - "[ 55/16 → 4/1 | s:bd duration:0.0625 ]", - "[ 29/8 → 4/1 | s:bd duration:0.0625 ]", -] -`; - -exports[`runs examples > example "onSubCycle" example index 1 1`] = ` -[ - "[ 1/4 → 1/1 | s:sd duration:0.0625 ]", - "[ 3/4 → 1/1 | s:sd duration:0.0625 ]", - "[ 5/4 → 2/1 | s:sd duration:0.0625 ]", - "[ 7/4 → 2/1 | s:sd duration:0.0625 ]", - "[ 9/4 → 3/1 | s:sd duration:0.0625 ]", - "[ 11/4 → 3/1 | s:sd duration:0.0625 ]", - "[ 13/4 → 4/1 | s:sd duration:0.0625 ]", - "[ 15/4 → 4/1 | s:sd duration:0.0625 ]", -] -`; - exports[`runs examples > example "orbit" example index 0 1`] = ` [ "[ 0/1 → 1/6 | s:hh delay:0.5 delaytime:0.25 orbit:1 ]", From 7b6074ccef28d0c63a7c210ee2bccc258ebafe3b Mon Sep 17 00:00:00 2001 From: "Jade (Rose) Rowland" Date: Wed, 15 Jan 2025 23:30:19 -0500 Subject: [PATCH 5/8] update function --- packages/core/pattern.mjs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/packages/core/pattern.mjs b/packages/core/pattern.mjs index 89c88a61..9279ec3c 100644 --- a/packages/core/pattern.mjs +++ b/packages/core/pattern.mjs @@ -3110,9 +3110,12 @@ Pattern.prototype.xfade = function (pos, b) { * @example * s("sd").beat("4:12", 16) */ -export const { beat } = register(['beat'], (times, div, pat) => { - if (typeof times === 'number') { - times = [times]; - } - return stack(...times.map((t) => pat.pressBy(_mod(t, div) / div).duration(1 / div))); -}); +const __beat = join => (t, div, pat) => { + t = Fraction(t).mod(div); + div = Fraction(div); + const b = t.div(div); + const e = t.add(1).div(div); + return join(pat.fmap(x => pure(x)._compress(b,e))); +} + +export const {beat, beatOut} = register(['beat', 'beatOut'], __beat(x => x.innerJoin())); \ No newline at end of file From c33c8b5469edf2af191737297eee5e5e3c0d5c90 Mon Sep 17 00:00:00 2001 From: "Jade (Rose) Rowland" Date: Wed, 15 Jan 2025 23:30:56 -0500 Subject: [PATCH 6/8] remove possibly not needed alt --- packages/core/pattern.mjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/core/pattern.mjs b/packages/core/pattern.mjs index 9279ec3c..9e5d2800 100644 --- a/packages/core/pattern.mjs +++ b/packages/core/pattern.mjs @@ -3118,4 +3118,4 @@ const __beat = join => (t, div, pat) => { return join(pat.fmap(x => pure(x)._compress(b,e))); } -export const {beat, beatOut} = register(['beat', 'beatOut'], __beat(x => x.innerJoin())); \ No newline at end of file +export const {beat} = register(['beat'], __beat(x => x.innerJoin())); \ No newline at end of file From 2348023b223f44e878ee2645133a76277d0e6434 Mon Sep 17 00:00:00 2001 From: "Jade (Rose) Rowland" Date: Wed, 15 Jan 2025 23:35:36 -0500 Subject: [PATCH 7/8] merge main --- test/__snapshots__/examples.test.mjs.snap | 28 +++++++---------------- 1 file changed, 8 insertions(+), 20 deletions(-) diff --git a/test/__snapshots__/examples.test.mjs.snap b/test/__snapshots__/examples.test.mjs.snap index 76e05997..6b149bc1 100644 --- a/test/__snapshots__/examples.test.mjs.snap +++ b/test/__snapshots__/examples.test.mjs.snap @@ -956,31 +956,19 @@ exports[`runs examples > example "bank" example index 0 1`] = ` exports[`runs examples > example "beat" example index 0 1`] = ` [ - "[ 0/1 → 1/1 | s:bd duration:0.0625 ]", - "[ 7/16 → 1/1 | s:bd duration:0.0625 ]", - "[ 5/8 → 1/1 | s:bd duration:0.0625 ]", - "[ 1/1 → 2/1 | s:bd duration:0.0625 ]", - "[ 23/16 → 2/1 | s:bd duration:0.0625 ]", - "[ 13/8 → 2/1 | s:bd duration:0.0625 ]", - "[ 2/1 → 3/1 | s:bd duration:0.0625 ]", - "[ 39/16 → 3/1 | s:bd duration:0.0625 ]", - "[ 21/8 → 3/1 | s:bd duration:0.0625 ]", - "[ 3/1 → 4/1 | s:bd duration:0.0625 ]", - "[ 55/16 → 4/1 | s:bd duration:0.0625 ]", - "[ 29/8 → 4/1 | s:bd duration:0.0625 ]", + "[ 0/1 → 1/16 | s:bd ]", + "[ 1/1 → 17/16 | s:bd ]", + "[ 2/1 → 33/16 | s:bd ]", + "[ 3/1 → 49/16 | s:bd ]", ] `; exports[`runs examples > example "beat" example index 1 1`] = ` [ - "[ 1/4 → 1/1 | s:sd duration:0.0625 ]", - "[ 3/4 → 1/1 | s:sd duration:0.0625 ]", - "[ 5/4 → 2/1 | s:sd duration:0.0625 ]", - "[ 7/4 → 2/1 | s:sd duration:0.0625 ]", - "[ 9/4 → 3/1 | s:sd duration:0.0625 ]", - "[ 11/4 → 3/1 | s:sd duration:0.0625 ]", - "[ 13/4 → 4/1 | s:sd duration:0.0625 ]", - "[ 15/4 → 4/1 | s:sd duration:0.0625 ]", + "[ 1/48 → 1/12 | s:sd ]", + "[ 49/48 → 13/12 | s:sd ]", + "[ 97/48 → 25/12 | s:sd ]", + "[ 145/48 → 37/12 | s:sd ]", ] `; From d2a9b9b750319c6bb13f603089853f6461667833 Mon Sep 17 00:00:00 2001 From: "Jade (Rose) Rowland" Date: Wed, 15 Jan 2025 23:51:57 -0500 Subject: [PATCH 8/8] format --- packages/core/pattern.mjs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/packages/core/pattern.mjs b/packages/core/pattern.mjs index 0c8e0c3f..72596b33 100644 --- a/packages/core/pattern.mjs +++ b/packages/core/pattern.mjs @@ -3122,12 +3122,15 @@ Pattern.prototype.xfade = function (pos, b) { * @example * s("sd").beat("4:12", 16) */ -const __beat = join => (t, div, pat) => { +const __beat = (join) => (t, div, pat) => { t = Fraction(t).mod(div); div = Fraction(div); const b = t.div(div); const e = t.add(1).div(div); - return join(pat.fmap(x => pure(x)._compress(b,e))); -} + return join(pat.fmap((x) => pure(x)._compress(b, e))); +}; -export const {beat} = register(['beat'], __beat(x => x.innerJoin())); \ No newline at end of file +export const { beat } = register( + ['beat'], + __beat((x) => x.innerJoin()), +);