doc: iter

This commit is contained in:
Felix Roos 2022-09-19 23:19:39 +02:00
parent cc394d9f74
commit abe28367fb
2 changed files with 12 additions and 0 deletions

View File

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

View File

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