refactor: replace .cpm with setcpm calls

+ doc setcpm
This commit is contained in:
Felix Roos 2025-06-19 09:09:45 +02:00
parent a8f2537e31
commit 6c4aa12c60
No known key found for this signature in database
12 changed files with 169 additions and 109 deletions

View file

@ -216,8 +216,9 @@ Finding the right notes can be difficult.. Scales are here to help:
<MiniRepl
client:visible
tune={`n("0 2 4 <[6,8] [7,9]>")
.scale("C:minor").sound("piano").cpm(60)`}
tune={`setcpm(60)
n("0 2 4 <[6,8] [7,9]>")
.scale("C:minor").sound("piano")`}
punchcard
/>
@ -242,9 +243,10 @@ Just like anything, we can automate the scale with a pattern:
<MiniRepl
client:visible
tune={`n("<0 -3>, 2 4 <[6,8] [7,9]>")
tune={`setcpm(60)
n("<0 -3>, 2 4 <[6,8] [7,9]>")
.scale("<C:major D:mixolydian>/4")
.sound("piano").cpm(60)`}
.sound("piano")`}
punchcard
/>
@ -275,9 +277,10 @@ Try changing that number!
<MiniRepl
client:visible
tune={`n("<[4@2 4] [5@2 5] [6@2 6] [5@2 5]>*2")
tune={`setcpm(60)
n("<[4@2 4] [5@2 5] [6@2 6] [5@2 5]>*2")
.scale("<C2:mixolydian F2:mixolydian>/4")
.sound("gm_acoustic_bass").cpm(60)`}
.sound("gm_acoustic_bass")`}
punchcard
/>
@ -291,7 +294,12 @@ This is also sometimes called triplet swing. You'll often find it in blues and j
**Replicate**
<MiniRepl client:visible tune={`note("c!2 [eb,<g a bb a>]").sound("piano").cpm(60)`} punchcard />
<MiniRepl
client:visible
tune={`setcpm(60)
note("c!2 [eb,<g a bb a>]").sound("piano")`}
punchcard
/>
<Box>

View file

@ -166,9 +166,14 @@ Try also changing the number at the end to change the tempo!
</Box>
**changing the tempo with cpm**
**changing the tempo with setcpm**
<MiniRepl client:visible tune={`sound("<bd hh rim hh>*8").cpm(90/4)`} punchcard />
<MiniRepl
client:visible
tune={`setcpm(90/4)
sound("<bd hh rim hh>*8")`}
punchcard
/>
<Box>
@ -287,7 +292,7 @@ The Mini-Notation is usually used inside some function. These are the functions
| ----- | ----------------------------------- | --------------------------------------------------------------------------------- |
| sound | plays the sound of the given name | <MiniRepl client:visible tune={`sound("bd sd [- bd] sd")`} /> |
| bank | selects the sound bank | <MiniRepl client:visible tune={`sound("bd sd [- bd] sd").bank("RolandTR909")`} /> |
| cpm | sets the tempo in cycles per minute | <MiniRepl client:visible tune={`sound("bd sd [- bd] sd").cpm(45)`} /> |
| cpm | sets the tempo in cycles per minute | <MiniRepl client:visible tune={`setcpm(45); sound("bd sd [- bd] sd")`} /> |
| n | select sample number | <MiniRepl client:visible tune={`n("0 1 4 2 0 6 3 2").sound("jazz")`} /> |
## Examples
@ -296,8 +301,8 @@ The Mini-Notation is usually used inside some function. These are the functions
<MiniRepl
client:visible
tune={`sound("[bd sd]*2, hh*8").bank("RolandTR505")
.cpm(100/4)`}
tune={`setcpm(100/4)
sound("[bd sd]*2, hh*8").bank("RolandTR505")`}
punchcard
/>
@ -314,14 +319,20 @@ Certain drum patterns are reused across genres.
We Will Rock you
<MiniRepl client:visible tune={`sound("bd*2 cp").bank("RolandTR707").cpm(81/2)`} punchcard />
<MiniRepl
client:visible
tune={`setcpm(81/2)
sound("bd*2 cp").bank("RolandTR707")`}
punchcard
/>
**Yellow Magic Orchestra - Firecracker**
<MiniRepl
client:visible
tune={`sound("bd sd, - - - hh - hh - -, - perc - perc:1*2")
.bank("RolandCompurhythm1000").cpm(120/2)`}
tune={`setcpm(120/2)
sound("bd sd, - - - hh - hh - -, - perc - perc:1*2")
.bank("RolandCompurhythm1000")`}
punchcard
/>
@ -329,12 +340,14 @@ We Will Rock you
<MiniRepl
client:visible
tune={`sound(\`
tune={`
setcpm(90/4)
sound(\`
[- - oh - ] [- - - - ] [- - - - ] [- - - - ],
[hh hh - - ] [hh - hh - ] [hh - hh - ] [hh - hh - ],
[- - - - ] [cp - - - ] [- - - - ] [cp - - - ],
[bd - - - ] [- - - bd] [- - bd - ] [- - - bd]
\`).cpm(90/4)`}
\`)`}
punchcard
/>
@ -342,12 +355,13 @@ We Will Rock you
<MiniRepl
client:visible
tune={`sound(\`
tune={`setcpm(88/4)
sound(\`
[- - - - ] [- - - - ] [- - - - ] [- - oh:1 - ],
[hh hh hh hh] [hh hh hh hh] [hh hh hh hh] [hh hh - - ],
[- - - - ] [cp - - - ] [- - - - ] [~ cp - - ],
[bd bd - - ] [- - bd - ] [bd bd - bd ] [- - - - ]
\`).bank("RolandTR808").cpm(88/4)`}
\`).bank("RolandTR808")`}
punchcard
/>
@ -355,11 +369,11 @@ We Will Rock you
<MiniRepl
client:visible
tune={`s(\`jazz*2,
tune={`setcpm(100/2)
s(\`jazz*2,
insect [crow metal] - -,
- space:4 - space:1,
- wind\`)
.cpm(100/2)`}
- wind\`)`}
punchcard
/>

