https://tidalcycles.org/api.php?action=feedcontributions&user=ZimaPurple&feedformat=atomTidalCycles userbase - User contributions [en]2020-11-25T05:11:33ZUser contributionsMediaWiki 1.32.2https://tidalcycles.org/index.php?title=anticipate&diff=3750anticipate2019-04-06T15:20:19Z<p>ZimaPurple: Start anticipate</p>
<hr />
<div>[[Category:Transitions]]<br />
<br />
[[Type signature|Type]]: <syntaxhighlight lang="haskell" inline>anticipate :: Time -> [ControlPattern] -> ControlPattern</syntaxhighlight><br />
<br />
Queue up a pattern to be triggered (or dropped) in at the specified number of cycles<br />
<br />
<syntaxhighlight lang="haskell" inline><br />
d1 $ sound "jvbass(3,8)"<br />
<br />
anticipate 4 $ sound "bd sn" # delay "0.5" # room "0.3"<br />
</syntaxhighlight></div>ZimaPurplehttps://tidalcycles.org/index.php?title=cycleChoose&diff=3749cycleChoose2019-04-06T14:53:01Z<p>ZimaPurple: inclue type signature</p>
<hr />
<div>[[Type signatures|Type]]: <source inline>cycleChoose :: [a] -> Pattern a</source><br />
<br />
similar to [[choose]], but only picks once per cycle<br />
<br />
<syntaxhighlight lang="Haskell"><br />
d1 $ sound "drum ~ drum drum" # n (cycleChoose [0,2,3])<br />
</syntaxhighlight></div>ZimaPurplehttps://tidalcycles.org/index.php?title=cycleChoose&diff=3748cycleChoose2019-04-06T14:39:36Z<p>ZimaPurple: start cycleChoose</p>
<hr />
<div>similar to [[choose]], but only picks once per cycle<br />
<br />
<syntaxhighlight lang="Haskell"><br />
d1 $ sound "drum ~ drum drum" # n (cycleChoose [0,2,3])<br />
</syntaxhighlight></div>ZimaPurplehttps://tidalcycles.org/index.php?title=chords&diff=3264chords2019-02-20T20:05:15Z<p>ZimaPurple: Cap typo</p>
<hr />
<div>=== List of chords ===<br />
<br />
6by9 7f10 7f5 7f9 7s5 7s5f9 7sus2 7sus4 9s5 9sus4 aug dim dim7 dom7 eleven elevenSharp five m11 <br />
m11s m11sharp m13m6 m6by9 m7f5 m7f9 m7flat5 m7flat9 m7s5 m7s9 m7sharp5 m7sharp5flat9 m7sharp9 m9 <br />
m9s5 m9sharp5 maj maj11 maj7 maj9 major major7 min min7 minor minor7 msharp5 nine nineSharp5 <br />
nineSus4 ninesus4 one plus sevenFlat10 sevenFlat5 sevenFlat9 sevenSharp5 sevenSharp5flat9 sevenSus2 <br />
sevenSus4 sharp5 six sixby9 sus2 sus4 thirteen<br />
<br />
=== Using chords ===<br />
<br />
The list above can be combined with a root using the <source inline>'</source> to use with the synths in Super Dirt like this:<br />
d1 $ n "c'maj e'min" # s "supermandolin"<br />
<br />
The root can be set as 'sharp' or 'flat' with <source inline>s</source> or <source inline>f</source> respectively:<br />
d1 $ n "cf'maj c'maj cs'maj" # s "supermandolin"<br />
<br />
The octave can be set with a number. The default is <source inline>5</source>:<br />
d1 $ n("c4'maj c5'maj c6'maj") # s "supermandolin"<br />
<br />
The chords can be patterned using the <source inline>|+</source> operator:<br />
d1 $ n ("c e f" |+ "<'maj 'min>") # s "supermandolin"<br />
<br />
This will give a pattern equivalent to:<br />
d1 $ n ("c'maj e'maj f'maj, c'min e'min f'min") # s "supermandolin</div>ZimaPurplehttps://tidalcycles.org/index.php?title=chords&diff=3263chords2019-02-20T20:04:56Z<p>ZimaPurple: Include octave default</p>
<hr />
<div>=== List of chords ===<br />
<br />
6by9 7f10 7f5 7f9 7s5 7s5f9 7sus2 7sus4 9s5 9sus4 aug dim dim7 dom7 eleven elevenSharp five m11 <br />
m11s m11sharp m13m6 m6by9 m7f5 m7f9 m7flat5 m7flat9 m7s5 m7s9 m7sharp5 m7sharp5flat9 m7sharp9 m9 <br />
m9s5 m9sharp5 maj maj11 maj7 maj9 major major7 min min7 minor minor7 msharp5 nine nineSharp5 <br />
nineSus4 ninesus4 one plus sevenFlat10 sevenFlat5 sevenFlat9 sevenSharp5 sevenSharp5flat9 sevenSus2 <br />
sevenSus4 sharp5 six sixby9 sus2 sus4 thirteen<br />
<br />
=== Using chords ===<br />
<br />
The list above can be combined with a root using the <source inline>'</source> to use with the synths in Super Dirt like this:<br />
d1 $ n "c'maj e'min" # s "supermandolin"<br />
<br />
The root can be set as 'sharp' or 'flat' with <source inline>s</source> or <source inline>f</source> respectively:<br />
d1 $ n "cf'maj c'maj cs'maj" # s "supermandolin"<br />
<br />
The octave can be set with a number. the default is <source inline>5</source>:<br />
d1 $ n("c4'maj c5'maj c6'maj") # s "supermandolin"<br />
<br />
The chords can be patterned using the <source inline>|+</source> operator:<br />
d1 $ n ("c e f" |+ "<'maj 'min>") # s "supermandolin"<br />
<br />
This will give a pattern equivalent to:<br />
d1 $ n ("c'maj e'maj f'maj, c'min e'min f'min") # s "supermandolin</div>ZimaPurplehttps://tidalcycles.org/index.php?title=chords&diff=3262chords2019-02-20T19:59:10Z<p>ZimaPurple: </p>
<hr />
<div>=== List of chords ===<br />
<br />
6by9 7f10 7f5 7f9 7s5 7s5f9 7sus2 7sus4 9s5 9sus4 aug dim dim7 dom7 eleven elevenSharp five m11 <br />
m11s m11sharp m13m6 m6by9 m7f5 m7f9 m7flat5 m7flat9 m7s5 m7s9 m7sharp5 m7sharp5flat9 m7sharp9 m9 <br />
m9s5 m9sharp5 maj maj11 maj7 maj9 major major7 min min7 minor minor7 msharp5 nine nineSharp5 <br />
nineSus4 ninesus4 one plus sevenFlat10 sevenFlat5 sevenFlat9 sevenSharp5 sevenSharp5flat9 sevenSus2 <br />
sevenSus4 sharp5 six sixby9 sus2 sus4 thirteen<br />
<br />
=== Using chords ===<br />
<br />
The list above can be combined with a root using the <source inline>'</source> to use with the synths in Super Dirt like this:<br />
d1 $ n "c'maj e'min" # s "supermandolin"<br />
<br />
The root can be set as 'sharp' or 'flat' with <source inline>s</source> or <source inline>f</source> respectively:<br />
d1 $ n "cf'maj c'maj cs'maj" # s "supermandolin"<br />
<br />
The octave can be set with a number:<br />
d1 $ n("c4'maj c5'maj c6'maj") # s "supermandolin"<br />
<br />
The chords can be patterned using the <source inline>|+</source> operator:<br />
d1 $ n ("c e f" |+ "<'maj 'min>") # s "supermandolin"<br />
<br />
This will give a pattern equivalent to:<br />
d1 $ n ("c'maj e'maj f'maj, c'min e'min f'min") # s "supermandolin</div>ZimaPurplehttps://tidalcycles.org/index.php?title=chords&diff=3261chords2019-02-20T19:58:43Z<p>ZimaPurple: Include setting octave</p>
<hr />
<div>=== List of chords ===<br />
<br />
6by9 7f10 7f5 7f9 7s5 7s5f9 7sus2 7sus4 9s5 9sus4 aug dim dim7 dom7 eleven elevenSharp five m11 m11s m11sharp m13m6 m6by9 m7f5 m7f9 m7flat5 m7flat9 m7s5 m7s9 m7sharp5 m7sharp5flat9 m7sharp9 m9 m9s5 m9sharp5 maj maj11 maj7 maj9 major major7 min min7 minor minor7 msharp5 nine nineSharp5 nineSus4 ninesus4 one plus sevenFlat10 sevenFlat5 sevenFlat9 sevenSharp5 sevenSharp5flat9 sevenSus2 sevenSus4 sharp5 six sixby9 sus2 sus4 thirteen<br />
<br />
=== Using chords ===<br />
<br />
The list above can be combined with a root using the <source inline>'</source> to use with the synths in Super Dirt like this:<br />
d1 $ n "c'maj e'min" # s "supermandolin"<br />
<br />
The root can be set as 'sharp' or 'flat' with <source inline>s</source> or <source inline>f</source> respectively:<br />
d1 $ n "cf'maj c'maj cs'maj" # s "supermandolin"<br />
<br />
The octave can be set with a number:<br />
d1 $ n("c4'maj c5'maj c6'maj") # s "supermandolin"<br />
<br />
The chords can be patterned using the <source inline>|+</source> operator:<br />
d1 $ n ("c e f" |+ "<'maj 'min>") # s "supermandolin"<br />
<br />
This will give a pattern equivalent to:<br />
d1 $ n ("c'maj e'maj f'maj, c'min e'min f'min") # s "supermandolin</div>ZimaPurplehttps://tidalcycles.org/index.php?title=chords&diff=3260chords2019-02-20T19:16:53Z<p>ZimaPurple: Include flat and sharp</p>
<hr />
<div>=== List of chords ===<br />
<br />
6by9 7f10 7f5 7f9 7s5 7s5f9 7sus2 7sus4 9s5 9sus4 aug dim dim7 dom7 eleven elevenSharp five m11 m11s m11sharp m13m6 m6by9 m7f5 m7f9 m7flat5 m7flat9 m7s5 m7s9 m7sharp5 m7sharp5flat9 m7sharp9 m9 m9s5 m9sharp5 maj maj11 maj7 maj9 major major7 min min7 minor minor7 msharp5 nine nineSharp5 nineSus4 ninesus4 one plus sevenFlat10 sevenFlat5 sevenFlat9 sevenSharp5 sevenSharp5flat9 sevenSus2 sevenSus4 sharp5 six sixby9 sus2 sus4 thirteen<br />
<br />
=== Using chords ===<br />
<br />
The list above can be combined with a root using the <source inline>'</source> to use with the synths in Super Dirt like this:<br />
d1 $ n "c'maj e'min" # s "supermandolin"<br />
<br />
The root can be set as 'sharp' or 'flat' with <source inline>s</source> or <source inline>f</source> respectively:<br />
d1 $ n "cf'maj c'maj cs'maj" # s "supermandolin"<br />
<br />
The chords can be patterned using the <source inline>|+</source> operator:<br />
d1 $ n ("c e f" |+ "<'maj 'min>") # s "supermandolin"<br />
<br />
This will give a pattern equivalent to:<br />
d1 $ n ("c'maj e'maj f'maj, c'min e'min f'min") # s "supermandolin</div>ZimaPurplehttps://tidalcycles.org/index.php?title=chords&diff=3259chords2019-02-20T19:09:27Z<p>ZimaPurple: Include patterning chords with `|+`</p>
<hr />
<div>=== List of chords ===<br />
<br />
6by9 7f10 7f5 7f9 7s5 7s5f9 7sus2 7sus4 9s5 9sus4 aug dim dim7 dom7 eleven elevenSharp five m11 m11s m11sharp m13m6 m6by9 m7f5 m7f9 m7flat5 m7flat9 m7s5 m7s9 m7sharp5 m7sharp5flat9 m7sharp9 m9 m9s5 m9sharp5 maj maj11 maj7 maj9 major major7 min min7 minor minor7 msharp5 nine nineSharp5 nineSus4 ninesus4 one plus sevenFlat10 sevenFlat5 sevenFlat9 sevenSharp5 sevenSharp5flat9 sevenSus2 sevenSus4 sharp5 six sixby9 sus2 sus4 thirteen<br />
<br />
=== Using chords ===<br />
<br />
The list above can be combined with a root using the <source inline>'</source> to use with the synths in Super Dirt like this:<br />
d1 $ n "c'maj e'min" # s "supermandolin"<br />
<br />
<br />
The chords can be patterned using the <source inline>|+</source> operator:<br />
d1 $ n ("c e f" |+ "<'maj 'min>") # s "supermandolin"<br />
<br />
<br />
This will give a pattern equivalent to:<br />
d1 $ n ("c'maj e'maj f'maj, c'min e'min f'min") # s "supermandolin</div>ZimaPurplehttps://tidalcycles.org/index.php?title=Interaction&diff=2940Interaction2018-12-23T23:09:08Z<p>ZimaPurple: missing '>'</p>
<hr />
<div><br />
In Tidal 1.0.0, the way you interact with patterns has changed a bit.<br />
<br />
The range of functions for interaction set up by default can be seen in the [https://github.com/tidalcycles/Tidal/blob/master/BootTidal.hs bootup code].<br />
<br />
= Patterns by number and by name =<br />
<br />
As before you can use <syntaxhighlight lang="haskell" inline>d1</syntaxhighlight>, <syntaxhighlight lang="haskell" inline>d2</syntaxhighlight> etc to start different patterns, e.g:<br />
<br />
<syntaxhighlight lang="Haskell"><br />
d1 $ sound "bd sd"<br />
<br />
d1 $ silence<br />
</syntaxhighlight><br />
<br />
But now as an alternative you can also use <syntaxhighlight lang="haskell" inline>p</syntaxhighlight> and specify ''any'' number, like this:<br />
<br />
<syntaxhighlight lang="Haskell"><br />
p 100323523 $ sound "bd sd"<br />
<br />
p 100323523 $ silence<br />
</syntaxhighlight><br />
<br />
Theoretically, you can have any number of patterns running at once.<br />
<br />
You can also refer to them by name, if you want.<br />
<br />
<syntaxhighlight lang="Haskell"><br />
p "jimmy" $ sound "bd sd"<br />
p "susan" $ sound "cp(3,8)"<br />
<br />
p "jimmy" $ silence<br />
p "susan" $ silence<br />
</syntaxhighlight><br />
<br />
= Transitions =<br />
<br />
If you want to do a transition, you put it in place of the <syntaxhighlight lang="haskell" inline>p</syntaxhighlight>, e.g.:<br />
<br />
<syntaxhighlight lang="haskell"><br />
xfade "susan" $ sound "gabba(3,8,<0 2 4>)"<br />
xfade "susan" $ sound "cp*2"<br />
</syntaxhighlight><br />
<br />
(The old t1, t2 etc method no longer works.)<br />
<br />
= Doing things once =<br />
<br />
If you just want a pattern to run for one cycle and then stop, you can do use <syntaxhighlight lang="haskell" inline>once</syntaxhighlight>:<br />
<br />
<syntaxhighlight lang="haskell"><br />
once $ s "bd sd(3,8)"<br />
</syntaxhighlight><br />
<br />
= Changing tempo with setcps =<br />
<br />
Just give it the number of cycles per second, for example if your cycle has two beats in, this will be the equivalent of 120 bpm:<br />
<br />
<source><br />
setcps 1<br />
</source><br />
<br />
= Changing tempo with cps =<br />
<br />
<syntaxhighlight lang="haskell" inline>cps</syntaxhighlight> is no longer a standalone function (`setcps` above now does this), but a control pattern. Patterning cps is ''fun''. Patterns don't (yet) have independent tempos though, if you change it on one pattern, it changes on all of them.<br />
<br />
<syntaxhighlight lang="haskell"><br />
p "cpsfun" $ s "bd sd(3,8)" # cps (slow 8 $ 0.5 + saw)<br />
</syntaxhighlight><br />
<br />
[[Category:Reference]]<br />
[[Category:Tidal-1+]]</div>ZimaPurplehttps://tidalcycles.org/index.php?title=Tutorial&diff=2939Tutorial2018-12-23T21:58:35Z<p>ZimaPurple: update anticipate as per yaxu in lurk</p>
<hr />
<div>'''Note: this is in the process of being updated for version 1.0.0.'''<br />
<br />
You’ve installed TidalCycles and (Super)Dirt, maybe even made a few sounds, but now you’re ready to get to business and start really learning. This guide will help you get started with simple patterns and walk you through all the way to complex compositions.<br />
<br />
Why not play with the code as you read, running your own experiments by changing the examples, and seeing where they take you?<br />
<br />
= Creating Rhythmic Sequences =<br />
==Play a Single Sample==<br />
Tidal provides 16 'connections' to the SuperDirt synthesiser, named from d1 to d16. Here’s a minimal example, that plays a kick drum every cycle:<br />
<br />
<source><br />
d1 $ sound "bd"<br />
</source><br />
<br />
Evaluate the above code in the Atom (or Emacs) editor by pressing Ctrl+Enter. If you want to stop the sound again, look ahead to the section on silence.<br />
<br />
In the code above, <source inline>sound</source> tells us we’re making a pattern of sound samples, and <source inline>"bd"</source> is a pattern that contains a single sound. bd is a sample of a kick drum. Samples live inside the Dirt-Samples folder which came with SuperDirt, and each sub-folder under that corresponds to a sample name (like bd).<br />
<br />
To find the SuperDirt samples on your system, in the SuperCollider IDE select the File > Open User Support Directory menu item. From there, open downloaded-quarks and finally Dirt-Samples in there. You should find a lot of folders, each one is a sample bank containing standard wav files. Feel free to make new folders and add your own sounds to it, see the [[Custom Samples]] userbase page for more info.<br />
<br />
We can pick a different sample in the bd folder by adding a colon (:) then a number. For example, this picks the fourth kick drum (it counts from zero, so :3 gives you the fourth sound in the folder):<br />
<br />
<source><br />
d1 $ sound "bd:3"<br />
</source><br />
<br />
If you specify a number greater than the number of samples in a folder, then Tidal just “wraps” around back to the first sample again (it starts counting at zero, e.g. in a folder with five samples, “bd:5” would play “bd:0”).<br />
<br />
It’s also possible to specify the sample number separately:<br />
<br />
<source><br />
d1 $ sound "bd" # n "3"<br />
</source><br />
<br />
The usefulness of doing this will become apparent later.<br />
<br />
==Sequences From Multiple Samples==<br />
Putting things in quotes allows you to define a sequence. For example, the following gives you a pattern of kick drum then snare:<br />
<br />
<source><br />
d1 $ sound "bd sd:3"<br />
</source><br />
<br />
When you run the code above, you are replacing the previous pattern with another one on-the-fly. Congratulations, you’re live coding.<br />
<br />
==Playing More Than One Sequence==<br />
The easiest way to play multiple sequences at the same time is to use two or more connections to the synthesizer:<br />
<br />
<source><br />
d1 $ sound "bd sd:1"<br />
<br />
d2 $ sound "hh hh hh hh"<br />
<br />
d3 $ sound "arpy"<br />
</source><br />
<br />
NOTE: each connection must be evaluated separately in your text editor. That is, you must press Ctrl+Enter three times, once for each line above. ''Make sure that there is a blank line between them each pattern'', or Tidal will evaluate them together and get confused (if you want to evaluate just one line, you can press shift-enter).<br />
<br />
ANOTHER NOTE: If you prefer to refer to patterns by name, rather than by number, you can do that with <source inline>p</source>, for example:<br />
<br />
<source><br />
p "susan" $ sound "bd sd:1"<br />
<br />
p "gerard" $ sound "hh hh hh hh"<br />
</source><br />
<br />
==What is a Cycle?==<br />
A cycle is the main “loop” of time in Tidal. The cycle repeats forever in the background, even when you’ve stopped samples from playing. The cycle’s duration always stays the same unless you modify it with cps, we’ll cover this later. By default, there is one cycle per second.<br />
<br />
Note that this omniprescent cyclic looping doesn’t necessary constrain you, for example it’s common to stretch a pattern outside of a single loop, and vary patterns from one loop to the next. We’ll see several ways to do this later, as well.<br />
<br />
All of the samples inside of a pattern get squashed into a single cycle. The patterns below all loop over the same amount of time:<br />
<br />
<source><br />
d1 $ sound "bd sd"<br />
<br />
d1 $ sound "bd sd hh cp mt arpy drum"<br />
<br />
d1 $ sound "bd sd hh cp mt arpy drum odx bd arpy bass2 feel future"<br />
</source><br />
<br />
Note how the more steps you add to the pattern, the faster it plays them, in order to fit them all in. No matter how many samples you put in a pattern in this way, they will always be distributed evenly within a single cycle.<br />
<br />
=Silence=<br />
At this point you probably want to know how to stop the patterns you started. An empty pattern is defined as silence, so if you want to ‘switch off’ a pattern, you can just set it to that:<br />
<br />
<source><br />
d1 silence<br />
</source><br />
<br />
If you want to set all the connections (from d1 to d9) to be silent at once, there’s a single-word shortcut for that:<br />
<br />
<source><br />
hush<br />
</source><br />
<br />
You can also isolate a single connection and silence all others with the <source inline>solo</source> function. You can do this like so:<br />
<br />
<source><br />
d1 $ sound "bd"<br />
<br />
d2 $ sound "~ cp"<br />
<br />
-- run this and only the bd plays<br />
solo 1 <br />
<br />
-- unsolo it and the cp plays again<br />
unsolo 1 <br />
</source><br />
<br />
=Patterns Within Patterns=<br />
<br />
You can use Tidal’s square brackets syntax to create a pattern grouping:<br />
<br />
<source><br />
d1 $ sound "[bd sd sd] cp"<br />
</source><br />
<br />
Square brackets allow several events to be played inside of a single step. You can think of the above pattern as having two steps, with the first step broken down into a subpattern, which has three steps. Practically, this means you can create denser sub-divisions of cycles:<br />
<br />
<source><br />
d1 $ sound "bd [sd sd]"<br />
<br />
d1 $ sound "bd [sd sd sd]"<br />
<br />
d1 $ sound "bd [sd sd sd sd]"<br />
<br />
d1 $ sound "[bd bd] [sd sd sd sd]"<br />
<br />
d1 $ sound "[bd bd bd] [sd sd]"<br />
<br />
d1 $ sound "[bd bd bd bd] [sd]"<br />
</source><br />
<br />
You can even nest groups inside groups to create increasingly dense and complex patterns:<br />
<br />
<source><br />
d1 $ sound "[bd bd] [bd [sd [sd sd] sd] sd]"<br />
</source><br />
<br />
A shorthand for this kind of grouping is to place a period . between groups, rather than surrounding them in square brackets. We call this technique ‘marking out feet’. For example these two patterns are equivalent:<br />
<br />
<source><br />
d1 $ sound "bd bd . sd sd sd . bd sd"<br />
<br />
d1 $ sound "[bd bd] [sd sd sd] [bd sd]"<br />
</source><br />
<br />
The former approach is often easier to type, but is a relatively new addition to TidalCycles, and so many examples will use the square brackets.<br />
<br />
==Layering (Polyrhythms) Instead of Grouping==<br />
You can also layer up several loops, by using commas to separate the different parts:<br />
<br />
<source><br />
d1 $ sound "[bd bd bd, sd cp sd cp]"<br />
</source><br />
<br />
This would play the sequence bd bd bd at the same time as sd cp sd cp. Note that the first sequence only has three events, and the second one has four. Because tidal ensures both loops fit inside the same cyclic duration, you end up with a polyrhythm.<br />
<br />
You can layer any number of these subpatterns to create many polyrhythms:<br />
<br />
<source><br />
d1 $ sound "[bd bd bd, sd cp sd cp, arpy arpy, odx]"<br />
</source><br />
<br />
And of course you can use groupings inside of the layers:<br />
<br />
<source><br />
d1 $ sound "[bd bd bd, [sd sd] cp, arpy [arpy [arpy arpy] arpy arpy], odx]"<br />
</source><br />
<br />
==Playing one step per cycle==<br />
To specify a group where only one step is played per cycle, use angle brackets. For example:<br />
<br />
<source><br />
d1 $ sound "bd <arpy:1 arpy:2 arpy:3>"<br />
</source><br />
<br />
The above will result in the sequence <code>bd arpy:1 bd arpy:2 bd arpy:3</code>, over three cycles.<br />
<br />
=Pattern Repetition and Speed=<br />
<br />
==Repetition==<br />
There are two short-hand symbols you can use inside patterns to speed things up or slow things down: * and /. You could think of these like multiplication and division.<br />
<br />
Use the * symbol to make a pattern, or part of a pattern, repeat as many times as you’d like:<br />
<br />
<source><br />
d1 $ sound "bd*2"<br />
</source><br />
<br />
This is the same as doing <code>d1 $ sound "bd bd"</code><br />
<br />
The code above uses *2 to make a sample play twice.<br />
<br />
You can use the / symbol to make a part of a pattern slow down, or occur less often:<br />
<br />
<source><br />
d1 $ sound "bd/2"<br />
</source><br />
<br />
The code above uses /2 to make a sample play half as often, or once every 2nd cycle.<br />
<br />
Using different numbers works as you’d expect:<br />
<br />
<source><br />
d1 $ sound "bd*3" -- plays the bd sample three times each cycle<br />
d1 $ sound "bd/3" -- plays the bd samples only once each third cycle<br />
</source><br />
<br />
==Using * and / on Groups==<br />
You can apply the * and / symbols on groups of patterns:<br />
<br />
<source><br />
d1 $ sound "[bd sn]*2 cp"<br />
<br />
d1 $ sound "[bd sn] cp/2"<br />
<br />
d1 $ sound "[[bd sn] cp]*2" -- speeds up the entire pattern by 2<br />
<br />
d1 $ sound "[[bd sn] cp]/2" -- slows down the entire pattern by 2<br />
</source><br />
<br />
You can also use the symbols on nested groups to create more complex rhythms:<br />
<br />
<source><br />
d1 $ sound "[bd sn sn*3]/2 [bd sn*3 bd*4]/3"<br />
<br />
d1 $ sound "[bd [sn sn]*2]/2 [bd [sn bd]/2]*2"<br />
</source><br />
<br />
=Modifying Sequences With Functions=<br />
<br />
Tidal comes into its own when you start building things up with functions which transform the patterns in various ways.<br />
<br />
For example, <code>rev</code> reverses a pattern:<br />
<br />
<source><br />
d1 $ rev (sound "bd*2 [bd [sn sn*2 sn] sn]")<br />
</source><br />
<br />
That’s not so exciting, but things get more interesting when this is used in combination with another function. For example every takes three parameters: <br />
a number, a function and a pattern to apply the function to. The number specifies how often the function is applied to the pattern. For example, the <br />
following reverses the pattern every fourth repetition:<br />
<br />
<source><br />
d1 $ every 4 (rev) (sound "bd*2 [bd [sn sn*2 sn] sn]")<br />
</source><br />
<br />
It takes a while to get used to how we’re using parenthesis here. In the previous example, rev takes one parameter, a pattern, and we had to ‘wrap up’ the <br />
pattern sound <code>"[bd bd] [bd [sn [sn sn] sn] sn]"</code> in brackets to pass it to rev. In the above example every takes three parameters: a number, <br />
a function and a pattern. We had to wrap up the pattern as before, but also rev in order to give it to every. This should become clearer with practice.<br />
<br />
You can also slow down or speed up the playback of a pattern, this makes it a quarter of the speed:<br />
<br />
<source><br />
d1 $ slow 4 $ sound "bd*2 [bd [sn sn*2 sn] sn]"<br />
</source><br />
<br />
And this four times the speed:<br />
<br />
<source><br />
d1 $ fast 4 $ sound "bd*2 [bd [sn sn*2 sn] sn]"<br />
</source><br />
<br />
Note that slow 0.25 would do exactly the same as fast 4.<br />
<br />
Again, this can be applied selectively:<br />
<br />
<source><br />
d1 $ every 4 (fast 4) $ sound "bd*2 [bd [sn sn*2 sn] sn]"<br />
</source><br />
<br />
Note again the use of parenthesis, around fast 4. This is needed, to group together the function fast with its parameter 4, before being passed as a parameter to the function every.<br />
<br />
In the examples above, the sound function takes a pattern of sample names, and turns it into a pattern of synthesizer triggers. <br />
This might take a while to fully understand, but the important thing to remember is that “it’s patterns all the way down”. <br />
In this case, this means that you can operate on the inner pattern of sample names, instead of the outer pattern of synthesizer triggers that sound gives you:<br />
<br />
<source><br />
d1 $ sound (every 4 (fast 4) "bd*2 [bd [sn sn*2 sn] sn]")<br />
</source><br />
<br />
The fast function is also known as density, which is actually the older name, so a lot of examples will use it instead of the <br />
(slightly quicker to type) fast. They do exactly the same thing.<br />
<br />
==Where are all the functions?==<br />
There are many types of functions that help you change patterns. Some of them re-order sequences, some alter time, some provide conditional logic, and some can help compose more complex patterns.<br />
<br />
We’ll introduce many of the core functions in this introduction, and a more complete list of functions available in Tidal can be found on the [[Category:Functions|functions category]] page.<br />
<br />
=Applying effects with control patterns=<br />
<br />
TidalCycles has a number of effects that you can apply to sounds. Some of them do simple things like change volume, and others do more complex things like add delay or distortion. This is done with what we call ''control patterns''. In fact <source inline>sound</source> itself creates a control pattern, and we apply effects by combining control patterns together.<br />
<br />
You can combine control patterns by adding the # operator between them:<br />
<br />
<source><br />
d1 $ sound "bd*4" # crush "4"<br />
</source><br />
<br />
The above code uses <source inline>crush</source> to create a bitcrushing control pattern with a value of 4 (which sounds really grungy), and uses <source inline>#</source> to join that with the <source inline>sound</source> control pattern.<br />
<br />
You can combine multiple control patterns together, with the # operator:<br />
<br />
<source><br />
d1 $ sound "bd*4" # crush "4" # speed "2"<br />
</source><br />
<br />
The code above both bitcrushes and speeds up sample playback (which increases the ‘pitch’).<br />
<br />
==Control values are patterns too==<br />
You may notice that the values of effects are specified in double quotes. This means that you can pattern the effect values too:<br />
<br />
<source><br />
d1 $ sound "bd*4" # gain "1 0.8 0.5 0.7"<br />
</source><br />
<br />
The above <source inline>gain</source> effect changes how loud the sample is, good for patterns of emphasis as above. Other control patterns follow all the same grouping rules as sound patterns:<br />
<br />
<source><br />
d1 $ sound "bd*4 sn*4" # gain "[[1 0.8]*2 [0.5 0.7]]/2"<br />
</source><br />
<br />
And you can also apply functions to control patterns:<br />
<br />
<source><br />
d1 $ sound "bd*4" # (every 3 (rev) $ gain "1 0.8 0.5 0.7")<br />
</source><br />
<br />
Like with the sound example earlier, you must use parenthesis after gain in order to specify a function on the gain pattern.<br />
<br />
This works too:<br />
<br />
<source><br />
d1 $ sound "bd*4" # gain (every 3 (rev) $ "1 0.8 0.5 0.7")<br />
</source><br />
<br />
In the above example, <source inline>every 3 (rev)</source> is being applied to <source inline>"1 0.8 0.5 0.7"</source>, which is a pattern of numbers. In the example preceding it, the same function was applied to <source inline>gain "1 0.8 0.5 0.7"</source>, which is a pattern of gain controls. In this case, whether you apply the function before or after the numbers are turned into controls doesn't matter too much, the outcome is exactly the same.<br />
<br />
==Control pattern order==<br />
You can specify the effect control ''before'' the sound control:<br />
<br />
<source><br />
d1 $ gain "1 0.8 0.5 0.7" # sound "bd"<br />
</source><br />
<br />
The order that you put things matters; with <source inline>#</source>the structure of the pattern is given by the pattern on the ''left''. In this case, only one bd sound is given, but you hear four, because the structure comes from the gain pattern on the left.<br />
<br />
==Modifying control values==<br />
<br />
The # operator is just a shortcut to a longer form of operator called <source inline>|=</source>. The <source inline>|=</source> operator is part of a family of operators, and means something special about combining patterns, which we’ll cover shortly. All you need to know right now is that <source inline>|=</source> is used to combine patterns.<br />
<br />
You can use <source inline>|=</source> to combine patterns conditionally:<br />
<br />
<source><br />
d1 $ every 2 (|= speed "2") $ sound "arpy*4" |= speed "1"<br />
</source><br />
<br />
There are other types of operators that allow you to perform arithmetic:<br />
<br />
|+<br />
|-<br />
|*<br />
|/<br />
<br />
For example, using <source inline>|+</source> will perform an addition operation and add to an original value:<br />
<br />
<source><br />
d1 $ every 2 (|+ speed "1") $ sound "arpy*4" |= speed "1"<br />
</source><br />
<br />
The code above results in a speed of “2” every other cycle.<br />
<br />
The following will multiply values:<br />
<br />
<source><br />
d1 $ every 2 (|* speed "1.5") $ sound "arpy*4" |= speed "1"<br />
</source><br />
<br />
More complex patterns and chaining can be done, and with any effect, of course:<br />
<br />
<source><br />
d1 $ every 3 (|- note "3") $ every 2 (|+ up "5") $ sound "arpy*4" |= note "0 2 4 5"<br />
</source><br />
<br />
It might be worth sticking to just these ways of combining control patterns for now, but if you are curious, you can look into the [[Combining pattern structure|others that are available]].<br />
<br />
==Some Common Effects==<br />
Here is a quick list of some effects you can use in Tidal (the full list is available in the Reference section):<br />
<br />
* gain - changes volume, values from 0 to 1<br />
* pan - pans sound right and left, values from 0 to 1<br />
* shape - a type of amplifier, values from 0 to 1<br />
* vowel - a vowel formant filter, values include a, e, i, o, and u<br />
* speed - changes playback speed of a sample, see below<br />
<br />
=Shorthand for numerical patterns=<br />
<br />
From version 0.9 of Tidal, there are some nice ways of saving on keypresses when working with numerical patterns.<br />
<br />
For example, when specifying patterns of single numbers, such as:<br />
<br />
<source><br />
d1 $ sound "arpy(3,8)" # n "2"<br />
</source><br />
<br />
you can miss off the double quotes, so this works fine:<br />
<br />
<source><br />
d1 $ sound "arpy(3,8)" # n 2<br />
</source><br />
<br />
However, if you wanted more than one value in that n pattern, you’d have to put the quotes in:<br />
<br />
<source><br />
d1 $ sound "arpy(3,8)" # n "2 5"<br />
</source><br />
<br />
You can also treat patterns of numbers as simple numbers in other ways. For example doing algebra:<br />
<br />
<source><br />
d1 $ sound "arpy(3,8)" # n ("0 2" * 2)<br />
<br />
d1 $ sound "arpy(3,8)" # n (every 4 (* 2) "0 2")<br />
<br />
d1 $ n (off 0.125 (+12) $ off 0.25 (+7) $ slow 2 $ "0(3,8) [5 7]") # sound "supergong"<br />
</source><br />
<br />
This is still quite new to everyone, so you will not see it used much in the documentation yet.<br />
<br />
You can also now specify increasing or decreasing numbers with a range, for example this:<br />
<br />
d1 $ n "[0..7] [3..1]" # sound "supergong"<br />
<br />
... is shorthand for:<br />
<br />
<source><br />
d1 $ n "[0 1 2 3 4 5 6 7] [3 2 1]" # sound "supergong"<br />
</source><br />
<br />
=Sample Playback Speed (and Pitch)=<br />
<br />
You can change the playback speed of a sample in TidalCycles by using the speed effect. You can use speed to change pitches, to create a weird effect, or to match the length of a sample to a specific period of the cycle time (but see the loopAt function for an easy way of doing the latter).<br />
<br />
You can set a sample’s speed by using the speed effect with a number.<br />
<br />
* speed "1" plays a sample at its original speed<br />
* speed "0.5" plays a sample at half of its original speed<br />
* speed "2" plays a sample at double its original speed<br />
<br />
<source>d1 $ sound "arpy" # speed "1"<br />
<br />
d1 $ sound "arpy" # speed "0.5"<br />
<br />
d1 $ sound "arpy" # speed "2"</source><br />
<br />
Just like other effects, you can specify a pattern for speed:<br />
<br />
d1 $ speed "1 0.5 2 1.5" # sound "arpy" <br />
<br />
You can also reverse a sample by specifying negative values:<br />
<br />
<source><br />
d1 $ speed "-1 -0.5 -2 -1.5" # sound "arpy"<br />
</source><br />
<br />
==Play a sample at multiple speeds simultaneously==<br />
Use the pattern grouping syntax with a comma to cause speed to play a sample back at multiple speeds at the same time:<br />
<br />
<source><br />
d1 $ sound "arpy" # speed "[1, 1.5]"<br />
d1 $ speed "[1 0.5, 1.5 2 3 4]" # sound "arpy"<br />
</source><br />
<br />
==12-tone scale speeds==<br />
You can also use the up function to change playback speed. up is a shortcut effect that matches speeds to half steps on a 12-tone scale. For example, the following plays a chromatic scale:<br />
<br />
<source><br />
d1 $ up "0 1 2 3 4 5 6 7 8 9 10 11" # sound "arpy"<br />
</source><br />
<br />
You can also use the run function to create an incrementing pattern of integers: <br />
<br />
<source><br />
d1 $ up (run 12) # sound "arpy". <br />
</source><br />
<br />
The <code>run</code> function will be discussed later.<br />
<br />
=Euclidean Sequences=<br />
If you give two numbers in parenthesis after an element in a pattern, then Tidal will distribute the first number of sounds equally across the second number of steps:<br />
<br />
<source><br />
d1 $ sound "bd(5,8)"<br />
</source><br />
<br />
You can also use the [[euclid]] function to do this. [[euclid]] takes the same two arguments as what is used in the parenthesis above:<br />
<br />
<source><br />
d1 $ euclid 5 8 $ sound "bd"<br />
</source><br />
<br />
You can use the parenthesis notation within a single element of a pattern:<br />
<br />
<source><br />
d1 $ sound "bd(3,8) sn*2"<br />
</source><br />
<br />
<source><br />
d1 $ sound "bd(3,8) sn(5,8)"<br />
</source><br />
<br />
You can also add a third parameter, which ‘rotates’ the pattern so it starts on a different step:<br />
<br />
<source><br />
d1 $ sound "bd(5,8,2)"<br />
</source><br />
<br />
You can also use the euclid function to apply a Euclidean algorithm over a complex pattern, although the structure of that pattern will be lost:<br />
<br />
<source><br />
d1 $ euclid 3 8 $ sound "bd*2 [sn cp]"<br />
</source><br />
<br />
In the above, three sounds are picked from the pattern on the right according to the structure given by the euclid 3 8. It ends up picking two bd sounds, a cp and missing the sn entirely.<br />
<br />
As a bonus, it is possible to pattern the parameters within the parenthesis, for example to alternate between 3 and 5 elements:<br />
<br />
<source><br />
d1 $ sound "bd([5 3]/2,8)"<br />
</source><br />
<br />
These types of sequences use “Bjorklund’s algorithm”, which wasn’t made for music but for an application in nuclear physics, which is exciting. More exciting still is that it is very similar in structure to the one of the first known algorithms written in Euclid’s book of elements in 300 BC. You can read more about this in the paper The Euclidean Algorithm Generates Traditional Musical Rhythms by Toussaint. Some examples from this paper are included below, including rotation in some cases.<br />
<br />
* (2,5) : A thirteenth century Persian rhythm called Khafif-e-ramal.<br />
* (3,4) : The archetypal pattern of the Cumbia from Colombia, as well as a Calypso rhythm from Trinidad.<br />
* (3,5,2) : Another thirteenth century Persian rhythm by the name of Khafif-e-ramal, as well as a Rumanian folk-dance rhythm.<br />
* (3,7) : A Ruchenitza rhythm used in a Bulgarian folk-dance.<br />
* (3,8) : The Cuban tresillo pattern.<br />
* (4,7) : Another Ruchenitza Bulgarian folk-dance rhythm.<br />
* (4,9) : The Aksak rhythm of Turkey.<br />
* (4,11) : The metric pattern used by Frank Zappa in his piece titled Outside Now.<br />
* (5,6) : Yields the York-Samai pattern, a popular Arab rhythm.<br />
* (5,7) : The Nawakhat pattern, another popular Arab rhythm.<br />
* (5,8) : The Cuban cinquillo pattern.<br />
* (5,9) : A popular Arab rhythm called Agsag-Samai.<br />
* (5,11) : The metric pattern used by Moussorgsky in Pictures at an Exhibition.<br />
* (5,12) : The Venda clapping pattern of a South African children’s song.<br />
* (5,16) : The Bossa-Nova rhythm necklace of Brazil.<br />
* (7,8) : A typical rhythm played on the Bendir (frame drum).<br />
* (7,12) : A common West African bell pattern.<br />
* (7,16,14) : A Samba rhythm necklace from Brazil.<br />
* (9,16) : A rhythm necklace used in the Central African Republic.<br />
* (11,24,14) : A rhythm necklace of the Aka Pygmies of Central Africa.<br />
* (13,24,5) : Another rhythm necklace of the Aka Pygmies of the upper Sangha.<br />
<br />
=Tempo=<br />
<br />
If you’ve made it this far without changing the tempo in all these examples, then you’re probably ready to change it up.<br />
<br />
Tidal’s core unit of time is cycles per second. It can be set with the <source inline>setcps</source> function:<br />
<br />
<source><br />
setcps 1<br />
</source><br />
<br />
You can execute setcps just like a pattern (using Shift+Enter in your editor).<br />
<br />
<source inline>setcps</source> accepts a positive numeric value that can include a decimal:<br />
<br />
<source><br />
setcps 1.5<br />
setcps 0.75<br />
setcps 10<br />
</source><br />
<br />
Tidal’s timing is based on cycles, rather than beats, however it is more common for people to think in terms of beats per minute (BPM). If you prefer to think in this way, you have to decide how many beats you want to have per cycle, and divide accordingly. For example if you wanted to play at 140 bpm, with four beats per cycle, then you could do:<br />
<br />
<source><br />
setcps (140/60/4)<br />
</source><br />
<br />
You can also pattern the tempo with the <source inline>cps</source> control function, for example:<br />
<br />
<source><br />
d1 $ sound "cp(3,8)"<br />
# cps (slow 8 $ range 0.8 1.6 saw)<br />
</source><br />
<br />
=The Run Function=<br />
<br />
There is a special utility function called run which will return a pattern of integers up to a specified maximum. You can use run with effects to aid in automatically generating a linear pattern:<br />
<br />
<source><br />
d1 $ sound "arpy*8" # up (run 8)<br />
d1 $ sound "arpy*8" # speed (run 8)<br />
</source><br />
<br />
In the above we’re specifying the number of sounds twice - in the sound pattern as well as the up or speed pattern. There’s actually a neat way of only having to specify this once, simply by switching them round, so the effect parameter is on the left:<br />
<br />
<source><br />
d1 $ up (run 8) # sound "arpy"<br />
</source><br />
<br />
This works because TidalCycles always takes the structure of a pattern from the parameter that’s on the left. We usually want the structure to come from the sound parameter, but not always.<br />
<br />
Because run returns a pattern, you can apply functions to its result:<br />
<br />
<source><br />
d1 $ sound "arpy*8" # up (every 2 (rev) $ run 8)<br />
</source><br />
<br />
For a more practical example of using run, read below about selecting samples from folders.<br />
<br />
=(Algorithmically) Selecting Samples=<br />
<br />
The sound parameter we’ve been using up to now can actually be broken into two separate parameters, making it easy to select samples with a pattern. These parameters are s that gives the name of the sample set, and n which gives the number of the sample within that set. For example, the following two patterns do exactly the same:<br />
<br />
<source><br />
d1 $ sound "arpy:0 arpy:2 arpy:3"<br />
d1 $ n "0 2 3" # s "arpy"<br />
</source><br />
<br />
It’s possible to break the sound parameter into two different patterns, namely s that gives the name of the sample set, and n which gives the index of the sample within that set. For example, the following two patterns are the same:<br />
<br />
<source><br />
d1 $ sound "arpy:0 arpy:2 arpy:3"<br />
d1 $ n "0 2 3" # s "arpy"<br />
</source><br />
<br />
This allows us to separate the sample folder name from the index inside the folder, possibly with surprising results!<br />
<br />
There is also special function called samples that lets you do the same using the sound parameter.<br />
<br />
<source><br />
d1 $ sound $ samples "drum*4" "0 1 2 3"<br />
</source><br />
<br />
the code above is the same as this:<br />
<br />
<source><br />
d1 $ sound "drum:0 drum:1 drum:2 drum:3"<br />
</source><br />
<br />
Whether you use n and s together, or sound with samples is up to you, although you might find the former to be more flexible.<br />
<br />
Remember the run function? Since run generates a pattern of integers, it can be used with n to automatically “run” through the sample indices of a folder:<br />
<br />
<source><br />
d1 $ n (run 4) # s "drum"<br />
d1 $ sound $ samples "drum*4" (run 4) -- or with samples<br />
</source><br />
<br />
And of course you can specify a different pattern of sample names:<br />
<br />
<source><br />
d1 $ s "drum arpy cp hh" # n (run 10)<br />
</source><br />
<br />
Again, by swapping the order of the s and n parameters, you can hear the difference between taking the structure from one or the other:<br />
<br />
<source><br />
d1 $ n (run 10) # s "drum arpy cp hh"<br />
</source><br />
<br />
NOTE: if you specify a run value that is greater than the number of samples in a folder, then the higher number index will “wrap” to the beginning of the samples in the folder (just like with the colon notation).<br />
<br />
You might sometimes see the samples function wrapped in parenthesis:<br />
<br />
<source><br />
d1 $ sound (samples "drum arpy cp hh" (run 10))<br />
</source><br />
<br />
=Combining Types of Patterns=<br />
<br />
Ok, remember when we started adding effects:<br />
<br />
<source><br />
d1 $ sound "bd sn drum arpy" # pan "0 1 0.25 0.75"<br />
</source><br />
<br />
What we’re actually doing in the code above is combining two patterns together: the sound pattern, and the pan pattern. The special pipe operators (|=, |+, |-, |*, |/, |>, and so on), allow us to combine two patterns. Remember that # is shorthand for |>.<br />
<br />
We can actually swap sides and it sounds the same:<br />
<br />
<source><br />
d1 $ pan "0 1 0.25 0.75" # sound "bd sn drum arpy"<br />
</source><br />
<br />
As we touched on earlier, the main thing to know when combining patterns like this is that the left-most pattern determines the rhythmic structure of the result. Removing one of the elements from the pan pattern on the left results in a cycle with three samples played:<br />
<br />
<source><br />
d1 $ pan "0 1 0.25" # sound "bd sn drum arpy"<br />
</source><br />
<br />
In the code above, the pan pattern determines the rhythm because it is the left-most pattern. The sound pattern now only determines what samples are played at what time. The sound pattern gets mapped onto the pan pattern.<br />
<br />
You might be wondering how TidalCycles decides which sound values get matched with which pan values in the above. (If not, there is no need to read the rest of this paragraph just now!) The rule is, for each value in the pattern on the left, values from the right are matched where the start (or onset) of the left value, fall within the timespan of the value on the right. For example, the second pan value of 1 starts one third into its pattern, and the second sound value of sn starts one quarter into its pattern, and ends at the halfway point. Because the former onset (one third) falls inside the timespan of the latter timespan (from one quarter until one half), they are matched. The timespan of arpy doesn’t contain any onsets from the pan pattern, and so it doesn’t match with anything, and isn’t played.<br />
<br />
The rule described above may seem like a lot to keep in mind while composing patterns, but in practice there is no need. Our advice is to not worry, write some patterns and get a feel for how they fit together.<br />
<br />
Anyway, this composition of pattern parameters allows us to do some unique things:<br />
<br />
<source><br />
d1 $ up "0 0*2 0*4 1" # sound "[arpy, bass2, bd]"<br />
</source><br />
<br />
Above, the sound pattern is merely specifying three samples to play on every note. Both the rhythm and pitch of these notes is defined by the up pattern.<br />
<br />
It's also possible to switch things around so that structure comes from the right, by using the operators >|, *|, +|, /| and -|, instead of |>, |*, |+ and |-, for example:<br />
<br />
<source><br />
d1 $ sound "drum" >| n "0 1*2 ~ 3"<br />
</source><br />
<br />
The side of the operator that the | is on, is where the structure comes from. In fact, if you put the bar on both sides, structure comes from both sides:<br />
<br />
<source><br />
d1 $ sound "drum cp" >| n "0 1 2"<br />
</source><br />
<br />
=Oscillation with Continuous Patterns=<br />
<br />
So far we’ve only been working with discrete patterns, by which we mean patterns which containing events which begin and end. Tidal also supports continuous patterns which instead vary continually over time. You can create continuous patterns using functions which give sine, saw, triangle, and square waves:<br />
<br />
<source><br />
d1 $ sound "bd*16" # pan sine<br />
</source><br />
<br />
The code above uses the sine pattern to specify a sine wave oscillation of values between 0 and 1 for the pan values, so the bass drum moves smoothly between the left and right speakers.<br />
<br />
Tidal used to have sine and sine1 patterns with different ranges, but now they are aliases, with both giving a range from 0 to 1.<br />
<br />
In addition to the sine pattern, Tidal also has saw, tri, and square, for sawtooth, triangle and square waves respectively.<br />
<br />
Just like discrete patterns, you can control the speed of continuous patterns with slow or density:<br />
<br />
<source><br />
d1 $ sound "bd*16" # pan (slow 8 $ saw)<br />
d1 $ sound "bd*8 sn*8" # pan (density 1.75 $ tri)<br />
d1 $ sound "bd*8 sn*8" # speed (density 2 $ tri)<br />
</source><br />
<br />
You can also combine them in different ways:<br />
<br />
<source><br />
d1 $ sound "bd*16" # pan (slowcat [sine, saw, square, tri])<br />
d1 $ sound "sn:2*16" # speed ((range 0.5 3 sine) * (slow 4 saw))<br />
</source><br />
<br />
==Scaling Oscillation==<br />
You can tell the oscillation functions to scale themselves and oscillate between two values using range:<br />
<br />
A recent change in tidal repurposed the old scale function to range, to free scale to be used for other purposes.<br />
<br />
<source><br />
d1 $ sound "bd*8 sn*8" # speed (range 1 3 $ tri)<br />
d1 $ sound "bd*8 sn*8" # speed (slow 4 $ range 1 3 $ tri)<br />
</source><br />
<br />
You can also scale to negative values, but make sure to wrap negative values in parens (otherwise the interpreter thinks you’re trying to subtract 2 from something):<br />
<br />
<source><br />
d1 $ sound "bd*8 sn*8" # speed (range (-2) 3 $ tri)<br />
</source><br />
<br />
This technique works well for a slow low-pass filter cutoff:<br />
<br />
<source><br />
d1 $ sound "hh*32" # cutoff (range 300 1000 $ slow 4 $ sine) # resonance "0.4"<br />
</source><br />
<br />
'''NOTE''': Despite the fact that these oscillator patterns produce continuous values, you still need to combine them with discrete sound patterns.<br />
<br />
=Rests=<br />
<br />
So far we have produced patterns that keep producing more and more sound. What if you want a rest, or gap of silence, in your pattern? You can use the “tilde” ~ character to do so:<br />
<br />
<source><br />
d1 $ sound "bd bd ~ bd"<br />
</source><br />
<br />
Think of the <code>~</code> as an ‘empty’ step in a sequence, that just produces silence.<br />
<br />
=Polymeters=<br />
<br />
We talked about polyrhythms earlier, but Tidal can also produce polymeter sequences. A polymeter pattern is one where two patterns have different sequence lengths, but share the same pulse or tempo.<br />
<br />
You use curly brace syntax to create a polymeter rhythm:<br />
<br />
<source><br />
d1 $ sound "{bd hh sn cp, arpy bass2 drum notes can}"<br />
</source><br />
<br />
The code above results in a five-note rhythm being played at the pulse of a four-note rhythm. If you switch the groups around, it results in a four-note rhythm over a five-note rhythm:<br />
<br />
<source><br />
d1 $ sound "{arpy bass2 drum notes can, bd hh sn cp}"<br />
</source><br />
<br />
Sometimes you might want to create an odd polymeter rhythm without having to explicitly create a base rhythm. You could do this with rests:<br />
<br />
<source><br />
d1 $ sound "{~ ~ ~ ~, arpy bass2 drum notes can}"<br />
</source><br />
<br />
But a more efficient way is to use the % symbol after the closing curly brace to specify the number of notes in the base pulse:<br />
<br />
<source><br />
d1 $ sound "{arpy bass2 drum notes can}%4"<br />
</source><br />
<br />
the above is the same as this:<br />
<br />
<source><br />
d1 $ sound "{~ ~ ~ ~, arpy bass2 drum notes can}"<br />
</source><br />
<br />
If “polymeter” sounds a bit confusing, there’s a good explanation here: http://music.stackexchange.com/questions/10488/polymeter-vs-polyrhythm<br />
<br />
=Shifting Time=<br />
<br />
You can use the <code>~></code> and <code><-</code> functions to shift patterns forwards or backwards in time, respectively. With each of these functions, you can specify an amount, in cycle units.<br />
<br />
<source><br />
d1 $ (0.25 <~) $ sound "bd*2 cp*2 hh sn"<br />
d1 $ (0.25 ~>) $ sound "bd*2 cp*2 hh sn"<br />
</source><br />
<br />
The above code shifts the patterns over by one quarter of a cycle.<br />
<br />
You can hear this shifting effect best when applying it conditionally. For example, the below shifts the pattern every third cycle:<br />
<br />
<source><br />
d1 $ every 3 (0.25 <~) $ sound "bd*2 cp*2 hh sn"<br />
d1 $ every 3 (0.25 ~>) $ sound "bd*2 cp*2 hh sn"<br />
</source><br />
<br />
You can shift patterns as little or as much as you’d like:<br />
<br />
<source><br />
d1 $ every 3 (0.0625 <~) $ sound "bd*2 cp*2 hh sn"<br />
d1 $ every 3 (1000 ~>) $ sound "bd*2 cp*2 hh sn"<br />
d1 $ every 3 (1000.125 ~>) $ sound "bd*2 cp*2 hh sn"<br />
</source><br />
<br />
However, in the above case every cycle is the same, so you won’t here a difference between shifting it 1 or 1000 cycles.<br />
<br />
You can also specify a pattern for the shift amount:<br />
<br />
<source><br />
d1 $ "[0 0.25]/4" <~ (sound "bd*2 cp*2 hh sn")<br />
</source><br />
<br />
=Introducing Randomness=<br />
<br />
Tidal can produce random patterns of integers and decimals. It can also introduce randomness into patterns by removing random events.<br />
<br />
==Random Decimal Patterns==<br />
You can use the rand function to create a random value between 0 and 1. This is useful for effects:<br />
<br />
<source><br />
d1 $ sound "arpy*4" # pan (rand)<br />
</source><br />
<br />
As with run and all numeric patterns, the values that rand give you can be scaled, for example the below gives random numbers between 0.25 and 0.75:<br />
<br />
<source><br />
d1 $ sound "arpy*4" # pan (range 0.25 0.75 $ rand)<br />
</source><br />
<br />
==Random Integer Patterns==<br />
Use the irand function to create a random integer up to a given maximum. The most common usage of irand is to produce a random pattern of sample indices (similar to run):<br />
<br />
<source><br />
d1 $ s "arpy*8" # n (irand 30)<br />
</source><br />
<br />
The code above randomly chooses from 30 samples in the “arpy” folder.<br />
<br />
Hairy detail: rand and irand are actually continuous patterns, which in practical terms means they have infinite detail - you can treat them as pure information! As with all patterns they are also deterministic, stateless functions of time, so that if you retriggered a pattern from the same logical time point, exactly the same numbers would be produced. Furthermore, if you use a rand or irand in two different places, you would get the same ‘random’ pattern - if this isn’t what you want, you can simply shift or slow down time a little for one of them, e.g. slow 0.3 rand.<br />
<br />
==Removing or “Degrading” Pattern events==<br />
Tidal has a few ways to randomly remove events from patterns. You can use the shorthand ? symbol if you want to give an event a 50/50 chance of happening or not on every cycle:<br />
<br />
<source><br />
d1 $ sound "bd? sd? sd? sd?"<br />
</source><br />
<br />
In the code above, the whole sample has a 50% chance if it will be played or if the whole cycle will be silent.<br />
<br />
You can add the ? after the completion of any event or group in a pattern:<br />
<br />
<source><br />
d1 $ sound "bd*16?"<br />
d1 $ sound "bd sn? cp hh?"<br />
d1 $ sound "[bd sn cp hh]?"<br />
</source><br />
<br />
The <code>?</code> symbol is shorthand for the degrade function. The two lines below are equivalent:<br />
<br />
<source><br />
d1 $ sound "bd*16?"<br />
d1 $ degrade $ sound "bd*16"<br />
</source><br />
<br />
Related to degrade is the degradeBy function, where you can specify the probability (from 0 to 1) that events will be removed from a pattern:<br />
<br />
<source><br />
d1 $ degradeBy 0.25 $ sound "bd*16"<br />
</source><br />
<br />
There is also sometimesBy, which executes a function based on a probability:<br />
<br />
<source><br />
d1 $ sometimesBy 0.75 (# crush 4) $ sound "bd arpy sn ~"<br />
</source><br />
<br />
The code above has a 75% chance of applying the bitcrush effect pattern # crush 4 on every event in the sound pattern.<br />
<br />
There are other aliases for sometimesBy:<br />
<br />
<source><br />
sometimes = sometimesBy 0.5<br />
often = sometimesBy 0.75<br />
rarely = sometimesBy 0.25<br />
almostNever = sometimesBy 0.1<br />
almostAlways = sometimesBy 0.9<br />
</source><br />
<br />
e.g.:<br />
<br />
<source><br />
d1 $ rarely (# crush 4) $ sound "bd*8"<br />
</source><br />
<br />
=Creating Variation in Patterns=<br />
<br />
You can create a lot of cyclic variations in patterns by layering conditional logic:<br />
<br />
<source><br />
d1 $ every 5 (|+| speed "0.5") $ every 4 (0.25 <~) $ every 3 (rev) $<br />
sound "bd sn arpy*2 cp"<br />
# speed "[1 1.25 0.75 -1.5]/3"<br />
</source><br />
<br />
In addition to every you can also use the whenmod conditional function. whenmod takes two parameters; it executes a function when the remainder of the current loop number divided by the first parameter is greater or equal than the second parameter.<br />
<br />
For example, the following will play a pattern normally for cycles 1-6, then play it in reverse for cycles 7-8. Then normally again for six cycles, then in reverse for two, and so on:<br />
<br />
<source><br />
d1 $ whenmod 8 6 (rev) $ sound "bd*2 arpy*2 cp hh*4"<br />
</source><br />
<br />
=Creating "Fills" and using "const"=<br />
<br />
You can think of a “fill” as a change to a regular pattern that happens regularly. e.g. every 4 cycles do “xya”, or every 8 cycles do “abc”.<br />
<br />
We’ve already been using every and whenmod to do pattern function fills:<br />
<br />
<source><br />
d1 $ every 8 (rev) $ every 4 (density 2) $ sound "bd hh sn cp"<br />
d1 $ whenmod 16 14 (# speed "2") $ sound "bd arpy*2 cp bass2"<br />
</source><br />
<br />
However, what if you wanted to conditionally replace the pattern with a new one? You can use the const function to completely replace a playing pattern.<br />
<br />
Let’s start with a trivial example where we use const to replace an entire pattern all the time:<br />
<br />
<source><br />
d1 $ const (sound "arpy*3") $ sound "bd sn cp hh"<br />
</source><br />
<br />
In the code above, we’ve completely replaced the “bd sn cp hh” pattern with an “arpy” pattern. const specifies the new pattern.<br />
<br />
We can conditionally apply const using every or whenmod:<br />
<br />
<source><br />
d1 $ whenmod 8 6 (const $ sound "arpy(3,8) bd*4") $ sound "bd sn bass2 sn"<br />
d1 $ every 12 (const $ sound "bd*4 sn*2") $ sound "bd sn bass2 sn"<br />
</source><br />
<br />
=Composing Multi-Part Patterns=<br />
<br />
There are a few ways that you can compose new patterns from multiple other patterns. You can concatenate or “append” patterns in serial, or you can “stack” them and play them together in parallel.<br />
<br />
==Concatenating patterns in serial==<br />
You can use the <code>fastcat</code> function to add patterns one after another:<br />
<br />
<source><br />
d1 $ fastcat [sound "bd sn:2" # vowel "[a o]/2",<br />
sound "casio casio:1 casio:2*2"<br />
]<br />
</source><br />
<br />
The <code>fastcat</code> function squeezes all the patterns into the space of one. The more patterns you add to the list, the faster each pattern will be played so that all patterns can fit into a single cycle.<br />
<br />
<source><br />
d1 $ fastcat [sound "bd sn:2" # vowel "[a o]/2",<br />
sound "casio casio:1 casio:2*2",<br />
sound "drum drum:2 drum:3 drum:4*2"<br />
]<br />
</source><br />
<br />
<code>cat</code> (also known as <code>slowcat</code>), will maintain the original playback speed of the patterns:<br />
<br />
<source><br />
d1 $ cat [sound "bd sn:2" # vowel "[a o]/2",<br />
sound "casio casio:1 casio:2*2",<br />
sound "drum drum:2 drum:3 drum:4*2"<br />
]<br />
</source><br />
<br />
<code>cat</code> is a great way to create a linear sequence of patterns (a sequence of sequences), giving a larger form to multiple patterns.<br />
<br />
There’s also <code>randcat</code>, which will play a random pattern from the list.<br />
<br />
==Playing patterns together in parallel==<br />
<br />
The <code>stack</code> function takes a list of patterns and combines them into a new pattern by playing all of the patterns in the list simultaneously.<br />
<br />
<source><br />
d1 $ stack [<br />
sound "bd bd*2",<br />
sound "hh*2 [sn cp] cp future*4",<br />
sound (samples "arpy*8" (run 16))<br />
]<br />
</source><br />
<br />
This is useful if you want to apply functions or effects on the entire stack:<br />
<br />
<source><br />
d1 $ every 4 (slow 2) $ whenmod 5 3 (# speed "0.75 1.5") $ stack [<br />
sound "bd bd*2",<br />
sound "hh*2 [sn cp] cp future*4",<br />
sound (samples "arpy*8" (run 16))<br />
] # speed "[[1 0.8], [1.5 2]*2]/3"<br />
</source><br />
<br />
=Truncating samples with "cut"=<br />
<br />
So far, all of our examples have used short samples. However, maybe you’ve experimented with some long samples. Maybe you’ve noticed that really long samples can cause a lot of bleed and unwanted sound.<br />
<br />
With Tidal’s cut effect, you can “choke” a sound and stop it from playing when a new sample is triggered.<br />
<br />
Consider the following example where we have a pattern of “arpy” sounds, played at a low speed, so there is a lot of bleed into each sample:<br />
<br />
<source><br />
d1 $ sound (samples "arpy*8" (run 8)) # speed "0.25"<br />
</source><br />
<br />
We can stop this bleed by using cut and assigning the pattern a cut group of “1”:<br />
<br />
<source><br />
d1 $ sound (samples "arpy*8" (run 8)) # speed "0.25" # cut "1"<br />
</source><br />
<br />
No more bleed!<br />
<br />
You can use any number for the cut group.<br />
<br />
Cut groups are global, to the Tidal process, so if you have two Dirt connections, use two different cut group values to make sure the patterns don’t choke each other:<br />
<br />
<source><br />
d1 $ sound (samples "arpy*8" (run 8)) # speed "0.25" # cut "1"<br />
d2 $ sound (samples "bass2*6" (run 6)) # speed "0.5" # cut "2"<br />
</source><br />
<br />
This also works in a stack:<br />
<br />
<source><br />
d1 $ stack [<br />
sound (samples "arpy*8" (run 8)) # speed "0.25" # cut "1",<br />
sound (samples "bass2*6" (run 6)) # speed "0.5" # cut "2" ]<br />
</source><br />
<br />
=Transitions Between Patterns=<br />
<br />
Changing the pattern on a channel takes effect (almost) immediately. This may not be what you want, especially when performing live!<br />
<br />
That’s why Tidal allows you to choose a transition that will introduce another pattern, eventually replacing the current one.<br />
<br />
For every Dirt channel, there’s a transition channel that accepts a transition function and a new pattern.<br />
<br />
So instead of directly sending the new pattern to d1, we’ll send it to the corresponding transition channel t1 and give it a nice transition function:<br />
<br />
<source><br />
d1 $ sound (samples "hc*8" (iter 4 $ run 4))<br />
</source><br />
<br />
<source><br />
anticipate 1 $ sound (samples "bd(3,8)" (run 3))<br />
</source><br />
<br />
To transition from here, simply change the pattern within t1, and in this case also change the transition function:<br />
<br />
<source><br />
xfadeIn 1 16 $ sound "bd(5,8)"<br />
</source><br />
<br />
The above will fade over 16 cycles from the former pattern to the given new one.<br />
<br />
Apart from <code>anticipate</code> and <code>xfadeIn</code> there are a lot more transition functions <br />
e.g. some that will force you to keep changing your patterns to avoid repetitive performances.<br />
<br />
=Samples=<br />
<br />
If you’re using SuperDirt, all the default samples can be found in the Dirt-Samples folder - you can open it by running Quarks.gui in SuperCollider, <br />
clicking on “Dirt-Samples” and then “open folder”. If you’re using classic dirt, look in its samples subfolder. Here’s some you could try:<br />
<br />
<nowiki>flick sid can metal future gabba sn mouth co gretsch mt arp h cp<br />
cr newnotes bass crow hc tabla bass0 hh bass1 bass2 oc bass3 ho<br />
odx diphone2 house off ht tink perc bd industrial pluck trump<br />
printshort jazz voodoo birds3 procshort blip drum jvbass psr<br />
wobble drumtraks koy rave bottle kurt latibro rm sax lighter lt<br />
arpy feel less stab ul</nowiki><br />
<br />
Each one is a folder containing one or more wav files. For example when you put bd:1 in a sequence, you’re picking up the second wav file in the bd folder. If you ask for the ninth sample and there are only seven in the folder, it’ll wrap around and play the second one.<br />
<br />
If you want to add your own samples, just create a new folder in the samples folder, and put wav files in it.<br />
<br />
=Synths=<br />
<br />
For this section to work, you need to have installed the SuperCollider sc3-plugins. You can either install the latest version from git, or if you are using Linux, you may find it in your package manager. On Fedora the package is called supercollider-sc3-plugins.<br />
<br />
SuperDirt is created with SuperCollider, a fantastic synthesis engine and language with huge sonic possibilities. You can trigger custom SuperCollider synths from TidalCycles in much the same way as you trigger samples. For example:<br />
<br />
<source><br />
d1 $ midinote "60 62*2" # s "supersaw"<br />
</source><br />
<br />
The above plays note 60 and 62 of the MIDI scale, using the midinote parameter. You can alternatively specify notes by name, using n:<br />
<br />
<source><br />
d1 $ n "c5 d5*2" # s "supersaw"<br />
</source><br />
<br />
For half tones you add the suffixes “f” or “s” (flat or sharp) to the note in question.<br />
<br />
<source><br />
d1 $ n "<[a5,cs5,e5,g5]*3 [d5,fs5,g5,c5]>" # s "supersquare" # gain "0.7"<br />
</source><br />
<br />
Above is a two chord progression A7 D7. Notice cs5 and fs5 as C#5 and F#5, respectively.<br />
<br />
<source><br />
d2 $ every 4 (rev) $ n "<[g5 df5 e5 a5] [gf5 d5 c5 g5]*3>" # s "supersaw"<br />
</source><br />
<br />
Now the same chords (A7 D7) this time played as ascending and descending arpeggios and cs5 written as df5and fs5 as gf5. Play both examples together for more fun!<br />
<br />
You can also specify note numbers with n, but where 0 is middle c (rather than 60 with midinote).<br />
<br />
<source><br />
d1 $ n "0 5" # s "supersaw"<br />
</source><br />
<br />
The default sustain length is a bit long so the sounds will overlap, you can adjust this using the sustain parameter<br />
<br />
<source><br />
d1 $ n "c5 d5*2" # s "supersaw" # sustain "0.4 0.2"<br />
</source><br />
<br />
Many example synths can be found in the default-synths-extra.scd file in the SuperDirt/library folder or in default-synths.scd and tutorial-synths.scd in the SuperDirt/synths folder. These include:<br />
<br />
* a series of tutorials: tutorial1, tutorial2, tutorial3, tutorial4, tutorial5<br />
* examples of modulating with the cursor or sound input: pmsin, in, inr<br />
* physical modeling synths: supermandolin, supergong, superpiano, superhex<br />
* a basic synth drumkit: superkick, superhat, supersnare, superclap, super808<br />
* four analogue-style synths: supersquare, supersaw, superpwm, supercomparator<br />
* two digital-style synths: superchip, supernoise<br />
<br />
To find the SuperDirt folder, simply run Quarks.folder in supercollider. The full folder location should appear in the postwindow (which is usually in the bottom right).<br />
<br />
Many of the above synths accept additional Tidal Parameters or interpret the usual parameters in a slightly different way. For complete documentation, see default-synths.scd, but here are some examples to try:<br />
<br />
<source><br />
d1 $ jux (# accelerate "-0.1") $ s "supermandolin*8" # midinote "[80!6 78]/8"<br />
# sustain "1 0.25 2 1"<br />
</source><br />
<br />
<source><br />
d1 $ midinote (slow 2 $ (run 8) * 7 + 50) # s "supergong" # decay "[1 0.2]/4"<br />
# voice "[0.5 0]/8" # sustain (slow 16 $ scale 5 0.5 $ saw1)<br />
</source><br />
<br />
<source><br />
d1 $ sound "superhat:0*8" # sustain "0.125!6 1.2" # accelerate "[0.5 -0.5]/4"<br />
</source><br />
<br />
<source><br />
d1 $ s "super808 supersnare" # n (irand 5)<br />
# voice "0.2" # decay "[2 0.5]/4" # accelerate "-0.1" # sustain "0.5" # speed "[0.5 2]/4"<br />
</source><br />
<br />
<source><br />
d1 $ n (slow 8 "[[c5 e5 g5 c6]*4 [b4 e5 g5 b5]*4]") # s "superpiano"<br />
# velocity "[1.20 0.9 0.8 1]"<br />
</source><br />
<br />
<source><br />
d1 $ n (slow 8 $ "[[c4,e4,g4,c5]*4 [e4,g4,b5,e5]*4]" + "<12 7>") # s "superpiano"<br />
# velocity (slow 8 $ scale 0.8 1.1 sine1) # sustain "8"<br />
</source><br />
<br />
<source><br />
d1 $ n "[c2 e3 g4 c5 c4 c3]/3" # s "[superpwm supersaw supersquare]/24" # sustain "0.5"<br />
# voice "0.9" # semitone "7.9" # resonance "0.3" # lfo "3" # pitch1 "0.5" # speed "0.25 1"<br />
</source><br />
<br />
<source><br />
d1 $ every 16 (density 24 . (|+| midinote "24") . (# sustain "0.3") . (# attack "0.05"))<br />
$ s "supercomparator/4" # midinote ((irand 24) + 24)<br />
# sustain "8" # attack "0.5" # hold "4" # release "4"<br />
# voice "0.5" # resonance "0.9" # lfo "1" # speed "30" # pitch1 "4"<br />
</source><br />
<br />
<source><br />
d1 $ n "[c2 e3 g4 c5 c4 c3]*4/3" # s "superchip" # sustain "0.1"<br />
# pitch2 "[1.2 1.5 2 3]" # pitch3 "[1.44 2.25 4 9]"<br />
# voice (slow 4 "0 0.25 0.5 0.75") # slide "[0 0.1]/8" # speed "-4"<br />
</source><br />
<br />
<source><br />
d2 $ every 4 (echo (negate 3/32)) $ n "c5*4" # s "supernoise"<br />
# accelerate "-2" # speed "1" # sustain "0.1 ! ! 1" # voice "0.0"<br />
</source><br />
<br />
<source><br />
d1 $ s "supernoise/8" # midinote ((irand 10) + 30) # sustain "8"<br />
# accelerate "0.5" # voice "0.5" # pitch1 "0.15" # slide "-0.5" # resonance "0.7"<br />
# attack "1" # release "20" # room "0.9" # size "0.9" # orbit "1"<br />
</source><br />
<br />
This is all quite new and under ongoing development, but you can read about modifying and adding your own synths to SuperDirt at its github repository.</div>ZimaPurplehttps://tidalcycles.org/index.php?title=Tutorial&diff=2935Tutorial2018-12-23T16:51:49Z<p>ZimaPurple: Correct description of randomness using the ?</p>
<hr />
<div>'''Note: this is in the process of being updated for version 1.0.0.'''<br />
<br />
You’ve installed TidalCycles and (Super)Dirt, maybe even made a few sounds, but now you’re ready to get to business and start really learning. This guide will help you get started with simple patterns and walk you through all the way to complex compositions.<br />
<br />
Why not play with the code as you read, running your own experiments by changing the examples, and seeing where they take you?<br />
<br />
= Creating Rhythmic Sequences =<br />
<br />
==Play a Single Sample==<br />
Tidal provides 16 'connections' to the SuperDirt synthesiser, named from d1 to d16. Here’s a minimal example, that plays a kick drum every cycle:<br />
<br />
<source><br />
d1 $ sound "bd"<br />
</source><br />
<br />
Evaluate the above code in the Atom (or Emacs) editor by pressing Ctrl+Enter. If you want to stop the sound again, look ahead to the section on silence.<br />
<br />
In the code above, <source inline>sound</source> tells us we’re making a pattern of sound samples, and <source inline>"bd"</source> is a pattern that contains a single sound. bd is a sample of a kick drum. Samples live inside the Dirt-Samples folder which came with SuperDirt, and each sub-folder under that corresponds to a sample name (like bd).<br />
<br />
To find the SuperDirt samples on your system, in the SuperCollider IDE select the File > Open User Support Directory menu item. From there, open downloaded-quarks and finally Dirt-Samples in there. You should find a lot of folders, each one is a sample bank containing standard wav files. Feel free to make new folders and add your own sounds to it, see the [[Custom Samples]] userbase page for more info.<br />
<br />
We can pick a different sample in the bd folder by adding a colon (:) then a number. For example, this picks the fourth kick drum (it counts from zero, so :3 gives you the fourth sound in the folder):<br />
<br />
<source><br />
d1 $ sound "bd:3"<br />
</source><br />
<br />
If you specify a number greater than the number of samples in a folder, then Tidal just “wraps” around back to the first sample again (it starts counting at zero, e.g. in a folder with five samples, “bd:5” would play “bd:0”).<br />
<br />
It’s also possible to specify the sample number separately:<br />
<br />
<source><br />
d1 $ sound "bd" # n "3"<br />
</source><br />
<br />
The usefulness of doing this will become apparent later.<br />
<br />
==Sequences From Multiple Samples==<br />
Putting things in quotes allows you to define a sequence. For example, the following gives you a pattern of kick drum then snare:<br />
<br />
<source><br />
d1 $ sound "bd sd:3"<br />
</source><br />
<br />
When you run the code above, you are replacing the previous pattern with another one on-the-fly. Congratulations, you’re live coding.<br />
<br />
==Playing More Than One Sequence==<br />
The easiest way to play multiple sequences at the same time is to use two or more connections to the synthesizer:<br />
<br />
<source><br />
d1 $ sound "bd sd:1"<br />
<br />
d2 $ sound "hh hh hh hh"<br />
<br />
d3 $ sound "arpy"<br />
</source><br />
<br />
NOTE: each connection must be evaluated separately in your text editor. That is, you must press Ctrl+Enter three times, once for each line above. ''Make sure that there is a blank line between them each pattern'', or Tidal will evaluate them together and get confused (if you want to evaluate just one line, you can press shift-enter).<br />
<br />
ANOTHER NOTE: If you prefer to refer to patterns by name, rather than by number, you can do that with <source inline>p</source>, for example:<br />
<br />
<source><br />
p "susan" $ sound "bd sd:1"<br />
<br />
p "gerard" $ sound "hh hh hh hh"<br />
</source><br />
<br />
==What is a Cycle?==<br />
A cycle is the main “loop” of time in Tidal. The cycle repeats forever in the background, even when you’ve stopped samples from playing. The cycle’s duration always stays the same unless you modify it with cps, we’ll cover this later. By default, there is one cycle per second.<br />
<br />
Note that this omniprescent cyclic looping doesn’t necessary constrain you, for example it’s common to stretch a pattern outside of a single loop, and vary patterns from one loop to the next. We’ll see several ways to do this later, as well.<br />
<br />
All of the samples inside of a pattern get squashed into a single cycle. The patterns below all loop over the same amount of time:<br />
<br />
<source><br />
d1 $ sound "bd sd"<br />
<br />
d1 $ sound "bd sd hh cp mt arpy drum"<br />
<br />
d1 $ sound "bd sd hh cp mt arpy drum odx bd arpy bass2 feel future"<br />
</source><br />
<br />
Note how the more steps you add to the pattern, the faster it plays them, in order to fit them all in. No matter how many samples you put in a pattern in this way, they will always be distributed evenly within a single cycle.<br />
<br />
=Silence=<br />
At this point you probably want to know how to stop the patterns you started. An empty pattern is defined as silence, so if you want to ‘switch off’ a pattern, you can just set it to that:<br />
<br />
<source><br />
d1 silence<br />
</source><br />
<br />
If you want to set all the connections (from d1 to d9) to be silent at once, there’s a single-word shortcut for that:<br />
<br />
<source><br />
hush<br />
</source><br />
<br />
You can also isolate a single connection and silence all others with the <source inline>solo</source> function. You can do this like so:<br />
<br />
<source><br />
d1 $ sound "bd"<br />
<br />
d2 $ sound "~ cp"<br />
<br />
-- run this and only the bd plays<br />
solo 1 <br />
<br />
-- unsolo it and the cp plays again<br />
unsolo 1 <br />
</source><br />
<br />
=Patterns Within Patterns=<br />
<br />
You can use Tidal’s square brackets syntax to create a pattern grouping:<br />
<br />
<source><br />
d1 $ sound "[bd sd sd] cp"<br />
</source><br />
<br />
Square brackets allow several events to be played inside of a single step. You can think of the above pattern as having two steps, with the first step broken down into a subpattern, which has three steps. Practically, this means you can create denser sub-divisions of cycles:<br />
<br />
<source><br />
d1 $ sound "bd [sd sd]"<br />
<br />
d1 $ sound "bd [sd sd sd]"<br />
<br />
d1 $ sound "bd [sd sd sd sd]"<br />
<br />
d1 $ sound "[bd bd] [sd sd sd sd]"<br />
<br />
d1 $ sound "[bd bd bd] [sd sd]"<br />
<br />
d1 $ sound "[bd bd bd bd] [sd]"<br />
</source><br />
<br />
You can even nest groups inside groups to create increasingly dense and complex patterns:<br />
<br />
<source><br />
d1 $ sound "[bd bd] [bd [sd [sd sd] sd] sd]"<br />
</source><br />
<br />
A shorthand for this kind of grouping is to place a period . between groups, rather than surrounding them in square brackets. We call this technique ‘marking out feet’. For example these two patterns are equivalent:<br />
<br />
<source><br />
d1 $ sound "bd bd . sd sd sd . bd sd"<br />
<br />
d1 $ sound "[bd bd] [sd sd sd] [bd sd]"<br />
</source><br />
<br />
The former approach is often easier to type, but is a relatively new addition to TidalCycles, and so many examples will use the square brackets.<br />
<br />
==Layering (Polyrhythms) Instead of Grouping==<br />
You can also layer up several loops, by using commas to separate the different parts:<br />
<br />
<source><br />
d1 $ sound "[bd bd bd, sd cp sd cp]"<br />
</source><br />
<br />
This would play the sequence bd bd bd at the same time as sd cp sd cp. Note that the first sequence only has three events, and the second one has four. Because tidal ensures both loops fit inside the same cyclic duration, you end up with a polyrhythm.<br />
<br />
You can layer any number of these subpatterns to create many polyrhythms:<br />
<br />
<source><br />
d1 $ sound "[bd bd bd, sd cp sd cp, arpy arpy, odx]"<br />
</source><br />
<br />
And of course you can use groupings inside of the layers:<br />
<br />
<source><br />
d1 $ sound "[bd bd bd, [sd sd] cp, arpy [arpy [arpy arpy] arpy arpy], odx]"<br />
</source><br />
<br />
==Playing one step per cycle==<br />
To specify a group where only one step is played per cycle, use angle brackets. For example:<br />
<br />
<source><br />
d1 $ sound "bd <arpy:1 arpy:2 arpy:3>"<br />
</source><br />
<br />
The above will result in the sequence <code>bd arpy:1 bd arpy:2 bd arpy:3</code>, over three cycles.<br />
<br />
=Pattern Repetition and Speed=<br />
<br />
==Repetition==<br />
There are two short-hand symbols you can use inside patterns to speed things up or slow things down: * and /. You could think of these like multiplication and division.<br />
<br />
Use the * symbol to make a pattern, or part of a pattern, repeat as many times as you’d like:<br />
<br />
<source><br />
d1 $ sound "bd*2"<br />
</source><br />
<br />
This is the same as doing <code>d1 $ sound "bd bd"</code><br />
<br />
The code above uses *2 to make a sample play twice.<br />
<br />
You can use the / symbol to make a part of a pattern slow down, or occur less often:<br />
<br />
<source><br />
d1 $ sound "bd/2"<br />
</source><br />
<br />
The code above uses /2 to make a sample play half as often, or once every 2nd cycle.<br />
<br />
Using different numbers works as you’d expect:<br />
<br />
<source><br />
d1 $ sound "bd*3" -- plays the bd sample three times each cycle<br />
d1 $ sound "bd/3" -- plays the bd samples only once each third cycle<br />
</source><br />
<br />
==Using * and / on Groups==<br />
You can apply the * and / symbols on groups of patterns:<br />
<br />
<source><br />
d1 $ sound "[bd sn]*2 cp"<br />
<br />
d1 $ sound "[bd sn] cp/2"<br />
<br />
d1 $ sound "[[bd sn] cp]*2" -- speeds up the entire pattern by 2<br />
<br />
d1 $ sound "[[bd sn] cp]/2" -- slows down the entire pattern by 2<br />
</source><br />
<br />
You can also use the symbols on nested groups to create more complex rhythms:<br />
<br />
<source><br />
d1 $ sound "[bd sn sn*3]/2 [bd sn*3 bd*4]/3"<br />
<br />
d1 $ sound "[bd [sn sn]*2]/2 [bd [sn bd]/2]*2"<br />
</source><br />
<br />
=Modifying Sequences With Functions=<br />
<br />
Tidal comes into its own when you start building things up with functions which transform the patterns in various ways.<br />
<br />
For example, <code>rev</code> reverses a pattern:<br />
<br />
<source><br />
d1 $ rev (sound "bd*2 [bd [sn sn*2 sn] sn]")<br />
</source><br />
<br />
That’s not so exciting, but things get more interesting when this is used in combination with another function. For example every takes three parameters: <br />
a number, a function and a pattern to apply the function to. The number specifies how often the function is applied to the pattern. For example, the <br />
following reverses the pattern every fourth repetition:<br />
<br />
<source><br />
d1 $ every 4 (rev) (sound "bd*2 [bd [sn sn*2 sn] sn]")<br />
</source><br />
<br />
It takes a while to get used to how we’re using parenthesis here. In the previous example, rev takes one parameter, a pattern, and we had to ‘wrap up’ the <br />
pattern sound <code>"[bd bd] [bd [sn [sn sn] sn] sn]"</code> in brackets to pass it to rev. In the above example every takes three parameters: a number, <br />
a function and a pattern. We had to wrap up the pattern as before, but also rev in order to give it to every. This should become clearer with practice.<br />
<br />
You can also slow down or speed up the playback of a pattern, this makes it a quarter of the speed:<br />
<br />
<source><br />
d1 $ slow 4 $ sound "bd*2 [bd [sn sn*2 sn] sn]"<br />
</source><br />
<br />
And this four times the speed:<br />
<br />
<source><br />
d1 $ fast 4 $ sound "bd*2 [bd [sn sn*2 sn] sn]"<br />
</source><br />
<br />
Note that slow 0.25 would do exactly the same as fast 4.<br />
<br />
Again, this can be applied selectively:<br />
<br />
<source><br />
d1 $ every 4 (fast 4) $ sound "bd*2 [bd [sn sn*2 sn] sn]"<br />
</source><br />
<br />
Note again the use of parenthesis, around fast 4. This is needed, to group together the function fast with its parameter 4, before being passed as a parameter to the function every.<br />
<br />
In the examples above, the sound function takes a pattern of sample names, and turns it into a pattern of synthesizer triggers. <br />
This might take a while to fully understand, but the important thing to remember is that “it’s patterns all the way down”. <br />
In this case, this means that you can operate on the inner pattern of sample names, instead of the outer pattern of synthesizer triggers that sound gives you:<br />
<br />
<source><br />
d1 $ sound (every 4 (fast 4) "bd*2 [bd [sn sn*2 sn] sn]")<br />
</source><br />
<br />
The fast function is also known as density, which is actually the older name, so a lot of examples will use it instead of the <br />
(slightly quicker to type) fast. They do exactly the same thing.<br />
<br />
==Where are all the functions?==<br />
There are many types of functions that help you change patterns. Some of them re-order sequences, some alter time, some provide conditional logic, and some can help compose more complex patterns.<br />
<br />
We’ll introduce many of the core functions in this introduction, and a more complete list of functions available in Tidal can be found on the [[Category:Functions|functions category]] page.<br />
<br />
=Applying effects with control patterns=<br />
<br />
TidalCycles has a number of effects that you can apply to sounds. Some of them do simple things like change volume, and others do more complex things like add delay or distortion. This is done with what we call ''control patterns''. In fact <source inline>sound</source> itself creates a control pattern, and we apply effects by combining control patterns together.<br />
<br />
You can combine control patterns by adding the # operator between them:<br />
<br />
<source><br />
d1 $ sound "bd*4" # crush "4"<br />
</source><br />
<br />
The above code uses <source inline>crush</source> to create a bitcrushing control pattern with a value of 4 (which sounds really grungy), and uses <source inline>#</source> to join that with the <source inline>sound</source> control pattern.<br />
<br />
You can combine multiple control patterns together, with the # operator:<br />
<br />
<source><br />
d1 $ sound "bd*4" # crush "4" # speed "2"<br />
</source><br />
<br />
The code above both bitcrushes and speeds up sample playback (which increases the ‘pitch’).<br />
<br />
==Control values are patterns too==<br />
You may notice that the values of effects are specified in double quotes. This means that you can pattern the effect values too:<br />
<br />
<source><br />
d1 $ sound "bd*4" # gain "1 0.8 0.5 0.7"<br />
</source><br />
<br />
The above <source inline>gain</source> effect changes how loud the sample is, good for patterns of emphasis as above. Other control patterns follow all the same grouping rules as sound patterns:<br />
<br />
<source><br />
d1 $ sound "bd*4 sn*4" # gain "[[1 0.8]*2 [0.5 0.7]]/2"<br />
</source><br />
<br />
And you can also apply functions to control patterns:<br />
<br />
<source><br />
d1 $ sound "bd*4" # (every 3 (rev) $ gain "1 0.8 0.5 0.7")<br />
</source><br />
<br />
Like with the sound example earlier, you must use parenthesis after gain in order to specify a function on the gain pattern.<br />
<br />
This works too:<br />
<br />
<source><br />
d1 $ sound "bd*4" # gain (every 3 (rev) $ "1 0.8 0.5 0.7")<br />
</source><br />
<br />
In the above example, <source inline>every 3 (rev)</source> is being applied to <source inline>"1 0.8 0.5 0.7"</source>, which is a pattern of numbers. In the example preceding it, the same function was applied to <source inline>gain "1 0.8 0.5 0.7"</source>, which is a pattern of gain controls. In this case, whether you apply the function before or after the numbers are turned into controls doesn't matter too much, the outcome is exactly the same.<br />
<br />
==Control pattern order==<br />
You can specify the effect control ''before'' the sound control:<br />
<br />
<source><br />
d1 $ gain "1 0.8 0.5 0.7" # sound "bd"<br />
</source><br />
<br />
The order that you put things matters; with <source inline>#</source>the structure of the pattern is given by the pattern on the ''left''. In this case, only one bd sound is given, but you hear four, because the structure comes from the gain pattern on the left.<br />
<br />
==Modifying control values==<br />
<br />
The # operator is just a shortcut to a longer form of operator called <source inline>|=</source>. The <source inline>|=</source> operator is part of a family of operators, and means something special about combining patterns, which we’ll cover shortly. All you need to know right now is that <source inline>|=</source> is used to combine patterns.<br />
<br />
You can use <source inline>|=</source> to combine patterns conditionally:<br />
<br />
<source><br />
d1 $ every 2 (|= speed "2") $ sound "arpy*4" |= speed "1"<br />
</source><br />
<br />
There are other types of operators that allow you to perform arithmetic:<br />
<br />
|+<br />
|-<br />
|*<br />
|/<br />
<br />
For example, using <source inline>|+</source> will perform an addition operation and add to an original value:<br />
<br />
<source><br />
d1 $ every 2 (|+ speed "1") $ sound "arpy*4" |= speed "1"<br />
</source><br />
<br />
The code above results in a speed of “2” every other cycle.<br />
<br />
The following will multiply values:<br />
<br />
<source><br />
d1 $ every 2 (|* speed "1.5") $ sound "arpy*4" |= speed "1"<br />
</source><br />
<br />
More complex patterns and chaining can be done, and with any effect, of course:<br />
<br />
<source><br />
d1 $ every 3 (|- note "3") $ every 2 (|+ up "5") $ sound "arpy*4" |= note "0 2 4 5"<br />
</source><br />
<br />
It might be worth sticking to just these ways of combining control patterns for now, but if you are curious, you can look into the [[Combining pattern structure|others that are available]].<br />
<br />
==Some Common Effects==<br />
Here is a quick list of some effects you can use in Tidal (the full list is available in the Reference section):<br />
<br />
* gain - changes volume, values from 0 to 1<br />
* pan - pans sound right and left, values from 0 to 1<br />
* shape - a type of amplifier, values from 0 to 1<br />
* vowel - a vowel formant filter, values include a, e, i, o, and u<br />
* speed - changes playback speed of a sample, see below<br />
<br />
=Shorthand for numerical patterns=<br />
<br />
From version 0.9 of Tidal, there are some nice ways of saving on keypresses when working with numerical patterns.<br />
<br />
For example, when specifying patterns of single numbers, such as:<br />
<br />
<source><br />
d1 $ sound "arpy(3,8)" # n "2"<br />
</source><br />
<br />
you can miss off the double quotes, so this works fine:<br />
<br />
<source><br />
d1 $ sound "arpy(3,8)" # n 2<br />
</source><br />
<br />
However, if you wanted more than one value in that n pattern, you’d have to put the quotes in:<br />
<br />
<source><br />
d1 $ sound "arpy(3,8)" # n "2 5"<br />
</source><br />
<br />
You can also treat patterns of numbers as simple numbers in other ways. For example doing algebra:<br />
<br />
<source><br />
d1 $ sound "arpy(3,8)" # n ("0 2" * 2)<br />
<br />
d1 $ sound "arpy(3,8)" # n (every 4 (* 2) "0 2")<br />
<br />
d1 $ n (off 0.125 (+12) $ off 0.25 (+7) $ slow 2 $ "0(3,8) [5 7]") # sound "supergong"<br />
</source><br />
<br />
This is still quite new to everyone, so you will not see it used much in the documentation yet.<br />
<br />
You can also now specify increasing or decreasing numbers with a range, for example this:<br />
<br />
d1 $ n "[0..7] [3..1]" # sound "supergong"<br />
<br />
... is shorthand for:<br />
<br />
<source><br />
d1 $ n "[0 1 2 3 4 5 6 7] [3 2 1]" # sound "supergong"<br />
</source><br />
<br />
=Sample Playback Speed (and Pitch)=<br />
<br />
You can change the playback speed of a sample in TidalCycles by using the speed effect. You can use speed to change pitches, to create a weird effect, or to match the length of a sample to a specific period of the cycle time (but see the loopAt function for an easy way of doing the latter).<br />
<br />
You can set a sample’s speed by using the speed effect with a number.<br />
<br />
* speed "1" plays a sample at its original speed<br />
* speed "0.5" plays a sample at half of its original speed<br />
* speed "2" plays a sample at double its original speed<br />
<br />
<source>d1 $ sound "arpy" # speed "1"<br />
<br />
d1 $ sound "arpy" # speed "0.5"<br />
<br />
d1 $ sound "arpy" # speed "2"</source><br />
<br />
Just like other effects, you can specify a pattern for speed:<br />
<br />
d1 $ speed "1 0.5 2 1.5" # sound "arpy" <br />
<br />
You can also reverse a sample by specifying negative values:<br />
<br />
<source><br />
d1 $ speed "-1 -0.5 -2 -1.5" # sound "arpy"<br />
</source><br />
<br />
==Play a sample at multiple speeds simultaneously==<br />
Use the pattern grouping syntax with a comma to cause speed to play a sample back at multiple speeds at the same time:<br />
<br />
<source><br />
d1 $ sound "arpy" # speed "[1, 1.5]"<br />
d1 $ speed "[1 0.5, 1.5 2 3 4]" # sound "arpy"<br />
</source><br />
<br />
==12-tone scale speeds==<br />
You can also use the up function to change playback speed. up is a shortcut effect that matches speeds to half steps on a 12-tone scale. For example, the following plays a chromatic scale:<br />
<br />
<source><br />
d1 $ up "0 1 2 3 4 5 6 7 8 9 10 11" # sound "arpy"<br />
</source><br />
<br />
You can also use the run function to create an incrementing pattern of integers: <br />
<br />
<source><br />
d1 $ up (run 12) # sound "arpy". <br />
</source><br />
<br />
The <code>run</code> function will be discussed later.<br />
<br />
=Euclidean Sequences=<br />
If you give two numbers in parenthesis after an element in a pattern, then Tidal will distribute the first number of sounds equally across the second number of steps:<br />
<br />
<source><br />
d1 $ sound "bd(5,8)"<br />
</source><br />
<br />
You can also use the [[euclid]] function to do this. [[euclid]] takes the same two arguments as what is used in the parenthesis above:<br />
<br />
<source><br />
d1 $ euclid 5 8 $ sound "bd"<br />
</source><br />
<br />
You can use the parenthesis notation within a single element of a pattern:<br />
<br />
<source><br />
d1 $ sound "bd(3,8) sn*2"<br />
</source><br />
<br />
<source><br />
d1 $ sound "bd(3,8) sn(5,8)"<br />
</source><br />
<br />
You can also add a third parameter, which ‘rotates’ the pattern so it starts on a different step:<br />
<br />
<source><br />
d1 $ sound "bd(5,8,2)"<br />
</source><br />
<br />
You can also use the euclid function to apply a Euclidean algorithm over a complex pattern, although the structure of that pattern will be lost:<br />
<br />
<source><br />
d1 $ euclid 3 8 $ sound "bd*2 [sn cp]"<br />
</source><br />
<br />
In the above, three sounds are picked from the pattern on the right according to the structure given by the euclid 3 8. It ends up picking two bd sounds, a cp and missing the sn entirely.<br />
<br />
As a bonus, it is possible to pattern the parameters within the parenthesis, for example to alternate between 3 and 5 elements:<br />
<br />
<source><br />
d1 $ sound "bd([5 3]/2,8)"<br />
</source><br />
<br />
These types of sequences use “Bjorklund’s algorithm”, which wasn’t made for music but for an application in nuclear physics, which is exciting. More exciting still is that it is very similar in structure to the one of the first known algorithms written in Euclid’s book of elements in 300 BC. You can read more about this in the paper The Euclidean Algorithm Generates Traditional Musical Rhythms by Toussaint. Some examples from this paper are included below, including rotation in some cases.<br />
<br />
* (2,5) : A thirteenth century Persian rhythm called Khafif-e-ramal.<br />
* (3,4) : The archetypal pattern of the Cumbia from Colombia, as well as a Calypso rhythm from Trinidad.<br />
* (3,5,2) : Another thirteenth century Persian rhythm by the name of Khafif-e-ramal, as well as a Rumanian folk-dance rhythm.<br />
* (3,7) : A Ruchenitza rhythm used in a Bulgarian folk-dance.<br />
* (3,8) : The Cuban tresillo pattern.<br />
* (4,7) : Another Ruchenitza Bulgarian folk-dance rhythm.<br />
* (4,9) : The Aksak rhythm of Turkey.<br />
* (4,11) : The metric pattern used by Frank Zappa in his piece titled Outside Now.<br />
* (5,6) : Yields the York-Samai pattern, a popular Arab rhythm.<br />
* (5,7) : The Nawakhat pattern, another popular Arab rhythm.<br />
* (5,8) : The Cuban cinquillo pattern.<br />
* (5,9) : A popular Arab rhythm called Agsag-Samai.<br />
* (5,11) : The metric pattern used by Moussorgsky in Pictures at an Exhibition.<br />
* (5,12) : The Venda clapping pattern of a South African children’s song.<br />
* (5,16) : The Bossa-Nova rhythm necklace of Brazil.<br />
* (7,8) : A typical rhythm played on the Bendir (frame drum).<br />
* (7,12) : A common West African bell pattern.<br />
* (7,16,14) : A Samba rhythm necklace from Brazil.<br />
* (9,16) : A rhythm necklace used in the Central African Republic.<br />
* (11,24,14) : A rhythm necklace of the Aka Pygmies of Central Africa.<br />
* (13,24,5) : Another rhythm necklace of the Aka Pygmies of the upper Sangha.<br />
<br />
=Tempo=<br />
<br />
If you’ve made it this far without changing the tempo in all these examples, then you’re probably ready to change it up.<br />
<br />
Tidal’s core unit of time is cycles per second. It can be set with the <source inline>setcps</source> function:<br />
<br />
<source><br />
setcps 1<br />
</source><br />
<br />
You can execute setcps just like a pattern (using Shift+Enter in your editor).<br />
<br />
<source inline>setcps</source> accepts a positive numeric value that can include a decimal:<br />
<br />
<source><br />
setcps 1.5<br />
setcps 0.75<br />
setcps 10<br />
</source><br />
<br />
Tidal’s timing is based on cycles, rather than beats, however it is more common for people to think in terms of beats per minute (BPM). If you prefer to think in this way, you have to decide how many beats you want to have per cycle, and divide accordingly. For example if you wanted to play at 140 bpm, with four beats per cycle, then you could do:<br />
<br />
<source><br />
setcps (140/60/4)<br />
</source><br />
<br />
You can also pattern the tempo with the <source inline>cps</source> control function, for example:<br />
<br />
<source><br />
d1 $ sound "cp(3,8)"<br />
# cps (slow 8 $ range 0.8 1.6 saw)<br />
</source><br />
<br />
=The Run Function=<br />
<br />
There is a special utility function called run which will return a pattern of integers up to a specified maximum. You can use run with effects to aid in automatically generating a linear pattern:<br />
<br />
<source><br />
d1 $ sound "arpy*8" # up (run 8)<br />
d1 $ sound "arpy*8" # speed (run 8)<br />
</source><br />
<br />
In the above we’re specifying the number of sounds twice - in the sound pattern as well as the up or speed pattern. There’s actually a neat way of only having to specify this once, simply by switching them round, so the effect parameter is on the left:<br />
<br />
<source><br />
d1 $ up (run 8) # sound "arpy"<br />
</source><br />
<br />
This works because TidalCycles always takes the structure of a pattern from the parameter that’s on the left. We usually want the structure to come from the sound parameter, but not always.<br />
<br />
Because run returns a pattern, you can apply functions to its result:<br />
<br />
<source><br />
d1 $ sound "arpy*8" # up (every 2 (rev) $ run 8)<br />
</source><br />
<br />
For a more practical example of using run, read below about selecting samples from folders.<br />
<br />
=(Algorithmically) Selecting Samples=<br />
<br />
The sound parameter we’ve been using up to now can actually be broken into two separate parameters, making it easy to select samples with a pattern. These parameters are s that gives the name of the sample set, and n which gives the number of the sample within that set. For example, the following two patterns do exactly the same:<br />
<br />
<source><br />
d1 $ sound "arpy:0 arpy:2 arpy:3"<br />
d1 $ n "0 2 3" # s "arpy"<br />
</source><br />
<br />
It’s possible to break the sound parameter into two different patterns, namely s that gives the name of the sample set, and n which gives the index of the sample within that set. For example, the following two patterns are the same:<br />
<br />
<source><br />
d1 $ sound "arpy:0 arpy:2 arpy:3"<br />
d1 $ n "0 2 3" # s "arpy"<br />
</source><br />
<br />
This allows us to separate the sample folder name from the index inside the folder, possibly with surprising results!<br />
<br />
There is also special function called samples that lets you do the same using the sound parameter.<br />
<br />
<source><br />
d1 $ sound $ samples "drum*4" "0 1 2 3"<br />
</source><br />
<br />
the code above is the same as this:<br />
<br />
<source><br />
d1 $ sound "drum:0 drum:1 drum:2 drum:3"<br />
</source><br />
<br />
Whether you use n and s together, or sound with samples is up to you, although you might find the former to be more flexible.<br />
<br />
Remember the run function? Since run generates a pattern of integers, it can be used with n to automatically “run” through the sample indices of a folder:<br />
<br />
<source><br />
d1 $ n (run 4) # s "drum"<br />
d1 $ sound $ samples "drum*4" (run 4) -- or with samples<br />
</source><br />
<br />
And of course you can specify a different pattern of sample names:<br />
<br />
<source><br />
d1 $ s "drum arpy cp hh" # n (run 10)<br />
</source><br />
<br />
Again, by swapping the order of the s and n parameters, you can hear the difference between taking the structure from one or the other:<br />
<br />
<source><br />
d1 $ n (run 10) # s "drum arpy cp hh"<br />
</source><br />
<br />
NOTE: if you specify a run value that is greater than the number of samples in a folder, then the higher number index will “wrap” to the beginning of the samples in the folder (just like with the colon notation).<br />
<br />
You might sometimes see the samples function wrapped in parenthesis:<br />
<br />
<source><br />
d1 $ sound (samples "drum arpy cp hh" (run 10))<br />
</source><br />
<br />
=Combining Types of Patterns=<br />
<br />
Ok, remember when we started adding effects:<br />
<br />
<source><br />
d1 $ sound "bd sn drum arpy" # pan "0 1 0.25 0.75"<br />
</source><br />
<br />
What we’re actually doing in the code above is combining two patterns together: the sound pattern, and the pan pattern. The special pipe operators (|=, |+, |-, |*, |/, |>, and so on), allow us to combine two patterns. Remember that # is shorthand for |>.<br />
<br />
We can actually swap sides and it sounds the same:<br />
<br />
<source><br />
d1 $ pan "0 1 0.25 0.75" # sound "bd sn drum arpy"<br />
</source><br />
<br />
As we touched on earlier, the main thing to know when combining patterns like this is that the left-most pattern determines the rhythmic structure of the result. Removing one of the elements from the pan pattern on the left results in a cycle with three samples played:<br />
<br />
<source><br />
d1 $ pan "0 1 0.25" # sound "bd sn drum arpy"<br />
</source><br />
<br />
In the code above, the pan pattern determines the rhythm because it is the left-most pattern. The sound pattern now only determines what samples are played at what time. The sound pattern gets mapped onto the pan pattern.<br />
<br />
You might be wondering how TidalCycles decides which sound values get matched with which pan values in the above. (If not, there is no need to read the rest of this paragraph just now!) The rule is, for each value in the pattern on the left, values from the right are matched where the start (or onset) of the left value, fall within the timespan of the value on the right. For example, the second pan value of 1 starts one third into its pattern, and the second sound value of sn starts one quarter into its pattern, and ends at the halfway point. Because the former onset (one third) falls inside the timespan of the latter timespan (from one quarter until one half), they are matched. The timespan of arpy doesn’t contain any onsets from the pan pattern, and so it doesn’t match with anything, and isn’t played.<br />
<br />
The rule described above may seem like a lot to keep in mind while composing patterns, but in practice there is no need. Our advice is to not worry, write some patterns and get a feel for how they fit together.<br />
<br />
Anyway, this composition of pattern parameters allows us to do some unique things:<br />
<br />
<source><br />
d1 $ up "0 0*2 0*4 1" # sound "[arpy, bass2, bd]"<br />
</source><br />
<br />
Above, the sound pattern is merely specifying three samples to play on every note. Both the rhythm and pitch of these notes is defined by the up pattern.<br />
<br />
It's also possible to switch things around so that structure comes from the right, by using the operators >|, *|, +|, /| and -|, instead of |>, |*, |+ and |-, for example:<br />
<br />
<source><br />
d1 $ sound "drum" >| n "0 1*2 ~ 3"<br />
</source><br />
<br />
The side of the operator that the | is on, is where the structure comes from. In fact, if you put the bar on both sides, structure comes from both sides:<br />
<br />
<source><br />
d1 $ sound "drum cp" >| n "0 1 2"<br />
</source><br />
<br />
=Oscillation with Continuous Patterns=<br />
<br />
So far we’ve only been working with discrete patterns, by which we mean patterns which containing events which begin and end. Tidal also supports continuous patterns which instead vary continually over time. You can create continuous patterns using functions which give sine, saw, triangle, and square waves:<br />
<br />
<source><br />
d1 $ sound "bd*16" # pan sine<br />
</source><br />
<br />
The code above uses the sine pattern to specify a sine wave oscillation of values between 0 and 1 for the pan values, so the bass drum moves smoothly between the left and right speakers.<br />
<br />
Tidal used to have sine and sine1 patterns with different ranges, but now they are aliases, with both giving a range from 0 to 1.<br />
<br />
In addition to the sine pattern, Tidal also has saw, tri, and square, for sawtooth, triangle and square waves respectively.<br />
<br />
Just like discrete patterns, you can control the speed of continuous patterns with slow or density:<br />
<br />
<source><br />
d1 $ sound "bd*16" # pan (slow 8 $ saw)<br />
d1 $ sound "bd*8 sn*8" # pan (density 1.75 $ tri)<br />
d1 $ sound "bd*8 sn*8" # speed (density 2 $ tri)<br />
</source><br />
<br />
You can also combine them in different ways:<br />
<br />
<source><br />
d1 $ sound "bd*16" # pan (slowcat [sine, saw, square, tri])<br />
d1 $ sound "sn:2*16" # speed ((range 0.5 3 sine) * (slow 4 saw))<br />
</source><br />
<br />
==Scaling Oscillation==<br />
You can tell the oscillation functions to scale themselves and oscillate between two values using range:<br />
<br />
A recent change in tidal repurposed the old scale function to range, to free scale to be used for other purposes.<br />
<br />
<source><br />
d1 $ sound "bd*8 sn*8" # speed (range 1 3 $ tri)<br />
d1 $ sound "bd*8 sn*8" # speed (slow 4 $ range 1 3 $ tri)<br />
</source><br />
<br />
You can also scale to negative values, but make sure to wrap negative values in parens (otherwise the interpreter thinks you’re trying to subtract 2 from something):<br />
<br />
<source><br />
d1 $ sound "bd*8 sn*8" # speed (range (-2) 3 $ tri)<br />
</source><br />
<br />
This technique works well for a slow low-pass filter cutoff:<br />
<br />
<source><br />
d1 $ sound "hh*32" # cutoff (range 300 1000 $ slow 4 $ sine) # resonance "0.4"<br />
</source><br />
<br />
'''NOTE''': Despite the fact that these oscillator patterns produce continuous values, you still need to combine them with discrete sound patterns.<br />
<br />
=Rests=<br />
<br />
So far we have produced patterns that keep producing more and more sound. What if you want a rest, or gap of silence, in your pattern? You can use the “tilde” ~ character to do so:<br />
<br />
<source><br />
d1 $ sound "bd bd ~ bd"<br />
</source><br />
<br />
Think of the <code>~</code> as an ‘empty’ step in a sequence, that just produces silence.<br />
<br />
=Polymeters=<br />
<br />
We talked about polyrhythms earlier, but Tidal can also produce polymeter sequences. A polymeter pattern is one where two patterns have different sequence lengths, but share the same pulse or tempo.<br />
<br />
You use curly brace syntax to create a polymeter rhythm:<br />
<br />
<source><br />
d1 $ sound "{bd hh sn cp, arpy bass2 drum notes can}"<br />
</source><br />
<br />
The code above results in a five-note rhythm being played at the pulse of a four-note rhythm. If you switch the groups around, it results in a four-note rhythm over a five-note rhythm:<br />
<br />
<source><br />
d1 $ sound "{arpy bass2 drum notes can, bd hh sn cp}"<br />
</source><br />
<br />
Sometimes you might want to create an odd polymeter rhythm without having to explicitly create a base rhythm. You could do this with rests:<br />
<br />
<source><br />
d1 $ sound "{~ ~ ~ ~, arpy bass2 drum notes can}"<br />
</source><br />
<br />
But a more efficient way is to use the % symbol after the closing curly brace to specify the number of notes in the base pulse:<br />
<br />
<source><br />
d1 $ sound "{arpy bass2 drum notes can}%4"<br />
</source><br />
<br />
the above is the same as this:<br />
<br />
<source><br />
d1 $ sound "{~ ~ ~ ~, arpy bass2 drum notes can}"<br />
</source><br />
<br />
If “polymeter” sounds a bit confusing, there’s a good explanation here: http://music.stackexchange.com/questions/10488/polymeter-vs-polyrhythm<br />
<br />
=Shifting Time=<br />
<br />
You can use the <code>~></code> and <code><-</code> functions to shift patterns forwards or backwards in time, respectively. With each of these functions, you can specify an amount, in cycle units.<br />
<br />
<source><br />
d1 $ (0.25 <~) $ sound "bd*2 cp*2 hh sn"<br />
d1 $ (0.25 ~>) $ sound "bd*2 cp*2 hh sn"<br />
</source><br />
<br />
The above code shifts the patterns over by one quarter of a cycle.<br />
<br />
You can hear this shifting effect best when applying it conditionally. For example, the below shifts the pattern every third cycle:<br />
<br />
<source><br />
d1 $ every 3 (0.25 <~) $ sound "bd*2 cp*2 hh sn"<br />
d1 $ every 3 (0.25 ~>) $ sound "bd*2 cp*2 hh sn"<br />
</source><br />
<br />
You can shift patterns as little or as much as you’d like:<br />
<br />
<source><br />
d1 $ every 3 (0.0625 <~) $ sound "bd*2 cp*2 hh sn"<br />
d1 $ every 3 (1000 ~>) $ sound "bd*2 cp*2 hh sn"<br />
d1 $ every 3 (1000.125 ~>) $ sound "bd*2 cp*2 hh sn"<br />
</source><br />
<br />
However, in the above case every cycle is the same, so you won’t here a difference between shifting it 1 or 1000 cycles.<br />
<br />
You can also specify a pattern for the shift amount:<br />
<br />
<source><br />
d1 $ "[0 0.25]/4" <~ (sound "bd*2 cp*2 hh sn")<br />
</source><br />
<br />
=Introducing Randomness=<br />
<br />
Tidal can produce random patterns of integers and decimals. It can also introduce randomness into patterns by removing random events.<br />
<br />
==Random Decimal Patterns==<br />
You can use the rand function to create a random value between 0 and 1. This is useful for effects:<br />
<br />
<source><br />
d1 $ sound "arpy*4" # pan (rand)<br />
</source><br />
<br />
As with run and all numeric patterns, the values that rand give you can be scaled, for example the below gives random numbers between 0.25 and 0.75:<br />
<br />
<source><br />
d1 $ sound "arpy*4" # pan (range 0.25 0.75 $ rand)<br />
</source><br />
<br />
==Random Integer Patterns==<br />
Use the irand function to create a random integer up to a given maximum. The most common usage of irand is to produce a random pattern of sample indices (similar to run):<br />
<br />
<source><br />
d1 $ s "arpy*8" # n (irand 30)<br />
</source><br />
<br />
The code above randomly chooses from 30 samples in the “arpy” folder.<br />
<br />
Hairy detail: rand and irand are actually continuous patterns, which in practical terms means they have infinite detail - you can treat them as pure information! As with all patterns they are also deterministic, stateless functions of time, so that if you retriggered a pattern from the same logical time point, exactly the same numbers would be produced. Furthermore, if you use a rand or irand in two different places, you would get the same ‘random’ pattern - if this isn’t what you want, you can simply shift or slow down time a little for one of them, e.g. slow 0.3 rand.<br />
<br />
==Removing or “Degrading” Pattern events==<br />
Tidal has a few ways to randomly remove events from patterns. You can use the shorthand ? symbol if you want to give an event a 50/50 chance of happening or not on every cycle:<br />
<br />
<source><br />
d1 $ sound "bd? sd? sd? sd?"<br />
</source><br />
<br />
In the code above, the whole sample has a 50% chance if it will be played or if the whole cycle will be silent.<br />
<br />
You can add the ? after the completion of any event or group in a pattern:<br />
<br />
<source><br />
d1 $ sound "bd*16?"<br />
d1 $ sound "bd sn? cp hh?"<br />
d1 $ sound "[bd sn cp hh]?"<br />
</source><br />
<br />
The <code>?</code> symbol is shorthand for the degrade function. The two lines below are equivalent:<br />
<br />
<source><br />
d1 $ sound "bd*16?"<br />
d1 $ degrade $ sound "bd*16"<br />
</source><br />
<br />
Related to degrade is the degradeBy function, where you can specify the probability (from 0 to 1) that events will be removed from a pattern:<br />
<br />
<source><br />
d1 $ degradeBy 0.25 $ sound "bd*16"<br />
</source><br />
<br />
There is also sometimesBy, which executes a function based on a probability:<br />
<br />
<source><br />
d1 $ sometimesBy 0.75 (# crush 4) $ sound "bd arpy sn ~"<br />
</source><br />
<br />
The code above has a 75% chance of applying the bitcrush effect pattern # crush 4 on every event in the sound pattern.<br />
<br />
There are other aliases for sometimesBy:<br />
<br />
<source><br />
sometimes = sometimesBy 0.5<br />
often = sometimesBy 0.75<br />
rarely = sometimesBy 0.25<br />
almostNever = sometimesBy 0.1<br />
almostAlways = sometimesBy 0.9<br />
</source><br />
<br />
e.g.:<br />
<br />
<source><br />
d1 $ rarely (# crush 4) $ sound "bd*8"<br />
</source><br />
<br />
=Creating Variation in Patterns=<br />
<br />
You can create a lot of cyclic variations in patterns by layering conditional logic:<br />
<br />
<source><br />
d1 $ every 5 (|+| speed "0.5") $ every 4 (0.25 <~) $ every 3 (rev) $<br />
sound "bd sn arpy*2 cp"<br />
# speed "[1 1.25 0.75 -1.5]/3"<br />
</source><br />
<br />
In addition to every you can also use the whenmod conditional function. whenmod takes two parameters; it executes a function when the remainder of the current loop number divided by the first parameter is greater or equal than the second parameter.<br />
<br />
For example, the following will play a pattern normally for cycles 1-6, then play it in reverse for cycles 7-8. Then normally again for six cycles, then in reverse for two, and so on:<br />
<br />
<source><br />
d1 $ whenmod 8 6 (rev) $ sound "bd*2 arpy*2 cp hh*4"<br />
</source><br />
<br />
=Creating "Fills" and using "const"=<br />
<br />
You can think of a “fill” as a change to a regular pattern that happens regularly. e.g. every 4 cycles do “xya”, or every 8 cycles do “abc”.<br />
<br />
We’ve already been using every and whenmod to do pattern function fills:<br />
<br />
<source><br />
d1 $ every 8 (rev) $ every 4 (density 2) $ sound "bd hh sn cp"<br />
d1 $ whenmod 16 14 (# speed "2") $ sound "bd arpy*2 cp bass2"<br />
</source><br />
<br />
However, what if you wanted to conditionally replace the pattern with a new one? You can use the const function to completely replace a playing pattern.<br />
<br />
Let’s start with a trivial example where we use const to replace an entire pattern all the time:<br />
<br />
<source><br />
d1 $ const (sound "arpy*3") $ sound "bd sn cp hh"<br />
</source><br />
<br />
In the code above, we’ve completely replaced the “bd sn cp hh” pattern with an “arpy” pattern. const specifies the new pattern.<br />
<br />
We can conditionally apply const using every or whenmod:<br />
<br />
<source><br />
d1 $ whenmod 8 6 (const $ sound "arpy(3,8) bd*4") $ sound "bd sn bass2 sn"<br />
d1 $ every 12 (const $ sound "bd*4 sn*2") $ sound "bd sn bass2 sn"<br />
</source><br />
<br />
=Composing Multi-Part Patterns=<br />
<br />
There are a few ways that you can compose new patterns from multiple other patterns. You can concatenate or “append” patterns in serial, or you can “stack” them and play them together in parallel.<br />
<br />
==Concatenating patterns in serial==<br />
You can use the <code>fastcat</code> function to add patterns one after another:<br />
<br />
<source><br />
d1 $ fastcat [sound "bd sn:2" # vowel "[a o]/2",<br />
sound "casio casio:1 casio:2*2"<br />
]<br />
</source><br />
<br />
The <code>fastcat</code> function squeezes all the patterns into the space of one. The more patterns you add to the list, the faster each pattern will be played so that all patterns can fit into a single cycle.<br />
<br />
<source><br />
d1 $ fastcat [sound "bd sn:2" # vowel "[a o]/2",<br />
sound "casio casio:1 casio:2*2",<br />
sound "drum drum:2 drum:3 drum:4*2"<br />
]<br />
</source><br />
<br />
<code>cat</code> (also known as <code>slowcat</code>), will maintain the original playback speed of the patterns:<br />
<br />
<source><br />
d1 $ cat [sound "bd sn:2" # vowel "[a o]/2",<br />
sound "casio casio:1 casio:2*2",<br />
sound "drum drum:2 drum:3 drum:4*2"<br />
]<br />
</source><br />
<br />
<code>cat</code> is a great way to create a linear sequence of patterns (a sequence of sequences), giving a larger form to multiple patterns.<br />
<br />
There’s also <code>randcat</code>, which will play a random pattern from the list.<br />
<br />
==Playing patterns together in parallel==<br />
<br />
The <code>stack</code> function takes a list of patterns and combines them into a new pattern by playing all of the patterns in the list simultaneously.<br />
<br />
<source><br />
d1 $ stack [<br />
sound "bd bd*2",<br />
sound "hh*2 [sn cp] cp future*4",<br />
sound (samples "arpy*8" (run 16))<br />
]<br />
</source><br />
<br />
This is useful if you want to apply functions or effects on the entire stack:<br />
<br />
<source><br />
d1 $ every 4 (slow 2) $ whenmod 5 3 (# speed "0.75 1.5") $ stack [<br />
sound "bd bd*2",<br />
sound "hh*2 [sn cp] cp future*4",<br />
sound (samples "arpy*8" (run 16))<br />
] # speed "[[1 0.8], [1.5 2]*2]/3"<br />
</source><br />
<br />
=Truncating samples with "cut"=<br />
<br />
So far, all of our examples have used short samples. However, maybe you’ve experimented with some long samples. Maybe you’ve noticed that really long samples can cause a lot of bleed and unwanted sound.<br />
<br />
With Tidal’s cut effect, you can “choke” a sound and stop it from playing when a new sample is triggered.<br />
<br />
Consider the following example where we have a pattern of “arpy” sounds, played at a low speed, so there is a lot of bleed into each sample:<br />
<br />
<source><br />
d1 $ sound (samples "arpy*8" (run 8)) # speed "0.25"<br />
</source><br />
<br />
We can stop this bleed by using cut and assigning the pattern a cut group of “1”:<br />
<br />
<source><br />
d1 $ sound (samples "arpy*8" (run 8)) # speed "0.25" # cut "1"<br />
</source><br />
<br />
No more bleed!<br />
<br />
You can use any number for the cut group.<br />
<br />
Cut groups are global, to the Tidal process, so if you have two Dirt connections, use two different cut group values to make sure the patterns don’t choke each other:<br />
<br />
<source><br />
d1 $ sound (samples "arpy*8" (run 8)) # speed "0.25" # cut "1"<br />
d2 $ sound (samples "bass2*6" (run 6)) # speed "0.5" # cut "2"<br />
</source><br />
<br />
This also works in a stack:<br />
<br />
<source><br />
d1 $ stack [<br />
sound (samples "arpy*8" (run 8)) # speed "0.25" # cut "1",<br />
sound (samples "bass2*6" (run 6)) # speed "0.5" # cut "2" ]<br />
</source><br />
<br />
=Transitions Between Patterns=<br />
<br />
Changing the pattern on a channel takes effect (almost) immediately. This may not be what you want, especially when performing live!<br />
<br />
That’s why Tidal allows you to choose a transition that will introduce another pattern, eventually replacing the current one.<br />
<br />
For every Dirt channel, there’s a transition channel that accepts a transition function and a new pattern.<br />
<br />
So instead of directly sending the new pattern to d1, we’ll send it to the corresponding transition channel t1 and give it a nice transition function:<br />
<br />
<source><br />
d1 $ sound (samples "hc*8" (iter 4 $ run 4))<br />
</source><br />
<br />
<source><br />
t1 anticipate $ sound (samples "bd(3,8)" (run 3))<br />
</source><br />
<br />
To transition from here, simply change the pattern within t1, and in this case also change the transition function:<br />
<br />
<source><br />
t1 (xfadeIn 16) $ sound "bd(5,8)"<br />
</source><br />
<br />
The above will fade over 16 cycles from the former pattern to the given new one.<br />
<br />
Apart from <code>anticipate</code> and <code>xfadeIn</code> there are a lot more transition functions <br />
e.g. some that will force you to keep changing your patterns to avoid repetitive performances.<br />
<br />
=Samples=<br />
<br />
If you’re using SuperDirt, all the default samples can be found in the Dirt-Samples folder - you can open it by running Quarks.gui in SuperCollider, <br />
clicking on “Dirt-Samples” and then “open folder”. If you’re using classic dirt, look in its samples subfolder. Here’s some you could try:<br />
<br />
<nowiki>flick sid can metal future gabba sn mouth co gretsch mt arp h cp<br />
cr newnotes bass crow hc tabla bass0 hh bass1 bass2 oc bass3 ho<br />
odx diphone2 house off ht tink perc bd industrial pluck trump<br />
printshort jazz voodoo birds3 procshort blip drum jvbass psr<br />
wobble drumtraks koy rave bottle kurt latibro rm sax lighter lt<br />
arpy feel less stab ul</nowiki><br />
<br />
Each one is a folder containing one or more wav files. For example when you put bd:1 in a sequence, you’re picking up the second wav file in the bd folder. If you ask for the ninth sample and there are only seven in the folder, it’ll wrap around and play the second one.<br />
<br />
If you want to add your own samples, just create a new folder in the samples folder, and put wav files in it.<br />
<br />
=Synths=<br />
<br />
For this section to work, you need to have installed the SuperCollider sc3-plugins. You can either install the latest version from git, or if you are using Linux, you may find it in your package manager. On Fedora the package is called supercollider-sc3-plugins.<br />
<br />
SuperDirt is created with SuperCollider, a fantastic synthesis engine and language with huge sonic possibilities. You can trigger custom SuperCollider synths from TidalCycles in much the same way as you trigger samples. For example:<br />
<br />
<source><br />
d1 $ midinote "60 62*2" # s "supersaw"<br />
</source><br />
<br />
The above plays note 60 and 62 of the MIDI scale, using the midinote parameter. You can alternatively specify notes by name, using n:<br />
<br />
<source><br />
d1 $ n "c5 d5*2" # s "supersaw"<br />
</source><br />
<br />
For half tones you add the suffixes “f” or “s” (flat or sharp) to the note in question.<br />
<br />
<source><br />
d1 $ n "<[a5,cs5,e5,g5]*3 [d5,fs5,g5,c5]>" # s "supersquare" # gain "0.7"<br />
</source><br />
<br />
Above is a two chord progression A7 D7. Notice cs5 and fs5 as C#5 and F#5, respectively.<br />
<br />
<source><br />
d2 $ every 4 (rev) $ n "<[g5 df5 e5 a5] [gf5 d5 c5 g5]*3>" # s "supersaw"<br />
</source><br />
<br />
Now the same chords (A7 D7) this time played as ascending and descending arpeggios and cs5 written as df5and fs5 as gf5. Play both examples together for more fun!<br />
<br />
You can also specify note numbers with n, but where 0 is middle c (rather than 60 with midinote).<br />
<br />
<source><br />
d1 $ n "0 5" # s "supersaw"<br />
</source><br />
<br />
The default sustain length is a bit long so the sounds will overlap, you can adjust this using the sustain parameter<br />
<br />
<source><br />
d1 $ n "c5 d5*2" # s "supersaw" # sustain "0.4 0.2"<br />
</source><br />
<br />
Many example synths can be found in the default-synths-extra.scd file in the SuperDirt/library folder or in default-synths.scd and tutorial-synths.scd in the SuperDirt/synths folder. These include:<br />
<br />
* a series of tutorials: tutorial1, tutorial2, tutorial3, tutorial4, tutorial5<br />
* examples of modulating with the cursor or sound input: pmsin, in, inr<br />
* physical modeling synths: supermandolin, supergong, superpiano, superhex<br />
* a basic synth drumkit: superkick, superhat, supersnare, superclap, super808<br />
* four analogue-style synths: supersquare, supersaw, superpwm, supercomparator<br />
* two digital-style synths: superchip, supernoise<br />
<br />
To find the SuperDirt folder, simply run Quarks.folder in supercollider. The full folder location should appear in the postwindow (which is usually in the bottom right).<br />
<br />
Many of the above synths accept additional Tidal Parameters or interpret the usual parameters in a slightly different way. For complete documentation, see default-synths.scd, but here are some examples to try:<br />
<br />
<source><br />
d1 $ jux (# accelerate "-0.1") $ s "supermandolin*8" # midinote "[80!6 78]/8"<br />
# sustain "1 0.25 2 1"<br />
</source><br />
<br />
<source><br />
d1 $ midinote (slow 2 $ (run 8) * 7 + 50) # s "supergong" # decay "[1 0.2]/4"<br />
# voice "[0.5 0]/8" # sustain (slow 16 $ scale 5 0.5 $ saw1)<br />
</source><br />
<br />
<source><br />
d1 $ sound "superhat:0*8" # sustain "0.125!6 1.2" # accelerate "[0.5 -0.5]/4"<br />
</source><br />
<br />
<source><br />
d1 $ s "super808 supersnare" # n (irand 5)<br />
# voice "0.2" # decay "[2 0.5]/4" # accelerate "-0.1" # sustain "0.5" # speed "[0.5 2]/4"<br />
</source><br />
<br />
<source><br />
d1 $ n (slow 8 "[[c5 e5 g5 c6]*4 [b4 e5 g5 b5]*4]") # s "superpiano"<br />
# velocity "[1.20 0.9 0.8 1]"<br />
</source><br />
<br />
<source><br />
d1 $ n (slow 8 $ "[[c4,e4,g4,c5]*4 [e4,g4,b5,e5]*4]" + "<12 7>") # s "superpiano"<br />
# velocity (slow 8 $ scale 0.8 1.1 sine1) # sustain "8"<br />
</source><br />
<br />
<source><br />
d1 $ n "[c2 e3 g4 c5 c4 c3]/3" # s "[superpwm supersaw supersquare]/24" # sustain "0.5"<br />
# voice "0.9" # semitone "7.9" # resonance "0.3" # lfo "3" # pitch1 "0.5" # speed "0.25 1"<br />
</source><br />
<br />
<source><br />
d1 $ every 16 (density 24 . (|+| midinote "24") . (# sustain "0.3") . (# attack "0.05"))<br />
$ s "supercomparator/4" # midinote ((irand 24) + 24)<br />
# sustain "8" # attack "0.5" # hold "4" # release "4"<br />
# voice "0.5" # resonance "0.9" # lfo "1" # speed "30" # pitch1 "4"<br />
</source><br />
<br />
<source><br />
d1 $ n "[c2 e3 g4 c5 c4 c3]*4/3" # s "superchip" # sustain "0.1"<br />
# pitch2 "[1.2 1.5 2 3]" # pitch3 "[1.44 2.25 4 9]"<br />
# voice (slow 4 "0 0.25 0.5 0.75") # slide "[0 0.1]/8" # speed "-4"<br />
</source><br />
<br />
<source><br />
d2 $ every 4 (echo (negate 3/32)) $ n "c5*4" # s "supernoise"<br />
# accelerate "-2" # speed "1" # sustain "0.1 ! ! 1" # voice "0.0"<br />
</source><br />
<br />
<source><br />
d1 $ s "supernoise/8" # midinote ((irand 10) + 30) # sustain "8"<br />
# accelerate "0.5" # voice "0.5" # pitch1 "0.15" # slide "-0.5" # resonance "0.7"<br />
# attack "1" # release "20" # room "0.9" # size "0.9" # orbit "1"<br />
</source><br />
<br />
This is all quite new and under ongoing development, but you can read about modifying and adding your own synths to SuperDirt at its github repository.</div>ZimaPurplehttps://tidalcycles.org/index.php?title=Tutorial&diff=2934Tutorial2018-12-23T16:42:32Z<p>ZimaPurple: Change use of scale to the new function range</p>
<hr />
<div>'''Note: this is in the process of being updated for version 1.0.0.'''<br />
<br />
You’ve installed TidalCycles and (Super)Dirt, maybe even made a few sounds, but now you’re ready to get to business and start really learning. This guide will help you get started with simple patterns and walk you through all the way to complex compositions.<br />
<br />
Why not play with the code as you read, running your own experiments by changing the examples, and seeing where they take you?<br />
<br />
= Creating Rhythmic Sequences =<br />
<br />
==Play a Single Sample==<br />
Tidal provides 16 'connections' to the SuperDirt synthesiser, named from d1 to d16. Here’s a minimal example, that plays a kick drum every cycle:<br />
<br />
<source><br />
d1 $ sound "bd"<br />
</source><br />
<br />
Evaluate the above code in the Atom (or Emacs) editor by pressing Ctrl+Enter. If you want to stop the sound again, look ahead to the section on silence.<br />
<br />
In the code above, <source inline>sound</source> tells us we’re making a pattern of sound samples, and <source inline>"bd"</source> is a pattern that contains a single sound. bd is a sample of a kick drum. Samples live inside the Dirt-Samples folder which came with SuperDirt, and each sub-folder under that corresponds to a sample name (like bd).<br />
<br />
To find the SuperDirt samples on your system, in the SuperCollider IDE select the File > Open User Support Directory menu item. From there, open downloaded-quarks and finally Dirt-Samples in there. You should find a lot of folders, each one is a sample bank containing standard wav files. Feel free to make new folders and add your own sounds to it, see the [[Custom Samples]] userbase page for more info.<br />
<br />
We can pick a different sample in the bd folder by adding a colon (:) then a number. For example, this picks the fourth kick drum (it counts from zero, so :3 gives you the fourth sound in the folder):<br />
<br />
<source><br />
d1 $ sound "bd:3"<br />
</source><br />
<br />
If you specify a number greater than the number of samples in a folder, then Tidal just “wraps” around back to the first sample again (it starts counting at zero, e.g. in a folder with five samples, “bd:5” would play “bd:0”).<br />
<br />
It’s also possible to specify the sample number separately:<br />
<br />
<source><br />
d1 $ sound "bd" # n "3"<br />
</source><br />
<br />
The usefulness of doing this will become apparent later.<br />
<br />
==Sequences From Multiple Samples==<br />
Putting things in quotes allows you to define a sequence. For example, the following gives you a pattern of kick drum then snare:<br />
<br />
<source><br />
d1 $ sound "bd sd:3"<br />
</source><br />
<br />
When you run the code above, you are replacing the previous pattern with another one on-the-fly. Congratulations, you’re live coding.<br />
<br />
==Playing More Than One Sequence==<br />
The easiest way to play multiple sequences at the same time is to use two or more connections to the synthesizer:<br />
<br />
<source><br />
d1 $ sound "bd sd:1"<br />
<br />
d2 $ sound "hh hh hh hh"<br />
<br />
d3 $ sound "arpy"<br />
</source><br />
<br />
NOTE: each connection must be evaluated separately in your text editor. That is, you must press Ctrl+Enter three times, once for each line above. ''Make sure that there is a blank line between them each pattern'', or Tidal will evaluate them together and get confused (if you want to evaluate just one line, you can press shift-enter).<br />
<br />
ANOTHER NOTE: If you prefer to refer to patterns by name, rather than by number, you can do that with <source inline>p</source>, for example:<br />
<br />
<source><br />
p "susan" $ sound "bd sd:1"<br />
<br />
p "gerard" $ sound "hh hh hh hh"<br />
</source><br />
<br />
==What is a Cycle?==<br />
A cycle is the main “loop” of time in Tidal. The cycle repeats forever in the background, even when you’ve stopped samples from playing. The cycle’s duration always stays the same unless you modify it with cps, we’ll cover this later. By default, there is one cycle per second.<br />
<br />
Note that this omniprescent cyclic looping doesn’t necessary constrain you, for example it’s common to stretch a pattern outside of a single loop, and vary patterns from one loop to the next. We’ll see several ways to do this later, as well.<br />
<br />
All of the samples inside of a pattern get squashed into a single cycle. The patterns below all loop over the same amount of time:<br />
<br />
<source><br />
d1 $ sound "bd sd"<br />
<br />
d1 $ sound "bd sd hh cp mt arpy drum"<br />
<br />
d1 $ sound "bd sd hh cp mt arpy drum odx bd arpy bass2 feel future"<br />
</source><br />
<br />
Note how the more steps you add to the pattern, the faster it plays them, in order to fit them all in. No matter how many samples you put in a pattern in this way, they will always be distributed evenly within a single cycle.<br />
<br />
=Silence=<br />
At this point you probably want to know how to stop the patterns you started. An empty pattern is defined as silence, so if you want to ‘switch off’ a pattern, you can just set it to that:<br />
<br />
<source><br />
d1 silence<br />
</source><br />
<br />
If you want to set all the connections (from d1 to d9) to be silent at once, there’s a single-word shortcut for that:<br />
<br />
<source><br />
hush<br />
</source><br />
<br />
You can also isolate a single connection and silence all others with the <source inline>solo</source> function. You can do this like so:<br />
<br />
<source><br />
d1 $ sound "bd"<br />
<br />
d2 $ sound "~ cp"<br />
<br />
-- run this and only the bd plays<br />
solo 1 <br />
<br />
-- unsolo it and the cp plays again<br />
unsolo 1 <br />
</source><br />
<br />
=Patterns Within Patterns=<br />
<br />
You can use Tidal’s square brackets syntax to create a pattern grouping:<br />
<br />
<source><br />
d1 $ sound "[bd sd sd] cp"<br />
</source><br />
<br />
Square brackets allow several events to be played inside of a single step. You can think of the above pattern as having two steps, with the first step broken down into a subpattern, which has three steps. Practically, this means you can create denser sub-divisions of cycles:<br />
<br />
<source><br />
d1 $ sound "bd [sd sd]"<br />
<br />
d1 $ sound "bd [sd sd sd]"<br />
<br />
d1 $ sound "bd [sd sd sd sd]"<br />
<br />
d1 $ sound "[bd bd] [sd sd sd sd]"<br />
<br />
d1 $ sound "[bd bd bd] [sd sd]"<br />
<br />
d1 $ sound "[bd bd bd bd] [sd]"<br />
</source><br />
<br />
You can even nest groups inside groups to create increasingly dense and complex patterns:<br />
<br />
<source><br />
d1 $ sound "[bd bd] [bd [sd [sd sd] sd] sd]"<br />
</source><br />
<br />
A shorthand for this kind of grouping is to place a period . between groups, rather than surrounding them in square brackets. We call this technique ‘marking out feet’. For example these two patterns are equivalent:<br />
<br />
<source><br />
d1 $ sound "bd bd . sd sd sd . bd sd"<br />
<br />
d1 $ sound "[bd bd] [sd sd sd] [bd sd]"<br />
</source><br />
<br />
The former approach is often easier to type, but is a relatively new addition to TidalCycles, and so many examples will use the square brackets.<br />
<br />
==Layering (Polyrhythms) Instead of Grouping==<br />
You can also layer up several loops, by using commas to separate the different parts:<br />
<br />
<source><br />
d1 $ sound "[bd bd bd, sd cp sd cp]"<br />
</source><br />
<br />
This would play the sequence bd bd bd at the same time as sd cp sd cp. Note that the first sequence only has three events, and the second one has four. Because tidal ensures both loops fit inside the same cyclic duration, you end up with a polyrhythm.<br />
<br />
You can layer any number of these subpatterns to create many polyrhythms:<br />
<br />
<source><br />
d1 $ sound "[bd bd bd, sd cp sd cp, arpy arpy, odx]"<br />
</source><br />
<br />
And of course you can use groupings inside of the layers:<br />
<br />
<source><br />
d1 $ sound "[bd bd bd, [sd sd] cp, arpy [arpy [arpy arpy] arpy arpy], odx]"<br />
</source><br />
<br />
==Playing one step per cycle==<br />
To specify a group where only one step is played per cycle, use angle brackets. For example:<br />
<br />
<source><br />
d1 $ sound "bd <arpy:1 arpy:2 arpy:3>"<br />
</source><br />
<br />
The above will result in the sequence <code>bd arpy:1 bd arpy:2 bd arpy:3</code>, over three cycles.<br />
<br />
=Pattern Repetition and Speed=<br />
<br />
==Repetition==<br />
There are two short-hand symbols you can use inside patterns to speed things up or slow things down: * and /. You could think of these like multiplication and division.<br />
<br />
Use the * symbol to make a pattern, or part of a pattern, repeat as many times as you’d like:<br />
<br />
<source><br />
d1 $ sound "bd*2"<br />
</source><br />
<br />
This is the same as doing <code>d1 $ sound "bd bd"</code><br />
<br />
The code above uses *2 to make a sample play twice.<br />
<br />
You can use the / symbol to make a part of a pattern slow down, or occur less often:<br />
<br />
<source><br />
d1 $ sound "bd/2"<br />
</source><br />
<br />
The code above uses /2 to make a sample play half as often, or once every 2nd cycle.<br />
<br />
Using different numbers works as you’d expect:<br />
<br />
<source><br />
d1 $ sound "bd*3" -- plays the bd sample three times each cycle<br />
d1 $ sound "bd/3" -- plays the bd samples only once each third cycle<br />
</source><br />
<br />
==Using * and / on Groups==<br />
You can apply the * and / symbols on groups of patterns:<br />
<br />
<source><br />
d1 $ sound "[bd sn]*2 cp"<br />
<br />
d1 $ sound "[bd sn] cp/2"<br />
<br />
d1 $ sound "[[bd sn] cp]*2" -- speeds up the entire pattern by 2<br />
<br />
d1 $ sound "[[bd sn] cp]/2" -- slows down the entire pattern by 2<br />
</source><br />
<br />
You can also use the symbols on nested groups to create more complex rhythms:<br />
<br />
<source><br />
d1 $ sound "[bd sn sn*3]/2 [bd sn*3 bd*4]/3"<br />
<br />
d1 $ sound "[bd [sn sn]*2]/2 [bd [sn bd]/2]*2"<br />
</source><br />
<br />
=Modifying Sequences With Functions=<br />
<br />
Tidal comes into its own when you start building things up with functions which transform the patterns in various ways.<br />
<br />
For example, <code>rev</code> reverses a pattern:<br />
<br />
<source><br />
d1 $ rev (sound "bd*2 [bd [sn sn*2 sn] sn]")<br />
</source><br />
<br />
That’s not so exciting, but things get more interesting when this is used in combination with another function. For example every takes three parameters: <br />
a number, a function and a pattern to apply the function to. The number specifies how often the function is applied to the pattern. For example, the <br />
following reverses the pattern every fourth repetition:<br />
<br />
<source><br />
d1 $ every 4 (rev) (sound "bd*2 [bd [sn sn*2 sn] sn]")<br />
</source><br />
<br />
It takes a while to get used to how we’re using parenthesis here. In the previous example, rev takes one parameter, a pattern, and we had to ‘wrap up’ the <br />
pattern sound <code>"[bd bd] [bd [sn [sn sn] sn] sn]"</code> in brackets to pass it to rev. In the above example every takes three parameters: a number, <br />
a function and a pattern. We had to wrap up the pattern as before, but also rev in order to give it to every. This should become clearer with practice.<br />
<br />
You can also slow down or speed up the playback of a pattern, this makes it a quarter of the speed:<br />
<br />
<source><br />
d1 $ slow 4 $ sound "bd*2 [bd [sn sn*2 sn] sn]"<br />
</source><br />
<br />
And this four times the speed:<br />
<br />
<source><br />
d1 $ fast 4 $ sound "bd*2 [bd [sn sn*2 sn] sn]"<br />
</source><br />
<br />
Note that slow 0.25 would do exactly the same as fast 4.<br />
<br />
Again, this can be applied selectively:<br />
<br />
<source><br />
d1 $ every 4 (fast 4) $ sound "bd*2 [bd [sn sn*2 sn] sn]"<br />
</source><br />
<br />
Note again the use of parenthesis, around fast 4. This is needed, to group together the function fast with its parameter 4, before being passed as a parameter to the function every.<br />
<br />
In the examples above, the sound function takes a pattern of sample names, and turns it into a pattern of synthesizer triggers. <br />
This might take a while to fully understand, but the important thing to remember is that “it’s patterns all the way down”. <br />
In this case, this means that you can operate on the inner pattern of sample names, instead of the outer pattern of synthesizer triggers that sound gives you:<br />
<br />
<source><br />
d1 $ sound (every 4 (fast 4) "bd*2 [bd [sn sn*2 sn] sn]")<br />
</source><br />
<br />
The fast function is also known as density, which is actually the older name, so a lot of examples will use it instead of the <br />
(slightly quicker to type) fast. They do exactly the same thing.<br />
<br />
==Where are all the functions?==<br />
There are many types of functions that help you change patterns. Some of them re-order sequences, some alter time, some provide conditional logic, and some can help compose more complex patterns.<br />
<br />
We’ll introduce many of the core functions in this introduction, and a more complete list of functions available in Tidal can be found on the [[Category:Functions|functions category]] page.<br />
<br />
=Applying effects with control patterns=<br />
<br />
TidalCycles has a number of effects that you can apply to sounds. Some of them do simple things like change volume, and others do more complex things like add delay or distortion. This is done with what we call ''control patterns''. In fact <source inline>sound</source> itself creates a control pattern, and we apply effects by combining control patterns together.<br />
<br />
You can combine control patterns by adding the # operator between them:<br />
<br />
<source><br />
d1 $ sound "bd*4" # crush "4"<br />
</source><br />
<br />
The above code uses <source inline>crush</source> to create a bitcrushing control pattern with a value of 4 (which sounds really grungy), and uses <source inline>#</source> to join that with the <source inline>sound</source> control pattern.<br />
<br />
You can combine multiple control patterns together, with the # operator:<br />
<br />
<source><br />
d1 $ sound "bd*4" # crush "4" # speed "2"<br />
</source><br />
<br />
The code above both bitcrushes and speeds up sample playback (which increases the ‘pitch’).<br />
<br />
==Control values are patterns too==<br />
You may notice that the values of effects are specified in double quotes. This means that you can pattern the effect values too:<br />
<br />
<source><br />
d1 $ sound "bd*4" # gain "1 0.8 0.5 0.7"<br />
</source><br />
<br />
The above <source inline>gain</source> effect changes how loud the sample is, good for patterns of emphasis as above. Other control patterns follow all the same grouping rules as sound patterns:<br />
<br />
<source><br />
d1 $ sound "bd*4 sn*4" # gain "[[1 0.8]*2 [0.5 0.7]]/2"<br />
</source><br />
<br />
And you can also apply functions to control patterns:<br />
<br />
<source><br />
d1 $ sound "bd*4" # (every 3 (rev) $ gain "1 0.8 0.5 0.7")<br />
</source><br />
<br />
Like with the sound example earlier, you must use parenthesis after gain in order to specify a function on the gain pattern.<br />
<br />
This works too:<br />
<br />
<source><br />
d1 $ sound "bd*4" # gain (every 3 (rev) $ "1 0.8 0.5 0.7")<br />
</source><br />
<br />
In the above example, <source inline>every 3 (rev)</source> is being applied to <source inline>"1 0.8 0.5 0.7"</source>, which is a pattern of numbers. In the example preceding it, the same function was applied to <source inline>gain "1 0.8 0.5 0.7"</source>, which is a pattern of gain controls. In this case, whether you apply the function before or after the numbers are turned into controls doesn't matter too much, the outcome is exactly the same.<br />
<br />
==Control pattern order==<br />
You can specify the effect control ''before'' the sound control:<br />
<br />
<source><br />
d1 $ gain "1 0.8 0.5 0.7" # sound "bd"<br />
</source><br />
<br />
The order that you put things matters; with <source inline>#</source>the structure of the pattern is given by the pattern on the ''left''. In this case, only one bd sound is given, but you hear four, because the structure comes from the gain pattern on the left.<br />
<br />
==Modifying control values==<br />
<br />
The # operator is just a shortcut to a longer form of operator called <source inline>|=</source>. The <source inline>|=</source> operator is part of a family of operators, and means something special about combining patterns, which we’ll cover shortly. All you need to know right now is that <source inline>|=</source> is used to combine patterns.<br />
<br />
You can use <source inline>|=</source> to combine patterns conditionally:<br />
<br />
<source><br />
d1 $ every 2 (|= speed "2") $ sound "arpy*4" |= speed "1"<br />
</source><br />
<br />
There are other types of operators that allow you to perform arithmetic:<br />
<br />
|+<br />
|-<br />
|*<br />
|/<br />
<br />
For example, using <source inline>|+</source> will perform an addition operation and add to an original value:<br />
<br />
<source><br />
d1 $ every 2 (|+ speed "1") $ sound "arpy*4" |= speed "1"<br />
</source><br />
<br />
The code above results in a speed of “2” every other cycle.<br />
<br />
The following will multiply values:<br />
<br />
<source><br />
d1 $ every 2 (|* speed "1.5") $ sound "arpy*4" |= speed "1"<br />
</source><br />
<br />
More complex patterns and chaining can be done, and with any effect, of course:<br />
<br />
<source><br />
d1 $ every 3 (|- note "3") $ every 2 (|+ up "5") $ sound "arpy*4" |= note "0 2 4 5"<br />
</source><br />
<br />
It might be worth sticking to just these ways of combining control patterns for now, but if you are curious, you can look into the [[Combining pattern structure|others that are available]].<br />
<br />
==Some Common Effects==<br />
Here is a quick list of some effects you can use in Tidal (the full list is available in the Reference section):<br />
<br />
* gain - changes volume, values from 0 to 1<br />
* pan - pans sound right and left, values from 0 to 1<br />
* shape - a type of amplifier, values from 0 to 1<br />
* vowel - a vowel formant filter, values include a, e, i, o, and u<br />
* speed - changes playback speed of a sample, see below<br />
<br />
=Shorthand for numerical patterns=<br />
<br />
From version 0.9 of Tidal, there are some nice ways of saving on keypresses when working with numerical patterns.<br />
<br />
For example, when specifying patterns of single numbers, such as:<br />
<br />
<source><br />
d1 $ sound "arpy(3,8)" # n "2"<br />
</source><br />
<br />
you can miss off the double quotes, so this works fine:<br />
<br />
<source><br />
d1 $ sound "arpy(3,8)" # n 2<br />
</source><br />
<br />
However, if you wanted more than one value in that n pattern, you’d have to put the quotes in:<br />
<br />
<source><br />
d1 $ sound "arpy(3,8)" # n "2 5"<br />
</source><br />
<br />
You can also treat patterns of numbers as simple numbers in other ways. For example doing algebra:<br />
<br />
<source><br />
d1 $ sound "arpy(3,8)" # n ("0 2" * 2)<br />
<br />
d1 $ sound "arpy(3,8)" # n (every 4 (* 2) "0 2")<br />
<br />
d1 $ n (off 0.125 (+12) $ off 0.25 (+7) $ slow 2 $ "0(3,8) [5 7]") # sound "supergong"<br />
</source><br />
<br />
This is still quite new to everyone, so you will not see it used much in the documentation yet.<br />
<br />
You can also now specify increasing or decreasing numbers with a range, for example this:<br />
<br />
d1 $ n "[0..7] [3..1]" # sound "supergong"<br />
<br />
... is shorthand for:<br />
<br />
<source><br />
d1 $ n "[0 1 2 3 4 5 6 7] [3 2 1]" # sound "supergong"<br />
</source><br />
<br />
=Sample Playback Speed (and Pitch)=<br />
<br />
You can change the playback speed of a sample in TidalCycles by using the speed effect. You can use speed to change pitches, to create a weird effect, or to match the length of a sample to a specific period of the cycle time (but see the loopAt function for an easy way of doing the latter).<br />
<br />
You can set a sample’s speed by using the speed effect with a number.<br />
<br />
* speed "1" plays a sample at its original speed<br />
* speed "0.5" plays a sample at half of its original speed<br />
* speed "2" plays a sample at double its original speed<br />
<br />
<source>d1 $ sound "arpy" # speed "1"<br />
<br />
d1 $ sound "arpy" # speed "0.5"<br />
<br />
d1 $ sound "arpy" # speed "2"</source><br />
<br />
Just like other effects, you can specify a pattern for speed:<br />
<br />
d1 $ speed "1 0.5 2 1.5" # sound "arpy" <br />
<br />
You can also reverse a sample by specifying negative values:<br />
<br />
<source><br />
d1 $ speed "-1 -0.5 -2 -1.5" # sound "arpy"<br />
</source><br />
<br />
==Play a sample at multiple speeds simultaneously==<br />
Use the pattern grouping syntax with a comma to cause speed to play a sample back at multiple speeds at the same time:<br />
<br />
<source><br />
d1 $ sound "arpy" # speed "[1, 1.5]"<br />
d1 $ speed "[1 0.5, 1.5 2 3 4]" # sound "arpy"<br />
</source><br />
<br />
==12-tone scale speeds==<br />
You can also use the up function to change playback speed. up is a shortcut effect that matches speeds to half steps on a 12-tone scale. For example, the following plays a chromatic scale:<br />
<br />
<source><br />
d1 $ up "0 1 2 3 4 5 6 7 8 9 10 11" # sound "arpy"<br />
</source><br />
<br />
You can also use the run function to create an incrementing pattern of integers: <br />
<br />
<source><br />
d1 $ up (run 12) # sound "arpy". <br />
</source><br />
<br />
The <code>run</code> function will be discussed later.<br />
<br />
=Euclidean Sequences=<br />
If you give two numbers in parenthesis after an element in a pattern, then Tidal will distribute the first number of sounds equally across the second number of steps:<br />
<br />
<source><br />
d1 $ sound "bd(5,8)"<br />
</source><br />
<br />
You can also use the [[euclid]] function to do this. [[euclid]] takes the same two arguments as what is used in the parenthesis above:<br />
<br />
<source><br />
d1 $ euclid 5 8 $ sound "bd"<br />
</source><br />
<br />
You can use the parenthesis notation within a single element of a pattern:<br />
<br />
<source><br />
d1 $ sound "bd(3,8) sn*2"<br />
</source><br />
<br />
<source><br />
d1 $ sound "bd(3,8) sn(5,8)"<br />
</source><br />
<br />
You can also add a third parameter, which ‘rotates’ the pattern so it starts on a different step:<br />
<br />
<source><br />
d1 $ sound "bd(5,8,2)"<br />
</source><br />
<br />
You can also use the euclid function to apply a Euclidean algorithm over a complex pattern, although the structure of that pattern will be lost:<br />
<br />
<source><br />
d1 $ euclid 3 8 $ sound "bd*2 [sn cp]"<br />
</source><br />
<br />
In the above, three sounds are picked from the pattern on the right according to the structure given by the euclid 3 8. It ends up picking two bd sounds, a cp and missing the sn entirely.<br />
<br />
As a bonus, it is possible to pattern the parameters within the parenthesis, for example to alternate between 3 and 5 elements:<br />
<br />
<source><br />
d1 $ sound "bd([5 3]/2,8)"<br />
</source><br />
<br />
These types of sequences use “Bjorklund’s algorithm”, which wasn’t made for music but for an application in nuclear physics, which is exciting. More exciting still is that it is very similar in structure to the one of the first known algorithms written in Euclid’s book of elements in 300 BC. You can read more about this in the paper The Euclidean Algorithm Generates Traditional Musical Rhythms by Toussaint. Some examples from this paper are included below, including rotation in some cases.<br />
<br />
* (2,5) : A thirteenth century Persian rhythm called Khafif-e-ramal.<br />
* (3,4) : The archetypal pattern of the Cumbia from Colombia, as well as a Calypso rhythm from Trinidad.<br />
* (3,5,2) : Another thirteenth century Persian rhythm by the name of Khafif-e-ramal, as well as a Rumanian folk-dance rhythm.<br />
* (3,7) : A Ruchenitza rhythm used in a Bulgarian folk-dance.<br />
* (3,8) : The Cuban tresillo pattern.<br />
* (4,7) : Another Ruchenitza Bulgarian folk-dance rhythm.<br />
* (4,9) : The Aksak rhythm of Turkey.<br />
* (4,11) : The metric pattern used by Frank Zappa in his piece titled Outside Now.<br />
* (5,6) : Yields the York-Samai pattern, a popular Arab rhythm.<br />
* (5,7) : The Nawakhat pattern, another popular Arab rhythm.<br />
* (5,8) : The Cuban cinquillo pattern.<br />
* (5,9) : A popular Arab rhythm called Agsag-Samai.<br />
* (5,11) : The metric pattern used by Moussorgsky in Pictures at an Exhibition.<br />
* (5,12) : The Venda clapping pattern of a South African children’s song.<br />
* (5,16) : The Bossa-Nova rhythm necklace of Brazil.<br />
* (7,8) : A typical rhythm played on the Bendir (frame drum).<br />
* (7,12) : A common West African bell pattern.<br />
* (7,16,14) : A Samba rhythm necklace from Brazil.<br />
* (9,16) : A rhythm necklace used in the Central African Republic.<br />
* (11,24,14) : A rhythm necklace of the Aka Pygmies of Central Africa.<br />
* (13,24,5) : Another rhythm necklace of the Aka Pygmies of the upper Sangha.<br />
<br />
=Tempo=<br />
<br />
If you’ve made it this far without changing the tempo in all these examples, then you’re probably ready to change it up.<br />
<br />
Tidal’s core unit of time is cycles per second. It can be set with the <source inline>setcps</source> function:<br />
<br />
<source><br />
setcps 1<br />
</source><br />
<br />
You can execute setcps just like a pattern (using Shift+Enter in your editor).<br />
<br />
<source inline>setcps</source> accepts a positive numeric value that can include a decimal:<br />
<br />
<source><br />
setcps 1.5<br />
setcps 0.75<br />
setcps 10<br />
</source><br />
<br />
Tidal’s timing is based on cycles, rather than beats, however it is more common for people to think in terms of beats per minute (BPM). If you prefer to think in this way, you have to decide how many beats you want to have per cycle, and divide accordingly. For example if you wanted to play at 140 bpm, with four beats per cycle, then you could do:<br />
<br />
<source><br />
setcps (140/60/4)<br />
</source><br />
<br />
You can also pattern the tempo with the <source inline>cps</source> control function, for example:<br />
<br />
<source><br />
d1 $ sound "cp(3,8)"<br />
# cps (slow 8 $ range 0.8 1.6 saw)<br />
</source><br />
<br />
=The Run Function=<br />
<br />
There is a special utility function called run which will return a pattern of integers up to a specified maximum. You can use run with effects to aid in automatically generating a linear pattern:<br />
<br />
<source><br />
d1 $ sound "arpy*8" # up (run 8)<br />
d1 $ sound "arpy*8" # speed (run 8)<br />
</source><br />
<br />
In the above we’re specifying the number of sounds twice - in the sound pattern as well as the up or speed pattern. There’s actually a neat way of only having to specify this once, simply by switching them round, so the effect parameter is on the left:<br />
<br />
<source><br />
d1 $ up (run 8) # sound "arpy"<br />
</source><br />
<br />
This works because TidalCycles always takes the structure of a pattern from the parameter that’s on the left. We usually want the structure to come from the sound parameter, but not always.<br />
<br />
Because run returns a pattern, you can apply functions to its result:<br />
<br />
<source><br />
d1 $ sound "arpy*8" # up (every 2 (rev) $ run 8)<br />
</source><br />
<br />
For a more practical example of using run, read below about selecting samples from folders.<br />
<br />
=(Algorithmically) Selecting Samples=<br />
<br />
The sound parameter we’ve been using up to now can actually be broken into two separate parameters, making it easy to select samples with a pattern. These parameters are s that gives the name of the sample set, and n which gives the number of the sample within that set. For example, the following two patterns do exactly the same:<br />
<br />
<source><br />
d1 $ sound "arpy:0 arpy:2 arpy:3"<br />
d1 $ n "0 2 3" # s "arpy"<br />
</source><br />
<br />
It’s possible to break the sound parameter into two different patterns, namely s that gives the name of the sample set, and n which gives the index of the sample within that set. For example, the following two patterns are the same:<br />
<br />
<source><br />
d1 $ sound "arpy:0 arpy:2 arpy:3"<br />
d1 $ n "0 2 3" # s "arpy"<br />
</source><br />
<br />
This allows us to separate the sample folder name from the index inside the folder, possibly with surprising results!<br />
<br />
There is also special function called samples that lets you do the same using the sound parameter.<br />
<br />
<source><br />
d1 $ sound $ samples "drum*4" "0 1 2 3"<br />
</source><br />
<br />
the code above is the same as this:<br />
<br />
<source><br />
d1 $ sound "drum:0 drum:1 drum:2 drum:3"<br />
</source><br />
<br />
Whether you use n and s together, or sound with samples is up to you, although you might find the former to be more flexible.<br />
<br />
Remember the run function? Since run generates a pattern of integers, it can be used with n to automatically “run” through the sample indices of a folder:<br />
<br />
<source><br />
d1 $ n (run 4) # s "drum"<br />
d1 $ sound $ samples "drum*4" (run 4) -- or with samples<br />
</source><br />
<br />
And of course you can specify a different pattern of sample names:<br />
<br />
<source><br />
d1 $ s "drum arpy cp hh" # n (run 10)<br />
</source><br />
<br />
Again, by swapping the order of the s and n parameters, you can hear the difference between taking the structure from one or the other:<br />
<br />
<source><br />
d1 $ n (run 10) # s "drum arpy cp hh"<br />
</source><br />
<br />
NOTE: if you specify a run value that is greater than the number of samples in a folder, then the higher number index will “wrap” to the beginning of the samples in the folder (just like with the colon notation).<br />
<br />
You might sometimes see the samples function wrapped in parenthesis:<br />
<br />
<source><br />
d1 $ sound (samples "drum arpy cp hh" (run 10))<br />
</source><br />
<br />
=Combining Types of Patterns=<br />
<br />
Ok, remember when we started adding effects:<br />
<br />
<source><br />
d1 $ sound "bd sn drum arpy" # pan "0 1 0.25 0.75"<br />
</source><br />
<br />
What we’re actually doing in the code above is combining two patterns together: the sound pattern, and the pan pattern. The special pipe operators (|=, |+, |-, |*, |/, |>, and so on), allow us to combine two patterns. Remember that # is shorthand for |>.<br />
<br />
We can actually swap sides and it sounds the same:<br />
<br />
<source><br />
d1 $ pan "0 1 0.25 0.75" # sound "bd sn drum arpy"<br />
</source><br />
<br />
As we touched on earlier, the main thing to know when combining patterns like this is that the left-most pattern determines the rhythmic structure of the result. Removing one of the elements from the pan pattern on the left results in a cycle with three samples played:<br />
<br />
<source><br />
d1 $ pan "0 1 0.25" # sound "bd sn drum arpy"<br />
</source><br />
<br />
In the code above, the pan pattern determines the rhythm because it is the left-most pattern. The sound pattern now only determines what samples are played at what time. The sound pattern gets mapped onto the pan pattern.<br />
<br />
You might be wondering how TidalCycles decides which sound values get matched with which pan values in the above. (If not, there is no need to read the rest of this paragraph just now!) The rule is, for each value in the pattern on the left, values from the right are matched where the start (or onset) of the left value, fall within the timespan of the value on the right. For example, the second pan value of 1 starts one third into its pattern, and the second sound value of sn starts one quarter into its pattern, and ends at the halfway point. Because the former onset (one third) falls inside the timespan of the latter timespan (from one quarter until one half), they are matched. The timespan of arpy doesn’t contain any onsets from the pan pattern, and so it doesn’t match with anything, and isn’t played.<br />
<br />
The rule described above may seem like a lot to keep in mind while composing patterns, but in practice there is no need. Our advice is to not worry, write some patterns and get a feel for how they fit together.<br />
<br />
Anyway, this composition of pattern parameters allows us to do some unique things:<br />
<br />
<source><br />
d1 $ up "0 0*2 0*4 1" # sound "[arpy, bass2, bd]"<br />
</source><br />
<br />
Above, the sound pattern is merely specifying three samples to play on every note. Both the rhythm and pitch of these notes is defined by the up pattern.<br />
<br />
It's also possible to switch things around so that structure comes from the right, by using the operators >|, *|, +|, /| and -|, instead of |>, |*, |+ and |-, for example:<br />
<br />
<source><br />
d1 $ sound "drum" >| n "0 1*2 ~ 3"<br />
</source><br />
<br />
The side of the operator that the | is on, is where the structure comes from. In fact, if you put the bar on both sides, structure comes from both sides:<br />
<br />
<source><br />
d1 $ sound "drum cp" >| n "0 1 2"<br />
</source><br />
<br />
=Oscillation with Continuous Patterns=<br />
<br />
So far we’ve only been working with discrete patterns, by which we mean patterns which containing events which begin and end. Tidal also supports continuous patterns which instead vary continually over time. You can create continuous patterns using functions which give sine, saw, triangle, and square waves:<br />
<br />
<source><br />
d1 $ sound "bd*16" # pan sine<br />
</source><br />
<br />
The code above uses the sine pattern to specify a sine wave oscillation of values between 0 and 1 for the pan values, so the bass drum moves smoothly between the left and right speakers.<br />
<br />
Tidal used to have sine and sine1 patterns with different ranges, but now they are aliases, with both giving a range from 0 to 1.<br />
<br />
In addition to the sine pattern, Tidal also has saw, tri, and square, for sawtooth, triangle and square waves respectively.<br />
<br />
Just like discrete patterns, you can control the speed of continuous patterns with slow or density:<br />
<br />
<source><br />
d1 $ sound "bd*16" # pan (slow 8 $ saw)<br />
d1 $ sound "bd*8 sn*8" # pan (density 1.75 $ tri)<br />
d1 $ sound "bd*8 sn*8" # speed (density 2 $ tri)<br />
</source><br />
<br />
You can also combine them in different ways:<br />
<br />
<source><br />
d1 $ sound "bd*16" # pan (slowcat [sine, saw, square, tri])<br />
d1 $ sound "sn:2*16" # speed ((range 0.5 3 sine) * (slow 4 saw))<br />
</source><br />
<br />
==Scaling Oscillation==<br />
You can tell the oscillation functions to scale themselves and oscillate between two values using range:<br />
<br />
A recent change in tidal repurposed the old scale function to range, to free scale to be used for other purposes.<br />
<br />
<source><br />
d1 $ sound "bd*8 sn*8" # speed (range 1 3 $ tri)<br />
d1 $ sound "bd*8 sn*8" # speed (slow 4 $ range 1 3 $ tri)<br />
</source><br />
<br />
You can also scale to negative values, but make sure to wrap negative values in parens (otherwise the interpreter thinks you’re trying to subtract 2 from something):<br />
<br />
<source><br />
d1 $ sound "bd*8 sn*8" # speed (range (-2) 3 $ tri)<br />
</source><br />
<br />
This technique works well for a slow low-pass filter cutoff:<br />
<br />
<source><br />
d1 $ sound "hh*32" # cutoff (range 300 1000 $ slow 4 $ sine) # resonance "0.4"<br />
</source><br />
<br />
'''NOTE''': Despite the fact that these oscillator patterns produce continuous values, you still need to combine them with discrete sound patterns.<br />
<br />
=Rests=<br />
<br />
So far we have produced patterns that keep producing more and more sound. What if you want a rest, or gap of silence, in your pattern? You can use the “tilde” ~ character to do so:<br />
<br />
<source><br />
d1 $ sound "bd bd ~ bd"<br />
</source><br />
<br />
Think of the <code>~</code> as an ‘empty’ step in a sequence, that just produces silence.<br />
<br />
=Polymeters=<br />
<br />
We talked about polyrhythms earlier, but Tidal can also produce polymeter sequences. A polymeter pattern is one where two patterns have different sequence lengths, but share the same pulse or tempo.<br />
<br />
You use curly brace syntax to create a polymeter rhythm:<br />
<br />
<source><br />
d1 $ sound "{bd hh sn cp, arpy bass2 drum notes can}"<br />
</source><br />
<br />
The code above results in a five-note rhythm being played at the pulse of a four-note rhythm. If you switch the groups around, it results in a four-note rhythm over a five-note rhythm:<br />
<br />
<source><br />
d1 $ sound "{arpy bass2 drum notes can, bd hh sn cp}"<br />
</source><br />
<br />
Sometimes you might want to create an odd polymeter rhythm without having to explicitly create a base rhythm. You could do this with rests:<br />
<br />
<source><br />
d1 $ sound "{~ ~ ~ ~, arpy bass2 drum notes can}"<br />
</source><br />
<br />
But a more efficient way is to use the % symbol after the closing curly brace to specify the number of notes in the base pulse:<br />
<br />
<source><br />
d1 $ sound "{arpy bass2 drum notes can}%4"<br />
</source><br />
<br />
the above is the same as this:<br />
<br />
<source><br />
d1 $ sound "{~ ~ ~ ~, arpy bass2 drum notes can}"<br />
</source><br />
<br />
If “polymeter” sounds a bit confusing, there’s a good explanation here: http://music.stackexchange.com/questions/10488/polymeter-vs-polyrhythm<br />
<br />
=Shifting Time=<br />
<br />
You can use the <code>~></code> and <code><-</code> functions to shift patterns forwards or backwards in time, respectively. With each of these functions, you can specify an amount, in cycle units.<br />
<br />
<source><br />
d1 $ (0.25 <~) $ sound "bd*2 cp*2 hh sn"<br />
d1 $ (0.25 ~>) $ sound "bd*2 cp*2 hh sn"<br />
</source><br />
<br />
The above code shifts the patterns over by one quarter of a cycle.<br />
<br />
You can hear this shifting effect best when applying it conditionally. For example, the below shifts the pattern every third cycle:<br />
<br />
<source><br />
d1 $ every 3 (0.25 <~) $ sound "bd*2 cp*2 hh sn"<br />
d1 $ every 3 (0.25 ~>) $ sound "bd*2 cp*2 hh sn"<br />
</source><br />
<br />
You can shift patterns as little or as much as you’d like:<br />
<br />
<source><br />
d1 $ every 3 (0.0625 <~) $ sound "bd*2 cp*2 hh sn"<br />
d1 $ every 3 (1000 ~>) $ sound "bd*2 cp*2 hh sn"<br />
d1 $ every 3 (1000.125 ~>) $ sound "bd*2 cp*2 hh sn"<br />
</source><br />
<br />
However, in the above case every cycle is the same, so you won’t here a difference between shifting it 1 or 1000 cycles.<br />
<br />
You can also specify a pattern for the shift amount:<br />
<br />
<source><br />
d1 $ "[0 0.25]/4" <~ (sound "bd*2 cp*2 hh sn")<br />
</source><br />
<br />
=Introducing Randomness=<br />
<br />
Tidal can produce random patterns of integers and decimals. It can also introduce randomness into patterns by removing random events.<br />
<br />
==Random Decimal Patterns==<br />
You can use the rand function to create a random value between 0 and 1. This is useful for effects:<br />
<br />
<source><br />
d1 $ sound "arpy*4" # pan (rand)<br />
</source><br />
<br />
As with run and all numeric patterns, the values that rand give you can be scaled, for example the below gives random numbers between 0.25 and 0.75:<br />
<br />
<source><br />
d1 $ sound "arpy*4" # pan (range 0.25 0.75 $ rand)<br />
</source><br />
<br />
==Random Integer Patterns==<br />
Use the irand function to create a random integer up to a given maximum. The most common usage of irand is to produce a random pattern of sample indices (similar to run):<br />
<br />
<source><br />
d1 $ s "arpy*8" # n (irand 30)<br />
</source><br />
<br />
The code above randomly chooses from 30 samples in the “arpy” folder.<br />
<br />
Hairy detail: rand and irand are actually continuous patterns, which in practical terms means they have infinite detail - you can treat them as pure information! As with all patterns they are also deterministic, stateless functions of time, so that if you retriggered a pattern from the same logical time point, exactly the same numbers would be produced. Furthermore, if you use a rand or irand in two different places, you would get the same ‘random’ pattern - if this isn’t what you want, you can simply shift or slow down time a little for one of them, e.g. slow 0.3 rand.<br />
<br />
==Removing or “Degrading” Pattern events==<br />
Tidal has a few ways to randomly remove events from patterns. You can use the shorthand ? symbol if you want to give an event a 50/50 chance of happening or not on every cycle:<br />
<br />
<source><br />
d1 $ sound "bd? sd? sd? sd?"<br />
</source><br />
<br />
In the code above, each bd and sd sample has a 50% chance of being played on every cycle.<br />
<br />
You can add the ? after the completion of any event or group in a pattern:<br />
<br />
<source><br />
d1 $ sound "bd*16?"<br />
d1 $ sound "bd sn? cp hh?"<br />
d1 $ sound "[bd sn cp hh]?"<br />
</source><br />
<br />
The <code>?</code> symbol is shorthand for the degrade function. The two lines below are equivalent:<br />
<br />
<source><br />
d1 $ sound "bd*16?"<br />
d1 $ degrade $ sound "bd*16"<br />
</source><br />
<br />
Related to degrade is the degradeBy function, where you can specify the probability (from 0 to 1) that events will be removed from a pattern:<br />
<br />
<source><br />
d1 $ degradeBy 0.25 $ sound "bd*16"<br />
</source><br />
<br />
There is also sometimesBy, which executes a function based on a probability:<br />
<br />
<source><br />
d1 $ sometimesBy 0.75 (# crush 4) $ sound "bd arpy sn ~"<br />
</source><br />
<br />
The code above has a 75% chance of applying the bitcrush effect pattern # crush 4 on every event in the sound pattern.<br />
<br />
There are other aliases for sometimesBy:<br />
<br />
<source><br />
sometimes = sometimesBy 0.5<br />
often = sometimesBy 0.75<br />
rarely = sometimesBy 0.25<br />
almostNever = sometimesBy 0.1<br />
almostAlways = sometimesBy 0.9<br />
</source><br />
<br />
e.g.:<br />
<br />
<source><br />
d1 $ rarely (# crush 4) $ sound "bd*8"<br />
</source><br />
<br />
=Creating Variation in Patterns=<br />
<br />
You can create a lot of cyclic variations in patterns by layering conditional logic:<br />
<br />
<source><br />
d1 $ every 5 (|+| speed "0.5") $ every 4 (0.25 <~) $ every 3 (rev) $<br />
sound "bd sn arpy*2 cp"<br />
# speed "[1 1.25 0.75 -1.5]/3"<br />
</source><br />
<br />
In addition to every you can also use the whenmod conditional function. whenmod takes two parameters; it executes a function when the remainder of the current loop number divided by the first parameter is greater or equal than the second parameter.<br />
<br />
For example, the following will play a pattern normally for cycles 1-6, then play it in reverse for cycles 7-8. Then normally again for six cycles, then in reverse for two, and so on:<br />
<br />
<source><br />
d1 $ whenmod 8 6 (rev) $ sound "bd*2 arpy*2 cp hh*4"<br />
</source><br />
<br />
=Creating "Fills" and using "const"=<br />
<br />
You can think of a “fill” as a change to a regular pattern that happens regularly. e.g. every 4 cycles do “xya”, or every 8 cycles do “abc”.<br />
<br />
We’ve already been using every and whenmod to do pattern function fills:<br />
<br />
<source><br />
d1 $ every 8 (rev) $ every 4 (density 2) $ sound "bd hh sn cp"<br />
d1 $ whenmod 16 14 (# speed "2") $ sound "bd arpy*2 cp bass2"<br />
</source><br />
<br />
However, what if you wanted to conditionally replace the pattern with a new one? You can use the const function to completely replace a playing pattern.<br />
<br />
Let’s start with a trivial example where we use const to replace an entire pattern all the time:<br />
<br />
<source><br />
d1 $ const (sound "arpy*3") $ sound "bd sn cp hh"<br />
</source><br />
<br />
In the code above, we’ve completely replaced the “bd sn cp hh” pattern with an “arpy” pattern. const specifies the new pattern.<br />
<br />
We can conditionally apply const using every or whenmod:<br />
<br />
<source><br />
d1 $ whenmod 8 6 (const $ sound "arpy(3,8) bd*4") $ sound "bd sn bass2 sn"<br />
d1 $ every 12 (const $ sound "bd*4 sn*2") $ sound "bd sn bass2 sn"<br />
</source><br />
<br />
=Composing Multi-Part Patterns=<br />
<br />
There are a few ways that you can compose new patterns from multiple other patterns. You can concatenate or “append” patterns in serial, or you can “stack” them and play them together in parallel.<br />
<br />
==Concatenating patterns in serial==<br />
You can use the <code>fastcat</code> function to add patterns one after another:<br />
<br />
<source><br />
d1 $ fastcat [sound "bd sn:2" # vowel "[a o]/2",<br />
sound "casio casio:1 casio:2*2"<br />
]<br />
</source><br />
<br />
The <code>fastcat</code> function squeezes all the patterns into the space of one. The more patterns you add to the list, the faster each pattern will be played so that all patterns can fit into a single cycle.<br />
<br />
<source><br />
d1 $ fastcat [sound "bd sn:2" # vowel "[a o]/2",<br />
sound "casio casio:1 casio:2*2",<br />
sound "drum drum:2 drum:3 drum:4*2"<br />
]<br />
</source><br />
<br />
<code>cat</code> (also known as <code>slowcat</code>), will maintain the original playback speed of the patterns:<br />
<br />
<source><br />
d1 $ cat [sound "bd sn:2" # vowel "[a o]/2",<br />
sound "casio casio:1 casio:2*2",<br />
sound "drum drum:2 drum:3 drum:4*2"<br />
]<br />
</source><br />
<br />
<code>cat</code> is a great way to create a linear sequence of patterns (a sequence of sequences), giving a larger form to multiple patterns.<br />
<br />
There’s also <code>randcat</code>, which will play a random pattern from the list.<br />
<br />
==Playing patterns together in parallel==<br />
<br />
The <code>stack</code> function takes a list of patterns and combines them into a new pattern by playing all of the patterns in the list simultaneously.<br />
<br />
<source><br />
d1 $ stack [<br />
sound "bd bd*2",<br />
sound "hh*2 [sn cp] cp future*4",<br />
sound (samples "arpy*8" (run 16))<br />
]<br />
</source><br />
<br />
This is useful if you want to apply functions or effects on the entire stack:<br />
<br />
<source><br />
d1 $ every 4 (slow 2) $ whenmod 5 3 (# speed "0.75 1.5") $ stack [<br />
sound "bd bd*2",<br />
sound "hh*2 [sn cp] cp future*4",<br />
sound (samples "arpy*8" (run 16))<br />
] # speed "[[1 0.8], [1.5 2]*2]/3"<br />
</source><br />
<br />
=Truncating samples with "cut"=<br />
<br />
So far, all of our examples have used short samples. However, maybe you’ve experimented with some long samples. Maybe you’ve noticed that really long samples can cause a lot of bleed and unwanted sound.<br />
<br />
With Tidal’s cut effect, you can “choke” a sound and stop it from playing when a new sample is triggered.<br />
<br />
Consider the following example where we have a pattern of “arpy” sounds, played at a low speed, so there is a lot of bleed into each sample:<br />
<br />
<source><br />
d1 $ sound (samples "arpy*8" (run 8)) # speed "0.25"<br />
</source><br />
<br />
We can stop this bleed by using cut and assigning the pattern a cut group of “1”:<br />
<br />
<source><br />
d1 $ sound (samples "arpy*8" (run 8)) # speed "0.25" # cut "1"<br />
</source><br />
<br />
No more bleed!<br />
<br />
You can use any number for the cut group.<br />
<br />
Cut groups are global, to the Tidal process, so if you have two Dirt connections, use two different cut group values to make sure the patterns don’t choke each other:<br />
<br />
<source><br />
d1 $ sound (samples "arpy*8" (run 8)) # speed "0.25" # cut "1"<br />
d2 $ sound (samples "bass2*6" (run 6)) # speed "0.5" # cut "2"<br />
</source><br />
<br />
This also works in a stack:<br />
<br />
<source><br />
d1 $ stack [<br />
sound (samples "arpy*8" (run 8)) # speed "0.25" # cut "1",<br />
sound (samples "bass2*6" (run 6)) # speed "0.5" # cut "2" ]<br />
</source><br />
<br />
=Transitions Between Patterns=<br />
<br />
Changing the pattern on a channel takes effect (almost) immediately. This may not be what you want, especially when performing live!<br />
<br />
That’s why Tidal allows you to choose a transition that will introduce another pattern, eventually replacing the current one.<br />
<br />
For every Dirt channel, there’s a transition channel that accepts a transition function and a new pattern.<br />
<br />
So instead of directly sending the new pattern to d1, we’ll send it to the corresponding transition channel t1 and give it a nice transition function:<br />
<br />
<source><br />
d1 $ sound (samples "hc*8" (iter 4 $ run 4))<br />
</source><br />
<br />
<source><br />
t1 anticipate $ sound (samples "bd(3,8)" (run 3))<br />
</source><br />
<br />
To transition from here, simply change the pattern within t1, and in this case also change the transition function:<br />
<br />
<source><br />
t1 (xfadeIn 16) $ sound "bd(5,8)"<br />
</source><br />
<br />
The above will fade over 16 cycles from the former pattern to the given new one.<br />
<br />
Apart from <code>anticipate</code> and <code>xfadeIn</code> there are a lot more transition functions <br />
e.g. some that will force you to keep changing your patterns to avoid repetitive performances.<br />
<br />
=Samples=<br />
<br />
If you’re using SuperDirt, all the default samples can be found in the Dirt-Samples folder - you can open it by running Quarks.gui in SuperCollider, <br />
clicking on “Dirt-Samples” and then “open folder”. If you’re using classic dirt, look in its samples subfolder. Here’s some you could try:<br />
<br />
<nowiki>flick sid can metal future gabba sn mouth co gretsch mt arp h cp<br />
cr newnotes bass crow hc tabla bass0 hh bass1 bass2 oc bass3 ho<br />
odx diphone2 house off ht tink perc bd industrial pluck trump<br />
printshort jazz voodoo birds3 procshort blip drum jvbass psr<br />
wobble drumtraks koy rave bottle kurt latibro rm sax lighter lt<br />
arpy feel less stab ul</nowiki><br />
<br />
Each one is a folder containing one or more wav files. For example when you put bd:1 in a sequence, you’re picking up the second wav file in the bd folder. If you ask for the ninth sample and there are only seven in the folder, it’ll wrap around and play the second one.<br />
<br />
If you want to add your own samples, just create a new folder in the samples folder, and put wav files in it.<br />
<br />
=Synths=<br />
<br />
For this section to work, you need to have installed the SuperCollider sc3-plugins. You can either install the latest version from git, or if you are using Linux, you may find it in your package manager. On Fedora the package is called supercollider-sc3-plugins.<br />
<br />
SuperDirt is created with SuperCollider, a fantastic synthesis engine and language with huge sonic possibilities. You can trigger custom SuperCollider synths from TidalCycles in much the same way as you trigger samples. For example:<br />
<br />
<source><br />
d1 $ midinote "60 62*2" # s "supersaw"<br />
</source><br />
<br />
The above plays note 60 and 62 of the MIDI scale, using the midinote parameter. You can alternatively specify notes by name, using n:<br />
<br />
<source><br />
d1 $ n "c5 d5*2" # s "supersaw"<br />
</source><br />
<br />
For half tones you add the suffixes “f” or “s” (flat or sharp) to the note in question.<br />
<br />
<source><br />
d1 $ n "<[a5,cs5,e5,g5]*3 [d5,fs5,g5,c5]>" # s "supersquare" # gain "0.7"<br />
</source><br />
<br />
Above is a two chord progression A7 D7. Notice cs5 and fs5 as C#5 and F#5, respectively.<br />
<br />
<source><br />
d2 $ every 4 (rev) $ n "<[g5 df5 e5 a5] [gf5 d5 c5 g5]*3>" # s "supersaw"<br />
</source><br />
<br />
Now the same chords (A7 D7) this time played as ascending and descending arpeggios and cs5 written as df5and fs5 as gf5. Play both examples together for more fun!<br />
<br />
You can also specify note numbers with n, but where 0 is middle c (rather than 60 with midinote).<br />
<br />
<source><br />
d1 $ n "0 5" # s "supersaw"<br />
</source><br />
<br />
The default sustain length is a bit long so the sounds will overlap, you can adjust this using the sustain parameter<br />
<br />
<source><br />
d1 $ n "c5 d5*2" # s "supersaw" # sustain "0.4 0.2"<br />
</source><br />
<br />
Many example synths can be found in the default-synths-extra.scd file in the SuperDirt/library folder or in default-synths.scd and tutorial-synths.scd in the SuperDirt/synths folder. These include:<br />
<br />
* a series of tutorials: tutorial1, tutorial2, tutorial3, tutorial4, tutorial5<br />
* examples of modulating with the cursor or sound input: pmsin, in, inr<br />
* physical modeling synths: supermandolin, supergong, superpiano, superhex<br />
* a basic synth drumkit: superkick, superhat, supersnare, superclap, super808<br />
* four analogue-style synths: supersquare, supersaw, superpwm, supercomparator<br />
* two digital-style synths: superchip, supernoise<br />
<br />
To find the SuperDirt folder, simply run Quarks.folder in supercollider. The full folder location should appear in the postwindow (which is usually in the bottom right).<br />
<br />
Many of the above synths accept additional Tidal Parameters or interpret the usual parameters in a slightly different way. For complete documentation, see default-synths.scd, but here are some examples to try:<br />
<br />
<source><br />
d1 $ jux (# accelerate "-0.1") $ s "supermandolin*8" # midinote "[80!6 78]/8"<br />
# sustain "1 0.25 2 1"<br />
</source><br />
<br />
<source><br />
d1 $ midinote (slow 2 $ (run 8) * 7 + 50) # s "supergong" # decay "[1 0.2]/4"<br />
# voice "[0.5 0]/8" # sustain (slow 16 $ scale 5 0.5 $ saw1)<br />
</source><br />
<br />
<source><br />
d1 $ sound "superhat:0*8" # sustain "0.125!6 1.2" # accelerate "[0.5 -0.5]/4"<br />
</source><br />
<br />
<source><br />
d1 $ s "super808 supersnare" # n (irand 5)<br />
# voice "0.2" # decay "[2 0.5]/4" # accelerate "-0.1" # sustain "0.5" # speed "[0.5 2]/4"<br />
</source><br />
<br />
<source><br />
d1 $ n (slow 8 "[[c5 e5 g5 c6]*4 [b4 e5 g5 b5]*4]") # s "superpiano"<br />
# velocity "[1.20 0.9 0.8 1]"<br />
</source><br />
<br />
<source><br />
d1 $ n (slow 8 $ "[[c4,e4,g4,c5]*4 [e4,g4,b5,e5]*4]" + "<12 7>") # s "superpiano"<br />
# velocity (slow 8 $ scale 0.8 1.1 sine1) # sustain "8"<br />
</source><br />
<br />
<source><br />
d1 $ n "[c2 e3 g4 c5 c4 c3]/3" # s "[superpwm supersaw supersquare]/24" # sustain "0.5"<br />
# voice "0.9" # semitone "7.9" # resonance "0.3" # lfo "3" # pitch1 "0.5" # speed "0.25 1"<br />
</source><br />
<br />
<source><br />
d1 $ every 16 (density 24 . (|+| midinote "24") . (# sustain "0.3") . (# attack "0.05"))<br />
$ s "supercomparator/4" # midinote ((irand 24) + 24)<br />
# sustain "8" # attack "0.5" # hold "4" # release "4"<br />
# voice "0.5" # resonance "0.9" # lfo "1" # speed "30" # pitch1 "4"<br />
</source><br />
<br />
<source><br />
d1 $ n "[c2 e3 g4 c5 c4 c3]*4/3" # s "superchip" # sustain "0.1"<br />
# pitch2 "[1.2 1.5 2 3]" # pitch3 "[1.44 2.25 4 9]"<br />
# voice (slow 4 "0 0.25 0.5 0.75") # slide "[0 0.1]/8" # speed "-4"<br />
</source><br />
<br />
<source><br />
d2 $ every 4 (echo (negate 3/32)) $ n "c5*4" # s "supernoise"<br />
# accelerate "-2" # speed "1" # sustain "0.1 ! ! 1" # voice "0.0"<br />
</source><br />
<br />
<source><br />
d1 $ s "supernoise/8" # midinote ((irand 10) + 30) # sustain "8"<br />
# accelerate "0.5" # voice "0.5" # pitch1 "0.15" # slide "-0.5" # resonance "0.7"<br />
# attack "1" # release "20" # room "0.9" # size "0.9" # orbit "1"<br />
</source><br />
<br />
This is all quite new and under ongoing development, but you can read about modifying and adding your own synths to SuperDirt at its github repository.</div>ZimaPurple