jevstrudel.git / website / src / pages / learn / mini-notation.mdx
mini-notation.mdx264 lines · 10.5 KB · raw
1---
2title: Mini Notation
3layout: ../../layouts/MainLayout.astro
4---
5
6import { MiniRepl } from '../../docs/MiniRepl';
7import { JsDoc } from '../../docs/JsDoc';
8
9# Mini-notation
10
11Just like [Tidal Cycles](https://tidalcycles.org/), Strudel uses a so called "Mini-Notation", which is a custom language that is designed for writing rhythmic patterns using little amounts of text.
12
13## Note
14
15This page just explains the entirety of the Mini-Notation syntax.
16If you are just getting started with Strudel, you can learn the basics of the Mini-Notation in a more practical manner in the [workshop](/workshop/first-sounds).
17After that, you can come back here if you want to understand every little detail.
18
19## Example
20
21Before diving deeper into the details, here is a flavour of how the Mini-Notation looks like:
22
23<MiniRepl
24  client:idle
25  tune={`note(\`<
26[e5 [b4 c5] d5 [c5 b4]]
27[a4 [a4 c5] e5 [d5 c5]]
28[b4 [~ c5] d5 e5]
29[c5 a4 a4 ~]
30[[~ d5] [~ f5] a5 [g5 f5]]
31[e5 [~ c5] e5 [d5 c5]]
32[b4 [b4 c5] d5 e5]
33[c5 a4 a4 ~]
34,
35[[e2 e3]*4]
36[[a2 a3]*4]
37[[g#2 g#3]*2 [e2 e3]*2]
38[a2 a3 a2 a3 a2 a3 b1 c2]
39[[d2 d3]*4]
40[[c2 c3]*4]
41[[b1 b2]*2 [e2 e3]*2]
42[[a1 a2]*4]
43>\`)`}
44/>
45
46## Mini Notation Format
47
48The snippet above is enclosed in backticks (`), which allows you to write multi-line strings.
49
50You can also use regular double quotes (`"`) for single line mini-notation, as we have done already.
51
52If you do just want to get a regular string that is _not_ parsed as mini-notation, use single quotes (`'`).
53
54## Sequences of events in a cycle
55
56We can play more notes by separating them with spaces:
57
58<MiniRepl client:idle tune={`note("c e g b")`} punchcard />
59
60Here, those four notes are squashed into one cycle, so each note is a quarter second long.
61Try adding or removing notes and notice how the tempo changes!
62
63<MiniRepl client:idle tune={`note("c d e f g a b")`} punchcard />
64
65Note that the overall duration of time does not change, and instead each note length decreases.
66This is a key idea, as it illustrates the 'Cycle' in TidalCycles!
67
68Each space-separated note in this sequence is an _event_.
69The time duration of each event is based on the speed or tempo of the cycle, and how many events are present.
70Taking the two examples above, we have four and eight events respectively, and since they have the same cycle duration, they each have to fit their events inside the same amount of time.
71
72This is perhaps counter-intuitive if you are used to adding notes in a sequencer or piano roll and the overall length increasing.
73But, it will begin to make sense as we go through more elements of mini-notation.
74
75## Multiplication
76
77A sequence can be sped up by multiplying it by a number using the asterisk symbol (`*`):
78
79<MiniRepl client:idle tune={`note("[e5 b4 d5 c5]*2")`} punchcard />
80
81The multiplication by two here means that the sequence will play twice per cycle.
82
83Multiplications can also be decimal (`*2.75`):
84
85<MiniRepl client:idle tune={`note("[e5 b4 d5 c5]*2.75")`} punchcard />
86
87## Division
88
89Contrary to multiplication, division can slow the sequence down by enclosing it in brackets and dividing it by a number (`/2`):
90
91<MiniRepl client:idle tune={`note("[e5 b4 d5 c5]/2")`} punchcard />
92
93The division by two means that the sequence will be played over the course of two cycles.
94You can also use decimal numbers for any tempo you like (`/2.75`).
95
96<MiniRepl client:idle tune={`note("[e5 b4 d5 c5]/2.75")`} punchcard />
97
98## Angle Brackets
99
100Using angle brackets `<>`, we can define the sequence length based on the number of events:
101
102<MiniRepl client:idle tune={`note("<e5 b4 d5 c5>")`} punchcard />
103
104The above snippet is the same as:
105
106<MiniRepl client:idle tune={`note("[e5 b4 d5 c5]/4")`} punchcard />
107
108The advantage of the angle brackets, is that we can add more events without needing to change the number at the end.
109
110<MiniRepl client:idle tune={`note("<e5 b4 d5 c5 e5>")`} punchcard />
111
112<MiniRepl client:idle tune={`note("<e5 b4 d5 c5 e5 b4>")`} punchcard />
113
114This is more similar to traditional music sequencers and piano rolls, where adding a note increases the perceived overall duration.
115We can also play a certain number of notes per cycle by using angle brackets with multiplication:
116
117<MiniRepl client:idle tune={`note("<e5 b4 d5 c5 a4 c5>*8")`} punchcard />
118
119Now we are playing 8 notes per cycle!
120
121## Subdividing time with bracket nesting
122
123To create more interesting rhythms, you can _nest_ or _enclose_ sequences (put sequences inside sequences) with brackets `[]`, like this:
124
125Compare the difference between the following:
126
127<MiniRepl client:idle tune={`note("e5 b4 c5 d5 c5 b4")`} />
128<MiniRepl client:idle tune={`note("e5 [b4 c5] d5 c5 b4")`} />
129<MiniRepl client:idle tune={`note("e5 [b4 c5] d5 [c5 b4]")`} />
130<MiniRepl client:idle tune={`note("e5 [b4 c5] d5 [c5 b4 d5 e5]")`} />
131<MiniRepl client:idle tune={`note("e5 [b4 c5] d5 [c5 b4 [d5 e5]]")`} />
132
133What's going on here? When we nest/enclose multiple events inside brackets (`[]`), their duration becomes the length of one event in the outer sequence.
134
135This is a very simple change to make, but it has profound consequences.
136Remember what we said earlier about how the cycles in tidal stay the same length, and the individual event lengths are divided up in this cycle?
137Well, what this means is that in TidalCycles, not only can you divide time any way you want, and you can also subdivide time any way you want!
138
139## Rests
140
141The "~" represents a rest, and will create silence between other events:
142
143<MiniRepl client:idle tune={`note("[b4 [~ c5] d5 e5]")`} punchcard />
144
145Alternatively, "-" can be used instead of "~". It means the same thing.
146
147## Parallel / polyphony
148
149Using commas, we can play chords.
150The following are the same:
151
152<MiniRepl client:idle tune={`note("[g3,b3,e4]")`} />
153<MiniRepl client:idle tune={`note("g3,b3,e4")`} punchcard canvasHeight={80} />
154
155But to play multiple chords in a sequence, we have to wrap them in brackets:
156
157<MiniRepl client:idle tune={`note("<[g3,b3,e4] [a3,c3,e4] [b3,d3,f#4] [b3,e4,g4]>*2")`} punchcard />
158
159## Elongation
160
161With the "@" symbol, we can specify temporal "weight" of a sequence child:
162
163<MiniRepl client:idle tune={`note("<[g3,b3,e4]@2 [a3,c3,e4] [b3,d3,f#4]>*2")`} punchcard />
164
165Here, the first chord has a weight of 2, making it twice the length of the other chords. The default weight is 1.
166
167## Replication
168
169Using "!" we can repeat without speeding up:
170
171<MiniRepl client:idle tune={`note("<[g3,b3,e4]!2 [a3,c3,e4] [b3,d3,f#4]>*2")`} punchcard />
172
173## Randomness
174
175Events with a "?" placed after them will have a 50% chance of being removed from the pattern:
176
177<MiniRepl client:idle tune={`note("[g3,b3,e4]*8?")`} punchcard />
178
179Adding a number between 0 and 1 after the "?" will affect the likelihood of the event being removed. For example, events with "?0.1" placed after them will have a 10% chance of being removed:
180
181<MiniRepl client:idle tune={`note("[g3,b3,e4]*8?0.1")`} punchcard />
182
183Events separated by a "|" will be chosen from at random:
184
185<MiniRepl client:idle tune={`note("[g3,b3,e4] | [a3,c3,e4] | [b3,d3,f#4]")`} punchcard />
186
187## Mini-notation review
188
189To recap what we've learned so far, compare the following patterns:
190
191<MiniRepl client:idle tune={`note("<g3 b3 e4 [a3,c3,e4] [b3,d3,f#4]>*2")`} />
192<MiniRepl client:idle tune={`note("<[g3,b3,e4] [a3,c3,e4] [b3,d3,f#4]>*2")`} />
193<MiniRepl client:idle tune={`note("<[g3,b3,e4]/2 [a3,c3,e4] [b3,d3,f#4]>*2")`} />
194<MiniRepl client:idle tune={`note("<[g3,b3,e4]*2 [a3,c3,e4] [b3,d3,f#4]>*2")`} />
195<MiniRepl client:idle tune={`note("<[g3,b3,e4] _ [a3,c3,e4] [b3,d3,f#4]>*2")`} />
196<MiniRepl client:idle tune={`note("<[g3,b3,e4]@2 [a3,c3,e4] [b3,d3,f#4]>*2")`} />
197<MiniRepl client:idle tune={`note("<[g3,b3,e4]!2 [a3,c3,e4] [b3,d3,f#4]>*2")`} />
198<MiniRepl client:idle tune={`note("<[g3,b3,e4]? [a3,c3,e4] [b3,d3,f#4]>*2")`} />
199<MiniRepl client:idle tune={`note("<[g3|b3|e4] [a3,c3,e4] [b3,d3,f#4]>*2")`} />
200
201## Euclidian rhythms
202
203Using round brackets after an event, we can create rhythmical sub-divisions based on three parameters: `beats`, `segments` and `offset`.
204This algorithm can be found in many different types of music software, and is often referred to as a [Euclidean rhythm](https://en.wikipedia.org/wiki/Euclidean_rhythm) sequencer, after computer scientist Godfriend Toussaint.
205Why is it interesting? Well, consider the following simple example:
206
207<MiniRepl client:idle tune={`s("bd(3,8,0)")`} punchcard canvasHeight={50} />
208
209Sound familiar?
210This is a popular Euclidian rhythm going by various names, such as "Pop Clave".
211These rhythms can be found in all musical cultures, and the Euclidian rhythm algorithm allows us to express them extremely easily.
212Writing this rhythm out in full require describing:
213
214<MiniRepl client:idle tune={`s("bd ~ ~ bd ~ ~ bd ~")`} punchcard canvasHeight={50} />
215
216But using the Euclidian rhythm notation, we only need to express "3 beats over 8 segments, starting on position 1".
217
218This makes it easy to write patterns with interesting rhythmic structures and variations that still sound familiar:
219
220<MiniRepl client:idle tune={`note("e5(2,8) b4(3,8) d5(2,8) c5(3,8)").slow(2)`} punchcard canvasHeight={50} />
221
222Note that since the example above does not use the third `offset` parameter, it can be written simply as `"(3,8)"`.
223
224<MiniRepl client:idle tune={`s("bd(3,8)")`} punchcard canvasHeight={50} />
225
226Let's look at those three parameters in detail.
227
228### Beats
229
230`beats`: the first parameter controls how may beats will be played.
231Compare these:
232
233<MiniRepl client:idle tune={`s("bd(2,8)")`} punchcard canvasHeight={50} />
234<MiniRepl client:idle tune={`s("bd(5,8)")`} punchcard canvasHeight={50} />
235<MiniRepl client:idle tune={`s("bd(7,8)")`} punchcard canvasHeight={50} />
236
237### Segments
238
239`segments`: the second parameter controls the total amount of segments the beats will be distributed over:
240
241<MiniRepl client:idle tune={`s("bd(3,4)")`} punchcard canvasHeight={50} />
242<MiniRepl client:idle tune={`s("bd(3,8)")`} punchcard canvasHeight={50} />
243<MiniRepl client:idle tune={`s("bd(3,13)")`} punchcard canvasHeight={50} />
244
245### Offsets
246
247`offset`: the third (optional) parameter controls the starting position for distributing the beats.
248We need a secondary rhythm to hear the difference:
249
250<MiniRepl client:idle tune={`s("bd(3,8,0), hh cp")`} punchcard />
251<MiniRepl client:idle tune={`s("bd(3,8,3), hh cp")`} punchcard />
252<MiniRepl client:idle tune={`s("bd(3,8,5), hh cp")`} punchcard />
253
254## Mini-notation exercise
255
256The most fun thing about the mini-notation, is that everything you have just learned can be combined in various ways!
257
258Starting with this one `n`, can you make a _pattern string_ that uses every single mini-notation element above?
259
260<MiniRepl client:idle tune={`n("60")`} />
261
262<br />
263
264Next: How do [Samples](/learn/samples) play into this?