add more synonyms

This commit is contained in:
Felix Roos 2023-01-12 17:40:58 +01:00
parent 68cc109933
commit ee9b89b6d5
5 changed files with 35 additions and 24 deletions

View file

@ -1903,19 +1903,10 @@ export const jux = register('jux', function (func, pat) {
return pat._juxBy(1, func, pat);
});
export const { stutWith, stutwith } = register(['stutWith', 'stutwith'], function (times, time, func, pat) {
return stack(...listRange(0, times - 1).map((i) => func(pat.late(Fraction(time).mul(i)), i)));
});
export const stut = register('stut', function (times, feedback, time, pat) {
return pat._stutWith(times, time, (pat, i) => pat.velocity(Math.pow(feedback, i)));
});
/**
* Superimpose and offset multiple times, applying the given function each time.
* @name echoWith
* @memberof Pattern
* @returns Pattern
* @synonyms echowith, stutWith, stutwith
* @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
@ -1928,6 +1919,9 @@ export const { echoWith, echowith } = register(['echoWith', 'echowith'], functio
return stack(...listRange(0, times - 1).map((i) => func(pat.late(Fraction(time).mul(i)), i)));
});
export const stutWith = echoWith;
export const stutwith = echoWith;
/**
* Superimpose and offset multiple times, gradually decreasing the velocity
* @name echo
@ -1943,6 +1937,19 @@ export const echo = register('echo', function (times, time, feedback, pat) {
return pat._echoWith(times, time, (pat, i) => pat.velocity(Math.pow(feedback, i)));
});
/**
* Deprecated. Like echo, but the last 2 parameters are flipped.
* @name stut
* @param {number} times how many times to repeat
* @param {number} feedback velocity multiplicator for each iteration
* @param {number} time cycle offset between iterations
* @example
* s("bd sd").stut(3, .8, 1/6)
*/
export const stut = register('stut', function (times, feedback, time, pat) {
return pat._stutWith(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
@ -1968,6 +1975,7 @@ export const iter = register('iter', function (times, pat) {
/**
* Like `iter`, but plays the subdivisions in reverse order. Known as iter' in tidalcycles
* @name iterBack
* @synonyms iterback
* @memberof Pattern
* @returns Pattern
* @example
@ -1999,6 +2007,7 @@ export const chunk = register('chunk', function (n, func, pat) {
/**
* Like `chunk`, but cycles through the parts in reverse order. Known as chunk' in tidalcycles
* @name chunkBack
* @synonyms chunkback
* @memberof Pattern
* @returns Pattern
* @example
@ -2011,7 +2020,7 @@ export const { chunkBack, chunkback } = register(['chunkBack', 'chunkback'], fun
// TODO - redefine elsewhere in terms of mask
export const bypass = register('bypass', function (on, pat) {
on = Boolean(parseInt(on));
return on ? silence : this;
return on ? silence : pat;
});
// sets absolute duration of haps
@ -2020,7 +2029,10 @@ export const duration = register('duration', function (value, pat) {
return pat.withHapSpan((span) => new TimeSpan(span.begin, span.begin.add(value)));
});
// TODO - make control?
/**
* Sets the color of the hap in visualizations like pianoroll or highlighting.
*/
// TODO: move this to controls https://github.com/tidalcycles/strudel/issues/288
export const { color, colour } = register(['color', 'colour'], function (color, pat) {
return pat.withContext((context) => ({ ...context, color }));
});