diff --git a/repl/src/tutorial/tutorial.mdx b/repl/src/tutorial/tutorial.mdx index 49a739f5..05dc1012 100644 --- a/repl/src/tutorial/tutorial.mdx +++ b/repl/src/tutorial/tutorial.mdx @@ -218,7 +218,7 @@ The following functions will return a pattern. We will see later what that means To create a pattern from a value, you can wrap the value in pure: - + Most of the time, you won't need that function as input values of pattern creating functions are purified by default. @@ -349,24 +349,108 @@ Note that late is called directly. This is a shortcut for: Adds the given number to each item in the pattern: - +").scale('C major')`} /> -### Functions not documented yet +Here, the triad `0, 2, 4` is shifted by different amounts. Without add, the equivalent would be: -- add -- sub -- sub -- mul -- div -- union -- every -- when -- off -- jux -- append -- superimpose -- internal Pattern functions? -- struct +".scale('C major')`} /> + +You can also use add with notes: + +")`} /> + +Behind the scenes, the notes are converted to midi numbers as soon before add is applied, which is equivalent to: + +")`} /> + +### sub(n) + +Like add, but the given numbers are subtracted: + +").scale('C4 minor')`} /> + +See add for more information. + +### mul(n) + +Multiplies each number by the given factor: + +").scale('C4 minor')`} /> + +... is equivalent to: + +".scale('C4 minor')`} /> + +This function is really useful in combination with signals: + + + +Here, we sample a sine wave 16 times, and multiply each sample by 7. This way, we let values oscillate between 0 and 7. + +### div(n) + +Like mul, but dividing by the given number. + +### round() + +Rounds all values to the nearest integer: + + + +### struct(binary_pat) + +Applies the given structure to the pattern: + + + +This is also useful to sample signals: + + + +### when(binary_pat, func) + +Applies the given function whenever the given pattern is in a true state. + +/2", sub(5))`} /> + +### superimpose(...func) + +Superimposes the result of the given function(s) on top of the original pattern: + +".scale('C minor').superimpose(scaleTranspose("2,4"))`} /> + +### layer(...func) + +Layers the result of the given function(s) on top of each other. Like superimpose, but the original pattern is not part of the result. + +".scale('C minor').layer(scaleTranspose("0,2,4"))`} /> + +### apply(func) + +Like layer, but with a single function: + +".scale('C minor').apply(scaleTranspose("0,2,4"))`} /> + +### off(time, func) + +Applies the given function by the given time offset: + + + +### append(pat) + +Appends the given pattern after the current pattern: + + + +### stack(pat) + +Stacks the given pattern to the current pattern: + + ## Tone API @@ -407,10 +491,51 @@ const monosynth = (options) => new MonoSynth(options); const noise = (options) => new NoiseSynth(options); const pluck = (options) => new PluckSynth(options); const polysynth = (options) => new PolySynth(options); -const sampler = (options) => new Sampler(options); const synth = (options) => new Synth(options); +const sampler = (options, baseUrl?) => new Sampler(options); // promisified, see below +const players = (options, baseUrl?) => new Sampler(options); // promisified, see below ``` +### sampler + +With sampler, you can create tonal instruments from samples: + + + saw.struct("x*8").mul(16).round() + .legato(4).scale('D dorian').slow(2) + .tone(kalimba.toDestination()) +)`} +/> + +The sampler function promisifies [Tone.js Sampler](https://tonejs.github.io/docs/14.7.77/Sampler). + +Note that this function currently only works with this promise notation, but in the future, +it will be possible to use async instruments in a synchronous fashion. + +### players + +With players, you can create sound banks: + + + "bd hh sn hh".tone(drums.toDestination()) +) + `} +/> + +The sampler function promisifies [Tone.js Players](https://tonejs.github.io/docs/14.7.77/Players). + +Note that this function currently only works with this promise notation, but in the future, +it will be possible to use async instruments in a synchronous fashion. + ### out Shortcut for Tone.Destination. Intended to be used with Tone's .chain: @@ -587,6 +712,10 @@ Together with edit, struct and voicings, this can be used to create a basic back +## Microtonal API + +TODO + ## MIDI API Strudel also supports midi via [webmidi](https://npmjs.com/package/webmidi).