cycles.mdx155 lines · 3.8 KB · raw
1---
2title: Understanding Cycles
3layout: ../../layouts/MainLayout.astro
4---
5
6import { MiniRepl } from '../../docs/MiniRepl';
7import { PitchSlider } from '../../components/PitchSlider';
8import Box from '@components/Box.astro';
9
10# Understanding Cycles
11
12The concept of cycles is very central to be able to understand how Strudel works.
13Strudel's mother language, TidalCycles, even has it in its name.
14
15## Cycles and BPM
16
17In most music software, the unit BPM (beats per minute) is used to set the tempo.
18Strudel expresses tempo as CPS (cycles per second), with a default of 0.5 CPS:
19
20<MiniRepl client:visible tune={`s("bd")`} />
21
22Here we can hear the 0.5CPS in action: The kick repeats once every two seconds.
23Let's make it 4 kicks:
24
25<MiniRepl client:visible tune={`s("bd bd bd bd")`} />
26
27Now we have 4 kicks per cycle, but the whole pattern still plays at 0.5CPS.
28In terms of BPM, most musicians would tell you this is playing at 120bpm.
29What about this one:
30
31<MiniRepl client:visible tune={`s("bd hh bd hh")`} />
32
33Because the second sound is now a hihat, the tempo feels slower again.
34This brings us to an important realization:
35
36<Box>
37
38Tempo is based on perception.
39The choice of sounds also has an impact on the tempo feel.
40This is why the same CPS can produce different perceived tempos.
41
42</Box>
43
44## Setting CPM
45
46If you're familiar with BPM, you can use the `setcpm` method to set the global tempo in cycles per minute:
47
48<MiniRepl
49  client:visible
50  tune={`setcpm(110)
51s("bd hh")`}
52/>
53
54If you want to add more beats per cycle, you might want to divide the cpm:
55
56<MiniRepl
57  client:visible
58  tune={`setcpm(110/4)
59s("bd sd bd rim, hh*8")`}
60/>
61
62Or using 2 beats per cycle:
63
64<MiniRepl
65  client:visible
66  tune={`setcpm(110/2)
67s("bd sd, hh*4")`}
68/>
69
70You can use the `setcps` method to set the global tempo in cycles per second. `setcpm(x)` is the same as `setcps(x / 60)`.
71
72<Box>
73
74To set a specific bpm, use `setcpm(bpm/bpc)`
75
76- bpm: the target beats per minute
77- bpc: the number of perceived beats per cycle
78
79</Box>
80
81## Cycles and Bars
82
83Also in most music software, multiple beats form a bar (or measure).
84The so called time signature specifies how many beats are in each bar.
85In many types of music, it is common to use 4 beats per bar, also known as 4/4 time.
86Many music programs use it as a default.
87
88Strudel does not a have concept of bars or measures, there are only cycles.
89How you use them is up to you. Above, we've had this example:
90
91<MiniRepl
92  client:visible
93  tune={`setcpm(110/4)
94s("bd sd bd rim, hh*8")`}
95/>
96
97This could be interpreted as 4/4 time with a tempo of 110bpm.
98We could write out multiple bars like this:
99
100<MiniRepl
101  client:visible
102  tune={`setcpm(110/4)
103s(\`<
104[bd sd bd rim, hh*8] 
105[bd sd bd rim*2, hh*8]
106>\`)`}
107/>
108
109Instead of writing out each bar separately, we could express this much shorter:
110
111<MiniRepl
112  client:visible
113  tune={`setcpm(110/2)
114s("bd <sd rim*<1 2>>,hh*4")`}
115/>
116
117Here we can see that thinking in cycles rather than bars simplifies things a lot!
118These types of simplifications work because of the repetitive nature of rhythm.
119In computational terms, you could say the former notation has a lot of redundancy.
120
121## Time Signatures
122
123To get a time signature, just change the number of elements per bar. Here is a rhythm with 7 beats:
124
125<MiniRepl client:visible tune={`s("bd ~ rim bd bd rim ~")`} />
126
127or with 5:
128
129<MiniRepl client:visible tune={`s("bd hh hh bd hh hh bd rim bd hh")`} />
130
131We could also write multiple bars with different time signatures:
132
133<MiniRepl
134  client:visible
135  tune={`setcpm(110*2)
136s(\`<
137[bd hh rim]@3
138[bd hh rim sd]@4
139>\`)`}
140/>
141
142Here we switch between 3/4 and 4/4, keeping the same tempo.
143
144If we don't specify the length, we get what's called a metric modulation:
145
146<MiniRepl
147  client:visible
148  tune={`setcpm(110/2)
149s(\`<
150[bd hh rim]
151[bd hh rim sd]
152>\`)`}
153/>
154
155Now the 3 elements get the same time as the 4 elements, which is why the tempo changes.