diff --git a/packages/core/euclid.mjs b/packages/core/euclid.mjs index 6a5be89b..6aa2283d 100644 --- a/packages/core/euclid.mjs +++ b/packages/core/euclid.mjs @@ -73,7 +73,7 @@ const bjork = function (ons, steps) { */ /** - * Like `iter`, but has an additional parameter for 'rotating' the resulting sequence. + * Like `euclid`, but has an additional parameter for 'rotating' the resulting sequence. * @memberof Pattern * @name euclidRot * @param {number} pulses the number of onsets / beats diff --git a/packages/core/pattern.mjs b/packages/core/pattern.mjs index 6ced2bae..17187bd6 100644 --- a/packages/core/pattern.mjs +++ b/packages/core/pattern.mjs @@ -1215,7 +1215,17 @@ function _sequenceCount(x) { } return [reify(x), 1]; } - +/** + * Aligns one or more given sequences to the given number of steps per cycle. + * + * @name polymeterSteps + * @param {number} steps how many items are placed in one cycle + * @param {any[]} sequences one or more arrays of Patterns / values + * @example + * polymeterSteps(2, ["c", "d", "e", "f", "g", "f", "e", "d"]) + * .note().stack(s("bd")) // 1 cycle = 1 bd = 2 notes + * // note("{c d e f g f e d}%2").stack(s("bd")) + */ export function polymeterSteps(steps, ...args) { const seqs = args.map((a) => _sequenceCount(a)); if (seqs.length == 0) { @@ -1238,6 +1248,14 @@ export function polymeterSteps(steps, ...args) { return stack(...pats); } +/** + * Combines the given lists of patterns with the same pulse. This will create so called polymeters when different sized sequences are used. + * @name polymeter + * @example + * polymeter(["c", "eb", "g"], ["c2", "g2"]).note() + * // "{c eb g, c2 g2}".note() + * + */ export function polymeter(...args) { return polymeterSteps(0, ...args); } diff --git a/website/src/config.ts b/website/src/config.ts index 5290d65c..3d5c6069 100644 --- a/website/src/config.ts +++ b/website/src/config.ts @@ -55,14 +55,14 @@ export const SIDEBAR: Sidebar = { { text: 'Synths', link: 'learn/synths' }, { text: 'Audio Effects', link: 'learn/effects' }, ], - Functions: [ + 'Pattern Functions': [ { text: 'Introduction', link: 'functions/intro' }, - { text: 'Value Modifiers', link: 'functions/value-modifiers' }, - { text: 'Factories', link: 'learn/factories' }, - { text: 'Signals', link: 'learn/signals' }, + { text: 'Pattern Constructors', link: 'learn/factories' }, { text: 'Time Modifiers', link: 'learn/time-modifiers' }, + { text: 'Value Modifiers', link: 'functions/value-modifiers' }, + { text: 'Signals', link: 'learn/signals' }, { text: 'Conditional Modifiers', link: 'learn/conditional-modifiers' }, - { text: 'Tonal', link: 'learn/tonal' }, + { text: 'Tonal Modifiers', link: 'learn/tonal' }, ], More: [ { text: 'Patterns', link: 'technical-manual/patterns' }, diff --git a/website/src/pages/functions/intro.mdx b/website/src/pages/functions/intro.mdx index 2e507e40..bed3cb37 100644 --- a/website/src/pages/functions/intro.mdx +++ b/website/src/pages/functions/intro.mdx @@ -38,3 +38,36 @@ While the Mini Notation is a powerful way to write rhythms shortly, it also has Here, we are using mini notation for the individual rhythms, while using the function `stack` to mix them. While stack is also available as `,` in mini notation, we cannot use it here, because we have different types of sounds. + +## Combining Patterns + +You can freely mix JS patterns, mini patterns and values! For example, this pattern: + + + +...is equivalent to: + + + +... as well as: + +")`} /> + +While mini notation is almost always shorter, it only has a handful of modifiers: \* / ! @. +When using JS patterns, there is a lot more you can do. diff --git a/website/src/pages/learn/factories.mdx b/website/src/pages/learn/factories.mdx index 03da950a..7bce19df 100644 --- a/website/src/pages/learn/factories.mdx +++ b/website/src/pages/learn/factories.mdx @@ -1,5 +1,5 @@ --- -title: Pattern Factories +title: Pattern Constructors description: Strudel Tutorial layout: ../../layouts/MainLayout.astro --- @@ -7,10 +7,10 @@ layout: ../../layouts/MainLayout.astro import { MiniRepl } from '../../docs/MiniRepl'; import { JsDoc } from '../../docs/JsDoc'; -# Pattern Factories +# Pattern Constructors The following functions will return a pattern. -Most of these are also used by the Mini Notation: +These are the equivalents used by the Mini Notation: | function | mini | | ------------------------------ | ---------------- | @@ -56,36 +56,3 @@ As a chained function: ## polymeterSteps - -# Combining Patterns - -You can freely mix JS patterns, mini patterns and values! For example, this pattern: - - - -...is equivalent to: - - - -... as well as: - -")`} /> - -While mini notation is almost always shorter, it only has a handful of modifiers: \* / ! @. -When using JS patterns, there is a lot more you can do. diff --git a/website/src/pages/learn/time-modifiers.mdx b/website/src/pages/learn/time-modifiers.mdx index 7e41ed34..c24d5961 100644 --- a/website/src/pages/learn/time-modifiers.mdx +++ b/website/src/pages/learn/time-modifiers.mdx @@ -1,6 +1,5 @@ --- -title: Pattern Factories -description: Strudel Tutorial +title: Time Modifiers layout: ../../layouts/MainLayout.astro --- @@ -10,6 +9,14 @@ import { JsDoc } from '../../docs/JsDoc'; # Time Modifiers The following functions modify a pattern temporal structure in some way. +Some of these have equivalent operators in the Mini Notation: + +| function | mini | +| ---------------------- | ------------ | +| `"x".slow(2)` | `"x/2"` | +| `"x".fast(2)` | `"x*2"` | +| `"x".euclid(3,8)` | `"x(3,8)"` | +| `"x".euclidRot(3,8,1)` | `"x(3,8,1)"` | ## slow @@ -39,7 +46,11 @@ The following functions modify a pattern temporal structure in some way. -## euclidLegato +### euclidRot + + + +### euclidLegato @@ -51,11 +62,11 @@ The following functions modify a pattern temporal structure in some way. -## iterBack +### iterBack -### chunk +## chunk