From cc394d9f743c2150aa5f78bec5c2df09942460e2 Mon Sep 17 00:00:00 2001 From: Felix Roos Date: Mon, 19 Sep 2022 23:13:36 +0200 Subject: [PATCH] doc: echo + echoWith --- packages/core/pattern.mjs | 22 +++++++++++++++++++++- tutorial/tutorial.mdx | 4 ++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/packages/core/pattern.mjs b/packages/core/pattern.mjs index 9ff616cf..bfe3d6de 100644 --- a/packages/core/pattern.mjs +++ b/packages/core/pattern.mjs @@ -1136,11 +1136,31 @@ export class Pattern { return this.stutWith(times, time, (pat, i) => pat.velocity(Math.pow(feedback, i))); } - // these might change with: https://github.com/tidalcycles/Tidal/issues/902 + /** + * Superimpose and offset multiple times, applying the given function each time. + * @name echoWith + * @memberof Pattern + * @returns Pattern + * @param {number} times how many times to repeat + * @param {number} time cycle offset between iterations + * @param {function} func function to apply, given the pattern and the iteration index + * @example + * "<0 [2 4]>" + * .echoWith(4, 1/8, (p,n) => p.add(n*2)) + * .scale('C minor').note().legato(.2).out() + */ _echoWith(times, time, func) { return stack(...listRange(0, times - 1).map((i) => func(this.late(Fraction(time).mul(i)), i))); } + /** + * Superimpose and offset multiple times, gradually decreasing the velocity + * @name echo + * @memberof Pattern + * @returns Pattern + * @example + * s("bd sd").echo(3, 1/6, .8).out() + */ _echo(times, time, feedback) { return this._echoWith(times, time, (pat, i) => pat.velocity(Math.pow(feedback, i))); } diff --git a/tutorial/tutorial.mdx b/tutorial/tutorial.mdx index 6eaf1d58..eec97f80 100644 --- a/tutorial/tutorial.mdx +++ b/tutorial/tutorial.mdx @@ -520,6 +520,10 @@ The following functions modify a pattern temporal structure in some way. {{ 'Pattern.off' | jsdoc }} +{{ 'Pattern.echo' | jsdoc }} + +{{ 'Pattern.echoWith' | jsdoc }} + ## Concat Modifiers {{ 'Pattern.seq' | jsdoc }}