Docs: add example of custom chained function

This adds a subsection to the "Understand/Coding Syntax" documentation that shows a simple example of converting the previous chain of effects into a custom, reusable chained function. There's also a prompt for the reader to experiment.
This commit is contained in:
Darius Kazemi
2025-10-11 17:40:55 -07:00
parent 7eebf3a466
commit 0065db8569
+19
View File
@@ -60,6 +60,25 @@ Strudel makes heavy use of chained functions. Here is a more sophisticated examp
.room(0.5)`}
/>
## Write your own chained function
You can write your own chained function using `register`. Here's the above chain but registered as a reusable, chained function.
<MiniRepl
client:idle
tune={`const effectChain = register('effectChain',
(pat) => pat
.s("sawtooth")
.cutoff(500)
//.delay(0.5)
.room(0.5)
);
note("a3 c#4 e4 a4").effectChain()
`}
/>
Try adding `.rev()` after `effectChain()` to see further effects added.
# Comments
The `//` in the example above is a line comment, resulting in the `delay` function being ignored.