docs: improve time modifiers page

+ polymeter + euclidRot
+ rename Factories to Pattern Constructors
This commit is contained in:
Felix Roos 2023-01-09 20:39:00 +01:00
parent 9ca5f9ad48
commit 10ee11c886
6 changed files with 77 additions and 48 deletions

View File

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

View File

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

View File

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

View File

@ -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:
<MiniRepl
client:idle
tune={`cat(
stack(g3,b3,e4),
stack(a3,c3,e4),
stack(b3,d3,fs4),
stack(b3,e4,g4)
).note()`}
/>
...is equivalent to:
<MiniRepl
client:idle
tune={`cat(
"g3,b3,e4",
"a3,c3,e4",
"b3,d3,f#4",
"b3,e4,g4"
).note()`}
/>
... as well as:
<MiniRepl client:only="react" tune={`note("<[g3,b3,e4] [a3,c3,e4] [b3,d3,f#4] [b3,e4,g4]>")`} />
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.

View File

@ -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
<JsDoc client:idle name="polymeterSteps" h={0} />
# Combining Patterns
You can freely mix JS patterns, mini patterns and values! For example, this pattern:
<MiniRepl
client:idle
tune={`cat(
stack(g3,b3,e4),
stack(a3,c3,e4),
stack(b3,d3,fs4),
stack(b3,e4,g4)
).note()`}
/>
...is equivalent to:
<MiniRepl
client:idle
tune={`cat(
"g3,b3,e4",
"a3,c3,e4",
"b3,d3,f#4",
"b3,e4,g4"
).note()`}
/>
... as well as:
<MiniRepl client:only="react" tune={`note("<[g3,b3,e4] [a3,c3,e4] [b3,d3,f#4] [b3,e4,g4]>")`} />
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.

View File

@ -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.
<JsDoc client:idle name="Pattern.euclid" h={0} />
## euclidLegato
### euclidRot
<JsDoc client:idle name="Pattern.euclidRot" h={0} />
### euclidLegato
<JsDoc client:idle name="Pattern.euclidLegato" h={0} />
@ -51,11 +62,11 @@ The following functions modify a pattern temporal structure in some way.
<JsDoc client:idle name="Pattern.iter" h={0} />
## iterBack
### iterBack
<JsDoc client:idle name="Pattern.iterBack" h={0} />
### chunk
## chunk
<JsDoc client:idle name="Pattern.chunk" h={0} />