mirror of
https://github.com/eliasstepanik/strudel-docker.git
synced 2026-01-21 10:38:37 +00:00
Documentation for all/each, and bugfix for each (#1233)
* bugfix for each(), and documentation for each() and all() * had to hide each/all examples from tests
This commit is contained in:
parent
9bf0f624f5
commit
1e3bbc57cc
@ -86,10 +86,33 @@ export function repl({
|
|||||||
const toggle = () => scheduler.toggle();
|
const toggle = () => scheduler.toggle();
|
||||||
const setCps = (cps) => scheduler.setCps(cps);
|
const setCps = (cps) => scheduler.setCps(cps);
|
||||||
const setCpm = (cpm) => scheduler.setCps(cpm / 60);
|
const setCpm = (cpm) => scheduler.setCps(cpm / 60);
|
||||||
|
|
||||||
|
// TODO - not documented as jsdoc examples as the test framework doesn't simulate enough context for `each` and `all`..
|
||||||
|
|
||||||
|
/** Applies a function to all the running patterns. Note that the patterns are groups together into a single `stack` before the function is applied. This is probably what you want, but see `each` for
|
||||||
|
* a version that applies the function to each pattern separately.
|
||||||
|
* ```
|
||||||
|
* $: sound("bd - cp sd")
|
||||||
|
* $: sound("hh*8")
|
||||||
|
* all(fast("<2 3>"))
|
||||||
|
* ```
|
||||||
|
* ```
|
||||||
|
* $: sound("bd - cp sd")
|
||||||
|
* $: sound("hh*8")
|
||||||
|
* all(x => x.pianoroll())
|
||||||
|
* ```
|
||||||
|
*/
|
||||||
const all = function (transform) {
|
const all = function (transform) {
|
||||||
allTransform = transform;
|
allTransform = transform;
|
||||||
return silence;
|
return silence;
|
||||||
};
|
};
|
||||||
|
/** Applies a function to each of the running patterns separately. This is intended for future use with upcoming 'stepwise' features. See `all` for a version that applies the function to all the patterns stacked together into a single pattern.
|
||||||
|
* ```
|
||||||
|
* $: sound("bd - cp sd")
|
||||||
|
* $: sound("hh*8")
|
||||||
|
* each(fast("<2 3>"))
|
||||||
|
* ```
|
||||||
|
*/
|
||||||
const each = function (transform) {
|
const each = function (transform) {
|
||||||
eachTransform = transform;
|
eachTransform = transform;
|
||||||
return silence;
|
return silence;
|
||||||
@ -161,7 +184,8 @@ export function repl({
|
|||||||
if (Object.keys(pPatterns).length) {
|
if (Object.keys(pPatterns).length) {
|
||||||
let patterns = Object.values(pPatterns);
|
let patterns = Object.values(pPatterns);
|
||||||
if (eachTransform) {
|
if (eachTransform) {
|
||||||
patterns = patterns.map(eachTransform);
|
// Explicit lambda so only element (not index and array) are passed
|
||||||
|
patterns = patterns.map((x) => eachTransform(x));
|
||||||
}
|
}
|
||||||
pattern = stack(...patterns);
|
pattern = stack(...patterns);
|
||||||
} else if (eachTransform) {
|
} else if (eachTransform) {
|
||||||
|
|||||||
@ -58,8 +58,8 @@ export function Reference() {
|
|||||||
<div className="prose dark:prose-invert min-w-full px-1 ">
|
<div className="prose dark:prose-invert min-w-full px-1 ">
|
||||||
<h2>API Reference</h2>
|
<h2>API Reference</h2>
|
||||||
<p>
|
<p>
|
||||||
This is the long list functions you can use! Remember that you don't need to remember all of those and that
|
This is the long list of functions you can use. Remember that you don't need to remember all of those and
|
||||||
you can already make music with a small set of functions!
|
that you can already make music with a small set of functions!
|
||||||
</p>
|
</p>
|
||||||
{visibleFunctions.map((entry, i) => (
|
{visibleFunctions.map((entry, i) => (
|
||||||
<section key={i}>
|
<section key={i}>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user