diff --git a/repl/src/tutorial/tutorial.mdx b/repl/src/tutorial/tutorial.mdx index 98502dcc..50a4a2b3 100644 --- a/repl/src/tutorial/tutorial.mdx +++ b/repl/src/tutorial/tutorial.mdx @@ -371,7 +371,158 @@ TODO: should the function really run the first cycle? ## Tone API -TODO, see https://github.com/tidalcycles/strudel/blob/main/repl/src/tone.ts +To make the sounds more interesting, we can use Tone.js instruments ands effects. + +[Show Source on Github](https://github.com/tidalcycles/strudel/blob/main/repl/src/tone.ts) + + + +### tone(instrument) + +To change the instrument of a pattern, you can pass any [Tone.js Source](https://tonejs.github.io/docs/14.7.77/index.html) to .tone: + + + +While this works, it is a little bit verbose. To simplify things, all Tone Synths have a shortcut: + +```js +const amsynth = (options) => new AMSynth(options); +const duosynth = (options) => new DuoSynth(options); +const fmsynth = (options) => new FMSynth(options); +const membrane = (options) => new MembraneSynth(options); +const metal = (options) => new MetalSynth(options); +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); +``` + +### out + +Shortcut for Tone.Destination. Intended to be used with Tone's .chain: + + + +This alone is not really useful, so read on.. + +### vol(volume) + +Helper that returns a Gain Node with the given volume. Intended to be used with Tone's .chain: + + + +### osc(type) + +Helper to set the waveform of a synth, monosynth or polysynth: + + + +The base types are `sine`, `square`, `sawtooth`, `triangle`. You can also append a number between 1 and 32 to reduce the harmonic partials. + +### lowpass(cutoff) + +Helper that returns a Filter Node of type lowpass with the given cutoff. Intended to be used with Tone's .chain: + + + +### highpass(cutoff) + +Helper that returns a Filter Node of type highpass with the given cutoff. Intended to be used with Tone's .chain: + + + +### adsr(attack, decay?, sustain?, release?) + +Helper to set the envelope of a Tone.js instrument. Intended to be used with Tone's .set: + + + +### Experimental: Patternification + +While the above methods work for static sounds, there is also the option to patternify tone methods. +This is currently experimental, because the performance is not stable, and audio glitches will appear after some time. +It would be great to get this to work without glitches though, because it is fun! + +#### synth(type) + +With .synth, you can create a synth with a variable wave type: + +'.m).slow(4)`} +/> + +#### adsr(attack, decay?, sustain?, release?) + +Chainable Envelope helper: + + + +Due to having more than one argument, this method is not patternified. + +#### filter(cuttoff) + +Patternified filter: + + + +#### gain(value) + +Patternified gain: + + + +#### autofilter(value) + +Patternified autofilter: + +'.m)`} +/> ## Tonal API