diff --git a/packages/core/pattern.mjs b/packages/core/pattern.mjs index ba4edafa..a11841a6 100644 --- a/packages/core/pattern.mjs +++ b/packages/core/pattern.mjs @@ -1915,12 +1915,12 @@ export const jux = register('jux', function (func, pat) { * .echoWith(4, 1/8, (p,n) => p.add(n*2)) * .scale('C minor').note().legato(.2) */ -export const { echoWith, echowith } = register(['echoWith', 'echowith'], function (times, time, func, pat) { - return stack(...listRange(0, times - 1).map((i) => func(pat.late(Fraction(time).mul(i)), i))); -}); - -export const stutWith = echoWith; -export const stutwith = echoWith; +export const { echoWith, echowith, stutWith, stutwith } = register( + ['echoWith', 'echowith', 'stutWith', 'stutwith'], + function (times, time, func, pat) { + return stack(...listRange(0, times - 1).map((i) => func(pat.late(Fraction(time).mul(i)), i))); + }, +); /** * Superimpose and offset multiple times, gradually decreasing the velocity @@ -1947,7 +1947,7 @@ export const echo = register('echo', function (times, time, feedback, pat) { * s("bd sd").stut(3, .8, 1/6) */ export const stut = register('stut', function (times, feedback, time, pat) { - return pat._stutWith(times, time, (pat, i) => pat.velocity(Math.pow(feedback, i))); + return pat._echoWith(times, time, (pat, i) => pat.velocity(Math.pow(feedback, i))); }); /** diff --git a/test/__snapshots__/examples.test.mjs.snap b/test/__snapshots__/examples.test.mjs.snap index c43b881e..a0c792a4 100644 --- a/test/__snapshots__/examples.test.mjs.snap +++ b/test/__snapshots__/examples.test.mjs.snap @@ -1977,6 +1977,23 @@ exports[`runs examples > example "hresonance" example index 0 1`] = ` ] `; +exports[`runs examples > example "hush" example index 0 1`] = ` +[ + "[ 0/1 → 1/3 | s:hh ]", + "[ 1/3 → 2/3 | s:hh ]", + "[ 2/3 → 1/1 | s:hh ]", + "[ 1/1 → 4/3 | s:hh ]", + "[ 4/3 → 5/3 | s:hh ]", + "[ 5/3 → 2/1 | s:hh ]", + "[ 2/1 → 7/3 | s:hh ]", + "[ 7/3 → 8/3 | s:hh ]", + "[ 8/3 → 3/1 | s:hh ]", + "[ 3/1 → 10/3 | s:hh ]", + "[ 10/3 → 11/3 | s:hh ]", + "[ 11/3 → 4/1 | s:hh ]", +] +`; + exports[`runs examples > example "inside" example index 0 1`] = ` [ "[ 1/8 → 1/4 | note:C3 ]", @@ -2014,6 +2031,25 @@ exports[`runs examples > example "inside" example index 0 1`] = ` ] `; +exports[`runs examples > example "invert" example index 0 1`] = ` +[ + "[ 0/1 → 1/8 | s:bd ]", + "[ 3/8 → 1/2 | s:bd ]", + "[ 3/4 → 7/8 | s:bd ]", + "[ 1/1 → 9/8 | s:bd ]", + "[ 11/8 → 3/2 | s:bd ]", + "[ 7/4 → 15/8 | s:bd ]", + "[ 2/1 → 17/8 | s:bd ]", + "[ 19/8 → 5/2 | s:bd ]", + "[ 11/4 → 23/8 | s:bd ]", + "[ 25/8 → 13/4 | s:bd ]", + "[ 13/4 → 27/8 | s:bd ]", + "[ 7/2 → 29/8 | s:bd ]", + "[ 29/8 → 15/4 | s:bd ]", + "[ 31/8 → 4/1 | s:bd ]", +] +`; + exports[`runs examples > example "irand" example index 0 1`] = ` [ "[ 0/1 → 1/8 | note:Bb3 ]", @@ -2073,6 +2109,96 @@ exports[`runs examples > example "iterBack" example index 0 1`] = ` ] `; +exports[`runs examples > example "jux" example index 0 1`] = ` +[ + "[ 0/1 → 1/5 | s:lt pan:0 ]", + "[ 1/5 → 2/5 | s:ht pan:0 ]", + "[ 2/5 → 3/5 | s:mt pan:0 ]", + "[ 3/5 → 4/5 | s:ht pan:0 ]", + "[ 4/5 → 1/1 | s:hh pan:0 ]", + "[ 4/5 → 1/1 | s:lt pan:1 ]", + "[ 3/5 → 4/5 | s:ht pan:1 ]", + "[ 2/5 → 3/5 | s:mt pan:1 ]", + "[ 1/5 → 2/5 | s:ht pan:1 ]", + "[ 0/1 → 1/5 | s:hh pan:1 ]", + "[ 1/1 → 6/5 | s:lt pan:0 ]", + "[ 6/5 → 7/5 | s:ht pan:0 ]", + "[ 7/5 → 8/5 | s:mt pan:0 ]", + "[ 8/5 → 9/5 | s:ht pan:0 ]", + "[ 9/5 → 2/1 | s:hh pan:0 ]", + "[ 9/5 → 2/1 | s:lt pan:1 ]", + "[ 8/5 → 9/5 | s:ht pan:1 ]", + "[ 7/5 → 8/5 | s:mt pan:1 ]", + "[ 6/5 → 7/5 | s:ht pan:1 ]", + "[ 1/1 → 6/5 | s:hh pan:1 ]", + "[ 2/1 → 11/5 | s:lt pan:0 ]", + "[ 11/5 → 12/5 | s:ht pan:0 ]", + "[ 12/5 → 13/5 | s:mt pan:0 ]", + "[ 13/5 → 14/5 | s:ht pan:0 ]", + "[ 14/5 → 3/1 | s:hh pan:0 ]", + "[ 14/5 → 3/1 | s:lt pan:1 ]", + "[ 13/5 → 14/5 | s:ht pan:1 ]", + "[ 12/5 → 13/5 | s:mt pan:1 ]", + "[ 11/5 → 12/5 | s:ht pan:1 ]", + "[ 2/1 → 11/5 | s:hh pan:1 ]", + "[ 3/1 → 16/5 | s:lt pan:0 ]", + "[ 16/5 → 17/5 | s:ht pan:0 ]", + "[ 17/5 → 18/5 | s:mt pan:0 ]", + "[ 18/5 → 19/5 | s:ht pan:0 ]", + "[ 19/5 → 4/1 | s:hh pan:0 ]", + "[ 19/5 → 4/1 | s:lt pan:1 ]", + "[ 18/5 → 19/5 | s:ht pan:1 ]", + "[ 17/5 → 18/5 | s:mt pan:1 ]", + "[ 16/5 → 17/5 | s:ht pan:1 ]", + "[ 3/1 → 16/5 | s:hh pan:1 ]", +] +`; + +exports[`runs examples > example "juxBy" example index 0 1`] = ` +[ + "[ 0/1 → 1/5 | s:lt pan:0.5 ]", + "[ 1/5 → 2/5 | s:ht pan:0.5 ]", + "[ 2/5 → 3/5 | s:mt pan:0.5 ]", + "[ 3/5 → 4/5 | s:ht pan:0.5 ]", + "[ 4/5 → 1/1 | s:hh pan:0.5 ]", + "[ 4/5 → 1/1 | s:lt pan:0.5 ]", + "[ 3/5 → 4/5 | s:ht pan:0.5 ]", + "[ 2/5 → 3/5 | s:mt pan:0.5 ]", + "[ 1/5 → 2/5 | s:ht pan:0.5 ]", + "[ 0/1 → 1/5 | s:hh pan:0.5 ]", + "[ 1/1 → 6/5 | s:lt pan:0.5 ]", + "[ 6/5 → 7/5 | s:ht pan:0.5 ]", + "[ 7/5 → 8/5 | s:mt pan:0.5 ]", + "[ 8/5 → 9/5 | s:ht pan:0.5 ]", + "[ 9/5 → 2/1 | s:hh pan:0.5 ]", + "[ 9/5 → 2/1 | s:lt pan:0.5 ]", + "[ 8/5 → 9/5 | s:ht pan:0.5 ]", + "[ 7/5 → 8/5 | s:mt pan:0.5 ]", + "[ 6/5 → 7/5 | s:ht pan:0.5 ]", + "[ 1/1 → 6/5 | s:hh pan:0.5 ]", + "[ 2/1 → 11/5 | s:lt pan:0.25 ]", + "[ 11/5 → 12/5 | s:ht pan:0.25 ]", + "[ 12/5 → 13/5 | s:mt pan:0.25 ]", + "[ 13/5 → 14/5 | s:ht pan:0.25 ]", + "[ 14/5 → 3/1 | s:hh pan:0.25 ]", + "[ 14/5 → 3/1 | s:lt pan:0.75 ]", + "[ 13/5 → 14/5 | s:ht pan:0.75 ]", + "[ 12/5 → 13/5 | s:mt pan:0.75 ]", + "[ 11/5 → 12/5 | s:ht pan:0.75 ]", + "[ 2/1 → 11/5 | s:hh pan:0.75 ]", + "[ 3/1 → 16/5 | s:lt pan:0.25 ]", + "[ 16/5 → 17/5 | s:ht pan:0.25 ]", + "[ 17/5 → 18/5 | s:mt pan:0.25 ]", + "[ 18/5 → 19/5 | s:ht pan:0.25 ]", + "[ 19/5 → 4/1 | s:hh pan:0.25 ]", + "[ 19/5 → 4/1 | s:lt pan:0.75 ]", + "[ 18/5 → 19/5 | s:ht pan:0.75 ]", + "[ 17/5 → 18/5 | s:mt pan:0.75 ]", + "[ 16/5 → 17/5 | s:ht pan:0.75 ]", + "[ 3/1 → 16/5 | s:hh pan:0.75 ]", +] +`; + exports[`runs examples > example "lastOf" example index 0 1`] = ` [ "[ 0/1 → 1/4 | note:c3 ]", @@ -2189,6 +2315,51 @@ exports[`runs examples > example "leslie" example index 0 1`] = ` ] `; +exports[`runs examples > example "linger" example index 0 1`] = ` +[ + "[ 0/1 → 1/4 | s:lt ]", + "[ 1/4 → 1/2 | s:ht ]", + "[ 1/2 → 3/4 | s:mt ]", + "[ 3/4 → 1/1 | s:cp ]", + "[ 0/1 → 1/4 | s:hh ]", + "[ 1/2 → 3/4 | s:hh ]", + "[ 1/4 → 1/2 | s:oh ]", + "[ 3/4 → 1/1 | s:oh ]", + "[ 1/1 → 5/4 | s:lt ]", + "[ 5/4 → 3/2 | s:ht ]", + "[ 1/1 → 5/4 | s:hh ]", + "[ 5/4 → 3/2 | s:oh ]", + "[ 3/2 → 7/4 | s:lt ]", + "[ 7/4 → 2/1 | s:ht ]", + "[ 3/2 → 7/4 | s:hh ]", + "[ 7/4 → 2/1 | s:oh ]", + "[ 2/1 → 9/4 | s:lt ]", + "[ 2/1 → 9/4 | s:hh ]", + "[ 9/4 → 5/2 | s:lt ]", + "[ 9/4 → 5/2 | s:hh ]", + "[ 5/2 → 11/4 | s:lt ]", + "[ 5/2 → 11/4 | s:hh ]", + "[ 11/4 → 3/1 | s:lt ]", + "[ 11/4 → 3/1 | s:hh ]", + "[ (3/1 → 25/8) ⇝ 13/4 | s:lt ]", + "[ (3/1 → 25/8) ⇝ 13/4 | s:hh ]", + "[ (25/8 → 13/4) ⇝ 27/8 | s:lt ]", + "[ (25/8 → 13/4) ⇝ 27/8 | s:hh ]", + "[ (13/4 → 27/8) ⇝ 7/2 | s:lt ]", + "[ (13/4 → 27/8) ⇝ 7/2 | s:hh ]", + "[ (27/8 → 7/2) ⇝ 29/8 | s:lt ]", + "[ (27/8 → 7/2) ⇝ 29/8 | s:hh ]", + "[ (7/2 → 29/8) ⇝ 15/4 | s:lt ]", + "[ (7/2 → 29/8) ⇝ 15/4 | s:hh ]", + "[ (29/8 → 15/4) ⇝ 31/8 | s:lt ]", + "[ (29/8 → 15/4) ⇝ 31/8 | s:hh ]", + "[ (15/4 → 31/8) ⇝ 4/1 | s:lt ]", + "[ (15/4 → 31/8) ⇝ 4/1 | s:hh ]", + "[ (31/8 → 4/1) ⇝ 33/8 | s:lt ]", + "[ (31/8 → 4/1) ⇝ 33/8 | s:hh ]", +] +`; + exports[`runs examples > example "loop" example index 0 1`] = ` [ "[ 0/1 → 1/1 | s:bd loop:1 ]", @@ -2480,6 +2651,27 @@ exports[`runs examples > example "outside" example index 0 1`] = ` ] `; +exports[`runs examples > example "palindrome" example index 0 1`] = ` +[ + "[ 3/4 → 1/1 | note:c ]", + "[ 1/2 → 3/4 | note:d ]", + "[ 1/4 → 1/2 | note:e ]", + "[ 0/1 → 1/4 | note:g ]", + "[ 1/1 → 5/4 | note:c ]", + "[ 5/4 → 3/2 | note:d ]", + "[ 3/2 → 7/4 | note:e ]", + "[ 7/4 → 2/1 | note:g ]", + "[ 11/4 → 3/1 | note:c ]", + "[ 5/2 → 11/4 | note:d ]", + "[ 9/4 → 5/2 | note:e ]", + "[ 2/1 → 9/4 | note:g ]", + "[ 3/1 → 13/4 | note:c ]", + "[ 13/4 → 7/2 | note:d ]", + "[ 7/2 → 15/4 | note:e ]", + "[ 15/4 → 4/1 | note:g ]", +] +`; + exports[`runs examples > example "pan" example index 0 1`] = ` [ "[ 0/1 → 1/4 | s:bd pan:0.5 ]", @@ -2908,6 +3100,19 @@ exports[`runs examples > example "room" example index 0 1`] = ` ] `; +exports[`runs examples > example "roomsize" example index 0 1`] = ` +[ + "[ 0/1 → 1/2 | s:bd room:0.8 roomsize:0 ]", + "[ 1/2 → 1/1 | s:sd room:0.8 roomsize:0 ]", + "[ 1/1 → 3/2 | s:bd room:0.8 roomsize:1 ]", + "[ 3/2 → 2/1 | s:sd room:0.8 roomsize:1 ]", + "[ 2/1 → 5/2 | s:bd room:0.8 roomsize:2 ]", + "[ 5/2 → 3/1 | s:sd room:0.8 roomsize:2 ]", + "[ 3/1 → 7/2 | s:bd room:0.8 roomsize:4 ]", + "[ 7/2 → 4/1 | s:sd room:0.8 roomsize:4 ]", +] +`; + exports[`runs examples > example "rootNotes" example index 0 1`] = ` [ "[ 0/1 → 1/1 | note:C2 ]", @@ -3064,6 +3269,107 @@ exports[`runs examples > example "scaleTranspose" example index 0 1`] = ` ] `; +exports[`runs examples > example "segment" example index 0 1`] = ` +[ + "[ 0/1 → 1/24 | note:40.25 ]", + "[ 1/24 → 1/12 | note:40.75 ]", + "[ 1/12 → 1/8 | note:41.25 ]", + "[ 1/8 → 1/6 | note:41.75 ]", + "[ 1/6 → 5/24 | note:42.25 ]", + "[ 5/24 → 1/4 | note:42.75 ]", + "[ 1/4 → 7/24 | note:43.25 ]", + "[ 7/24 → 1/3 | note:43.75 ]", + "[ 1/3 → 3/8 | note:44.25 ]", + "[ 3/8 → 5/12 | note:44.75 ]", + "[ 5/12 → 11/24 | note:45.25 ]", + "[ 11/24 → 1/2 | note:45.75 ]", + "[ 1/2 → 13/24 | note:46.25 ]", + "[ 13/24 → 7/12 | note:46.75 ]", + "[ 7/12 → 5/8 | note:47.25 ]", + "[ 5/8 → 2/3 | note:47.75 ]", + "[ 2/3 → 17/24 | note:48.25 ]", + "[ 17/24 → 3/4 | note:48.75 ]", + "[ 3/4 → 19/24 | note:49.25 ]", + "[ 19/24 → 5/6 | note:49.75 ]", + "[ 5/6 → 7/8 | note:50.25 ]", + "[ 7/8 → 11/12 | note:50.75 ]", + "[ 11/12 → 23/24 | note:51.25 ]", + "[ 23/24 → 1/1 | note:51.75 ]", + "[ 1/1 → 25/24 | note:40.25 ]", + "[ 25/24 → 13/12 | note:40.75 ]", + "[ 13/12 → 9/8 | note:41.25 ]", + "[ 9/8 → 7/6 | note:41.75 ]", + "[ 7/6 → 29/24 | note:42.25 ]", + "[ 29/24 → 5/4 | note:42.75 ]", + "[ 5/4 → 31/24 | note:43.25 ]", + "[ 31/24 → 4/3 | note:43.75 ]", + "[ 4/3 → 11/8 | note:44.25 ]", + "[ 11/8 → 17/12 | note:44.75 ]", + "[ 17/12 → 35/24 | note:45.25 ]", + "[ 35/24 → 3/2 | note:45.75 ]", + "[ 3/2 → 37/24 | note:46.25 ]", + "[ 37/24 → 19/12 | note:46.75 ]", + "[ 19/12 → 13/8 | note:47.25 ]", + "[ 13/8 → 5/3 | note:47.75 ]", + "[ 5/3 → 41/24 | note:48.25 ]", + "[ 41/24 → 7/4 | note:48.75 ]", + "[ 7/4 → 43/24 | note:49.25 ]", + "[ 43/24 → 11/6 | note:49.75 ]", + "[ 11/6 → 15/8 | note:50.25 ]", + "[ 15/8 → 23/12 | note:50.75 ]", + "[ 23/12 → 47/24 | note:51.25 ]", + "[ 47/24 → 2/1 | note:51.75 ]", + "[ 2/1 → 49/24 | note:40.25 ]", + "[ 49/24 → 25/12 | note:40.75 ]", + "[ 25/12 → 17/8 | note:41.25 ]", + "[ 17/8 → 13/6 | note:41.75 ]", + "[ 13/6 → 53/24 | note:42.25 ]", + "[ 53/24 → 9/4 | note:42.75 ]", + "[ 9/4 → 55/24 | note:43.25 ]", + "[ 55/24 → 7/3 | note:43.75 ]", + "[ 7/3 → 19/8 | note:44.25 ]", + "[ 19/8 → 29/12 | note:44.75 ]", + "[ 29/12 → 59/24 | note:45.25 ]", + "[ 59/24 → 5/2 | note:45.75 ]", + "[ 5/2 → 61/24 | note:46.25 ]", + "[ 61/24 → 31/12 | note:46.75 ]", + "[ 31/12 → 21/8 | note:47.25 ]", + "[ 21/8 → 8/3 | note:47.75 ]", + "[ 8/3 → 65/24 | note:48.25 ]", + "[ 65/24 → 11/4 | note:48.75 ]", + "[ 11/4 → 67/24 | note:49.25 ]", + "[ 67/24 → 17/6 | note:49.75 ]", + "[ 17/6 → 23/8 | note:50.25 ]", + "[ 23/8 → 35/12 | note:50.75 ]", + "[ 35/12 → 71/24 | note:51.25 ]", + "[ 71/24 → 3/1 | note:51.75 ]", + "[ 3/1 → 73/24 | note:40.25 ]", + "[ 73/24 → 37/12 | note:40.75 ]", + "[ 37/12 → 25/8 | note:41.25 ]", + "[ 25/8 → 19/6 | note:41.75 ]", + "[ 19/6 → 77/24 | note:42.25 ]", + "[ 77/24 → 13/4 | note:42.75 ]", + "[ 13/4 → 79/24 | note:43.25 ]", + "[ 79/24 → 10/3 | note:43.75 ]", + "[ 10/3 → 27/8 | note:44.25 ]", + "[ 27/8 → 41/12 | note:44.75 ]", + "[ 41/12 → 83/24 | note:45.25 ]", + "[ 83/24 → 7/2 | note:45.75 ]", + "[ 7/2 → 85/24 | note:46.25 ]", + "[ 85/24 → 43/12 | note:46.75 ]", + "[ 43/12 → 29/8 | note:47.25 ]", + "[ 29/8 → 11/3 | note:47.75 ]", + "[ 11/3 → 89/24 | note:48.25 ]", + "[ 89/24 → 15/4 | note:48.75 ]", + "[ 15/4 → 91/24 | note:49.25 ]", + "[ 91/24 → 23/6 | note:49.75 ]", + "[ 23/6 → 31/8 | note:50.25 ]", + "[ 31/8 → 47/12 | note:50.75 ]", + "[ 47/12 → 95/24 | note:51.25 ]", + "[ 95/24 → 4/1 | note:51.75 ]", +] +`; + exports[`runs examples > example "seq" example index 0 1`] = ` [ "[ 0/1 → 1/4 | s:hh ]", @@ -3423,6 +3729,43 @@ exports[`runs examples > example "struct" example index 0 1`] = ` ] `; +exports[`runs examples > example "stut" example index 0 1`] = ` +[ + "[ 0/1 → 1/2 | s:bd ]", + "[ 1/2 → 1/1 | s:sd ]", + "[ -1/3 ⇜ (0/1 → 1/6) | s:sd ]", + "[ 1/6 → 2/3 | s:bd ]", + "[ (2/3 → 1/1) ⇝ 7/6 | s:sd ]", + "[ -1/6 ⇜ (0/1 → 1/3) | s:sd ]", + "[ 1/3 → 5/6 | s:bd ]", + "[ (5/6 → 1/1) ⇝ 4/3 | s:sd ]", + "[ 1/1 → 3/2 | s:bd ]", + "[ 3/2 → 2/1 | s:sd ]", + "[ 2/3 ⇜ (1/1 → 7/6) | s:sd ]", + "[ 7/6 → 5/3 | s:bd ]", + "[ (5/3 → 2/1) ⇝ 13/6 | s:sd ]", + "[ 5/6 ⇜ (1/1 → 4/3) | s:sd ]", + "[ 4/3 → 11/6 | s:bd ]", + "[ (11/6 → 2/1) ⇝ 7/3 | s:sd ]", + "[ 2/1 → 5/2 | s:bd ]", + "[ 5/2 → 3/1 | s:sd ]", + "[ 5/3 ⇜ (2/1 → 13/6) | s:sd ]", + "[ 13/6 → 8/3 | s:bd ]", + "[ (8/3 → 3/1) ⇝ 19/6 | s:sd ]", + "[ 11/6 ⇜ (2/1 → 7/3) | s:sd ]", + "[ 7/3 → 17/6 | s:bd ]", + "[ (17/6 → 3/1) ⇝ 10/3 | s:sd ]", + "[ 3/1 → 7/2 | s:bd ]", + "[ 7/2 → 4/1 | s:sd ]", + "[ 8/3 ⇜ (3/1 → 19/6) | s:sd ]", + "[ 19/6 → 11/3 | s:bd ]", + "[ (11/3 → 4/1) ⇝ 25/6 | s:sd ]", + "[ 17/6 ⇜ (3/1 → 10/3) | s:sd ]", + "[ 10/3 → 23/6 | s:bd ]", + "[ (23/6 → 4/1) ⇝ 13/3 | s:sd ]", +] +`; + exports[`runs examples > example "sub" example index 0 1`] = ` [ "[ 0/1 → 1/3 | note:C4 ]",