View file

@ -68,9 +68,10 @@ Try commenting out one or more by adding `//` before a line
<MiniRepl
client:visible
tune={`note("c2 [eb3,g3] ".add("<0 <1 -1>>"))
tune={`setcpm(60)
note("c2 [eb3,g3] ".add("<0 <1 -1>>"))
.color("<cyan <magenta yellow>>").adsr("[.1 0]:.2:[1 0]")
.sound("gm_acoustic_bass").room(.5).cpm(60)`}
.sound("gm_acoustic_bass").room(.5)`}
punchcard
/>
@ -84,9 +85,10 @@ We can add as often as we like:
<MiniRepl
client:visible
tune={`note("c2 [eb3,g3]".add("<0 <1 -1>>").add("0,7"))
tune={`setcpm(60)
note("c2 [eb3,g3]".add("<0 <1 -1>>").add("0,7"))
.color("<cyan <magenta yellow>>").adsr("[.1 0]:.2:[1 0]")
.sound("gm_acoustic_bass").room(.5).cpm(60)`}
.sound("gm_acoustic_bass").room(.5)`}
punchcard
/>

View file

@ -56,13 +56,13 @@ This page is just a listing of all functions covered in the workshop!
## Pattern Effects
| name | description | example |
| ---- | ----------------------------------- | ----------------------------------------------------------------------------------- |
| cpm | sets the tempo in cycles per minute | <MiniRepl client:visible tune={`sound("bd sd [~ bd] sd").cpm(45)`} /> |
| fast | speed up | <MiniRepl client:visible tune={`sound("bd sd [~ bd] sd").fast(2)`} /> |
| slow | slow down | <MiniRepl client:visible tune={`sound("bd sd [~ bd] sd").slow(2)`} /> |
| rev | reverse | <MiniRepl client:visible tune={`n("0 2 4 6").scale("C:minor").rev()`} /> |
| jux | split left/right, modify right | <MiniRepl client:visible tune={`n("0 2 4 6").scale("C:minor").jux(rev)`} /> |
| add | add numbers / notes | <MiniRepl client:visible tune={`n("0 2 4 6".add("<0 1 2 1>")).scale("C:minor")`} /> |
| ply | speed up each event n times | <MiniRepl client:visible tune={`s("bd sd").ply("<1 2 3>")`} /> |
| off | copy, shift time & modify | <MiniRepl client:visible tune={`s("bd sd, hh*4").off(1/8, x=>x.speed(2))`} /> |
| name | description | example |
| ------ | ----------------------------------- | ----------------------------------------------------------------------------------- |
| setcpm | sets the tempo in cycles per minute | <MiniRepl client:visible tune={`setcpm(45); sound("bd sd [~ bd] sd")`} /> |
| fast | speed up | <MiniRepl client:visible tune={`sound("bd sd [~ bd] sd").fast(2)`} /> |
| slow | slow down | <MiniRepl client:visible tune={`sound("bd sd [~ bd] sd").slow(2)`} /> |
| rev | reverse | <MiniRepl client:visible tune={`n("0 2 4 6").scale("C:minor").rev()`} /> |
| jux | split left/right, modify right | <MiniRepl client:visible tune={`n("0 2 4 6").scale("C:minor").jux(rev)`} /> |
| add | add numbers / notes | <MiniRepl client:visible tune={`n("0 2 4 6".add("<0 1 2 1>")).scale("C:minor")`} /> |
| ply | speed up each event n times | <MiniRepl client:visible tune={`s("bd sd").ply("<1 2 3>")`} /> |
| off | copy, shift time & modify | <MiniRepl client:visible tune={`s("bd sd, hh*4").off(1/8, x=>x.speed(2))`} /> |