doc: chunk + chunkBack

This commit is contained in:
Felix Roos 2022-09-19 23:30:37 +02:00
parent e4f4fe81ae
commit 5d699496ca
2 changed files with 20 additions and 0 deletions

View File

@ -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);
}

View File

@ -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.