From 505cc01a18a48d295656c8e13575143a11256ea5 Mon Sep 17 00:00:00 2001 From: Felix Roos Date: Sat, 17 Sep 2022 23:59:16 +0200 Subject: [PATCH 1/5] remove empty heading --- tutorial/tutorial.mdx | 2 -- 1 file changed, 2 deletions(-) diff --git a/tutorial/tutorial.mdx b/tutorial/tutorial.mdx index 48db137a..6eaf1d58 100644 --- a/tutorial/tutorial.mdx +++ b/tutorial/tutorial.mdx @@ -593,8 +593,6 @@ Like layer, but with a single function: Signals are patterns with continuous values, meaning they have theoretically infinite steps. They can provide streams of numbers that can be sampled at discrete points in time. -## - {{ 'saw' | jsdoc }} {{ 'sine' | jsdoc }} From cc394d9f743c2150aa5f78bec5c2df09942460e2 Mon Sep 17 00:00:00 2001 From: Felix Roos Date: Mon, 19 Sep 2022 23:13:36 +0200 Subject: [PATCH 2/5] 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 }} From abe28367fbd8e3ba2a863cfb89890f7d152305da Mon Sep 17 00:00:00 2001 From: Felix Roos Date: Mon, 19 Sep 2022 23:19:39 +0200 Subject: [PATCH 3/5] doc: iter --- packages/core/pattern.mjs | 10 ++++++++++ tutorial/tutorial.mdx | 2 ++ 2 files changed, 12 insertions(+) diff --git a/packages/core/pattern.mjs b/packages/core/pattern.mjs index bfe3d6de..3d761dc3 100644 --- a/packages/core/pattern.mjs +++ b/packages/core/pattern.mjs @@ -1165,6 +1165,16 @@ export class Pattern { return this._echoWith(times, time, (pat, i) => pat.velocity(Math.pow(feedback, i))); } + /** + * Divides a pattern into a given number of subdivisions, plays the subdivisions in order, but increments the starting subdivision each cycle. The pattern wraps to the first subdivision after the last subdivision is played. + * @name iter + * @memberof Pattern + * @returns Pattern + * @param {number} divide number of subdivisions + * @param {boolean} back if true, iterate backwards + * @example + * note("0 1 2 3".scale('A minor')).iter(4).out() + */ iter(times, back = false) { return slowcat(...listRange(0, times - 1).map((i) => (back ? this.late(i / times) : this.early(i / times)))); } diff --git a/tutorial/tutorial.mdx b/tutorial/tutorial.mdx index eec97f80..1f1c02a0 100644 --- a/tutorial/tutorial.mdx +++ b/tutorial/tutorial.mdx @@ -502,6 +502,8 @@ The following functions modify a pattern temporal structure in some way. {{ 'Pattern.legato' | jsdoc }} +{{ 'Pattern.iter' | jsdoc }} + ## Conditional Modifiers {{ 'Pattern.every' | jsdoc }} From e4f4fe81aed0ef44f8c1d0da123ee3186ddf9b1d Mon Sep 17 00:00:00 2001 From: Felix Roos Date: Mon, 19 Sep 2022 23:21:55 +0200 Subject: [PATCH 4/5] doc: iterBack --- packages/core/pattern.mjs | 11 ++++++++--- tutorial/tutorial.mdx | 2 ++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/packages/core/pattern.mjs b/packages/core/pattern.mjs index 3d761dc3..86f6405f 100644 --- a/packages/core/pattern.mjs +++ b/packages/core/pattern.mjs @@ -1170,8 +1170,6 @@ export class Pattern { * @name iter * @memberof Pattern * @returns Pattern - * @param {number} divide number of subdivisions - * @param {boolean} back if true, iterate backwards * @example * note("0 1 2 3".scale('A minor')).iter(4).out() */ @@ -1179,7 +1177,14 @@ export class Pattern { return slowcat(...listRange(0, times - 1).map((i) => (back ? this.late(i / times) : this.early(i / times)))); } - // known as iter' in tidalcycles + /** + * Like `iter`, but plays the subdivisions in reverse order. Known as iter' in tidalcycles + * @name iterBack + * @memberof Pattern + * @returns Pattern + * @example + * note("0 1 2 3".scale('A minor')).iterBack(4).out() + */ iterBack(times) { return this.iter(times, true); } diff --git a/tutorial/tutorial.mdx b/tutorial/tutorial.mdx index 1f1c02a0..4c92bf84 100644 --- a/tutorial/tutorial.mdx +++ b/tutorial/tutorial.mdx @@ -504,6 +504,8 @@ The following functions modify a pattern temporal structure in some way. {{ 'Pattern.iter' | jsdoc }} +{{ 'Pattern.iterBack' | jsdoc }} + ## Conditional Modifiers {{ 'Pattern.every' | jsdoc }} From 5d699496ca1f0bc1bccfda0b4d5bca63da9185b8 Mon Sep 17 00:00:00 2001 From: Felix Roos Date: Mon, 19 Sep 2022 23:30:37 +0200 Subject: [PATCH 5/5] doc: chunk + chunkBack --- packages/core/pattern.mjs | 16 ++++++++++++++++ tutorial/tutorial.mdx | 4 ++++ 2 files changed, 20 insertions(+) diff --git a/packages/core/pattern.mjs b/packages/core/pattern.mjs index 86f6405f..2950d015 100644 --- a/packages/core/pattern.mjs +++ b/packages/core/pattern.mjs @@ -1189,6 +1189,14 @@ export class Pattern { return this.iter(times, true); } + /** + * Divides a pattern into a given number of parts, then cycles through those parts in turn, applying the given function to each part in turn (one part per cycle). + * @name chunk + * @memberof Pattern + * @returns Pattern + * @example + * "0 1 2 3".chunk(4, x=>x.add(7)).scale('A minor').note().out() + */ _chunk(n, func, back = false) { const binary = Array(n - 1).fill(false); binary.unshift(true); @@ -1196,6 +1204,14 @@ export class Pattern { return this.when(binary_pat, func); } + /** + * Like `chunk`, but cycles through the parts in reverse order. Known as chunk' in tidalcycles + * @name chunkBack + * @memberof Pattern + * @returns Pattern + * @example + * "0 1 2 3".chunkBack(4, x=>x.add(7)).scale('A minor').note().out() + */ _chunkBack(n, func) { return this._chunk(n, func, true); } diff --git a/tutorial/tutorial.mdx b/tutorial/tutorial.mdx index 4c92bf84..61c6e398 100644 --- a/tutorial/tutorial.mdx +++ b/tutorial/tutorial.mdx @@ -596,6 +596,10 @@ Like layer, but with a single function: {{ 'Pattern.range' | jsdoc }} +{{ 'Pattern.chunk' | jsdoc }} + +{{ 'Pattern.chunkBack' | jsdoc }} + ## Continuous Signals Signals are patterns with continuous values, meaning they have theoretically infinite steps.