diff --git a/packages/core/pattern.mjs b/packages/core/pattern.mjs index f2bbf069d..d8bbf6300 100644 --- a/packages/core/pattern.mjs +++ b/packages/core/pattern.mjs @@ -2405,7 +2405,7 @@ export const { echoWith, echowith, stutWith, stutwith } = register( * s("bd sd").echo(3, 1/6, .8) */ export const echo = register('echo', function (times, time, feedback, pat) { - return pat._echoWith(times, time, (pat, i) => pat.gain(Math.pow(feedback, i))); + return pat._echoForEach(times, time, (pat, i) => pat.gain(Math.pow(feedback, i))); }); /** @@ -2418,7 +2418,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._echoWith(times, time, (pat, i) => pat.gain(Math.pow(feedback, i))); + return pat._echoForEach(times, time, (pat, i) => pat.gain(Math.pow(feedback, i))); }); export const applyN = register('applyN', function (n, func, p) { diff --git a/test/__snapshots__/examples.test.mjs.snap b/test/__snapshots__/examples.test.mjs.snap index 46359b620..22d324027 100644 --- a/test/__snapshots__/examples.test.mjs.snap +++ b/test/__snapshots__/examples.test.mjs.snap @@ -3301,20 +3301,28 @@ exports[`runs examples > example "echo" example index 0 1`] = ` ] `; +exports[`runs examples > example "echoForEach" example index 0 1`] = `[]`; + exports[`runs examples > example "echoWith" example index 0 1`] = ` [ "[ -3/8 ⇜ (0/1 → 1/8) | note:Bb3 ]", - "[ -1/4 ⇜ (0/1 → 1/4) | note:D4 ]", - "[ -1/8 ⇜ (0/1 → 3/8) | note:F4 ]", + "[ -1/4 ⇜ (0/1 → 1/8) ⇝ 1/4 | note:D4 ]", + "[ -1/8 ⇜ (0/1 → 1/8) ⇝ 3/8 | note:F4 ]", "[ 0/1 → 1/1 | note:C3 ]", + "[ -1/4 ⇜ (1/8 → 1/4) | note:D4 ]", + "[ -1/8 ⇜ (1/8 → 1/4) ⇝ 3/8 | note:F4 ]", "[ (1/8 → 1/1) ⇝ 9/8 | note:Eb3 ]", + "[ -1/8 ⇜ (1/4 → 3/8) | note:F4 ]", "[ (1/4 → 1/1) ⇝ 5/4 | note:G3 ]", "[ (3/8 → 1/1) ⇝ 11/8 | note:Bb3 ]", "[ 1/8 ⇜ (1/1 → 9/8) | note:Eb3 ]", - "[ 1/4 ⇜ (1/1 → 5/4) | note:G3 ]", - "[ 3/8 ⇜ (1/1 → 11/8) | note:Bb3 ]", + "[ 1/4 ⇜ (1/1 → 9/8) ⇝ 5/4 | note:G3 ]", + "[ 3/8 ⇜ (1/1 → 9/8) ⇝ 11/8 | note:Bb3 ]", "[ 1/1 → 3/2 | note:Eb3 ]", + "[ 1/4 ⇜ (9/8 → 5/4) | note:G3 ]", + "[ 3/8 ⇜ (9/8 → 5/4) ⇝ 11/8 | note:Bb3 ]", "[ 9/8 → 13/8 | note:G3 ]", + "[ 3/8 ⇜ (5/4 → 11/8) | note:Bb3 ]", "[ 5/4 → 7/4 | note:Bb3 ]", "[ 11/8 → 15/8 | note:D4 ]", "[ 3/2 → 2/1 | note:G3 ]", @@ -3322,17 +3330,23 @@ exports[`runs examples > example "echoWith" example index 0 1`] = ` "[ (7/4 → 2/1) ⇝ 9/4 | note:D4 ]", "[ (15/8 → 2/1) ⇝ 19/8 | note:F4 ]", "[ 13/8 ⇜ (2/1 → 17/8) | note:Bb3 ]", - "[ 7/4 ⇜ (2/1 → 9/4) | note:D4 ]", - "[ 15/8 ⇜ (2/1 → 19/8) | note:F4 ]", + "[ 7/4 ⇜ (2/1 → 17/8) ⇝ 9/4 | note:D4 ]", + "[ 15/8 ⇜ (2/1 → 17/8) ⇝ 19/8 | note:F4 ]", "[ 2/1 → 3/1 | note:C3 ]", + "[ 7/4 ⇜ (17/8 → 9/4) | note:D4 ]", + "[ 15/8 ⇜ (17/8 → 9/4) ⇝ 19/8 | note:F4 ]", "[ (17/8 → 3/1) ⇝ 25/8 | note:Eb3 ]", + "[ 15/8 ⇜ (9/4 → 19/8) | note:F4 ]", "[ (9/4 → 3/1) ⇝ 13/4 | note:G3 ]", "[ (19/8 → 3/1) ⇝ 27/8 | note:Bb3 ]", "[ 17/8 ⇜ (3/1 → 25/8) | note:Eb3 ]", - "[ 9/4 ⇜ (3/1 → 13/4) | note:G3 ]", - "[ 19/8 ⇜ (3/1 → 27/8) | note:Bb3 ]", + "[ 9/4 ⇜ (3/1 → 25/8) ⇝ 13/4 | note:G3 ]", + "[ 19/8 ⇜ (3/1 → 25/8) ⇝ 27/8 | note:Bb3 ]", "[ 3/1 → 7/2 | note:Eb3 ]", + "[ 9/4 ⇜ (25/8 → 13/4) | note:G3 ]", + "[ 19/8 ⇜ (25/8 → 13/4) ⇝ 27/8 | note:Bb3 ]", "[ 25/8 → 29/8 | note:G3 ]", + "[ 19/8 ⇜ (13/4 → 27/8) | note:Bb3 ]", "[ 13/4 → 15/4 | note:Bb3 ]", "[ 27/8 → 31/8 | note:D4 ]", "[ 7/2 → 4/1 | note:G3 ]", diff --git a/website/src/repl/tunes.mjs b/website/src/repl/tunes.mjs index f1c72b12d..bdae9b33e 100644 --- a/website/src/repl/tunes.mjs +++ b/website/src/repl/tunes.mjs @@ -285,7 +285,7 @@ stack( .mul(gain(sine.struct("x*8").add(3/5).mul(2/5).fast(8))) .piano()`; -// iter, echo, echoWith +// iter, echo, echoForEach export const undergroundPlumber = `// "Underground plumber" // @license CC BY-NC-SA 4.0 https://creativecommons.org/licenses/by-nc-sa/4.0/ // @by Felix Roos @@ -307,7 +307,7 @@ stack( .cutoff(400).decay(.12).sustain(0) , "[g2,[c3 eb3]]".iter(4) - .echoWith(4, 1/8, (x,n)=>x.transpose(n*12).gain(Math.pow(.4,n))) + .echoForEach(4, 1/8, (x,n)=>x.transpose(n*12).gain(Math.pow(.4,n))) .note().layer(h) .clip(.1) ) @@ -432,7 +432,7 @@ export const festivalOfFingers3 = `// "Festival of fingers 3" setcps(1) n("[-7*3],0,2,6,[8 7]") - .echoWith( + .echoForEach( 4, // echo 4 times 1/4, // 1/4s between echos (x,i)=>x @@ -485,7 +485,7 @@ stack( .decay(.1).sustain(0) // make notes short .s('triangle') // waveform .degradeBy(perlin.range(0,.5)) // randomly controlled random removal :) - .echoWith(4,.125,(x,n)=>x.gain(.15*1/(n+1))) // echo notes + .echoForEach(4,.125,(x,n)=>x.gain(.15*1/(n+1))) // echo notes //.hush() ) .slow(3/2)`;