From ee9b89b6d539d54045d4877f9b3f15dfa723ef57 Mon Sep 17 00:00:00 2001 From: Felix Roos Date: Thu, 12 Jan 2023 17:40:58 +0100 Subject: [PATCH] add more synonyms --- packages/core/controls.mjs | 7 +++-- packages/core/pattern.mjs | 36 ++++++++++++++++-------- undocumented.json | 6 ---- website/src/pages/learn/accumulation.mdx | 6 +++- website/src/pages/learn/effects.mdx | 4 +-- 5 files changed, 35 insertions(+), 24 deletions(-) diff --git a/packages/core/controls.mjs b/packages/core/controls.mjs index b156f721..b3537db9 100644 --- a/packages/core/controls.mjs +++ b/packages/core/controls.mjs @@ -621,14 +621,15 @@ const generic_params = [ /** * Sets the room size of the reverb, see {@link room}. * - * @name size + * @name roomsize + * @synonyms size * @param {number | Pattern} size between 0 and 10 * @example - * s("bd sd").room(.8).size("<0 1 2 4 8>") + * s("bd sd").room(.8).roomsize("<0 1 2 4 8>") * */ // TODO: find out why : - // s("bd sd").room(.8).size("<0 .2 .4 .6 .8 [1,0]>").osc() + // s("bd sd").room(.8).roomsize("<0 .2 .4 .6 .8 [1,0]>").osc() // .. does not work. Is it because room is only one effect? [ 'f', diff --git a/packages/core/pattern.mjs b/packages/core/pattern.mjs index 434ec0ae..ba4edafa 100644 --- a/packages/core/pattern.mjs +++ b/packages/core/pattern.mjs @@ -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 })); }); diff --git a/undocumented.json b/undocumented.json index 656fcc32..e7095fe1 100644 --- a/undocumented.json +++ b/undocumented.json @@ -78,12 +78,6 @@ "focusspan", "zoomArc", "zoomarc", - "stutWith", - "stutwith", - "stut", - "echowith", - "iterback", - "chunkback", "bypass", "duration", "color", diff --git a/website/src/pages/learn/accumulation.mdx b/website/src/pages/learn/accumulation.mdx index 9c793bd3..71761387 100644 --- a/website/src/pages/learn/accumulation.mdx +++ b/website/src/pages/learn/accumulation.mdx @@ -27,4 +27,8 @@ import { JsDoc } from '../../docs/JsDoc'; ## echoWith - + + +## stut + + diff --git a/website/src/pages/learn/effects.mdx b/website/src/pages/learn/effects.mdx index 04153437..6ef4e7d3 100644 --- a/website/src/pages/learn/effects.mdx +++ b/website/src/pages/learn/effects.mdx @@ -99,6 +99,6 @@ global effects use the same chain for all events of the same orbit: -## size / roomsize +## roomsize - +