Mini-Notation¶
krp.p() parses a compact string notation into a pattern. It is a shorthand
for building patterns without chaining Python calls.
Syntax¶
Returns a Pattern object -- composable like any other pattern.
Tokens¶
| Token | Meaning | Equivalent |
|---|---|---|
x or X |
Hit (percussive trigger) | krp.hit() |
. |
Rest | krp.rest() |
~ |
Rest (alternative) | krp.rest() |
- |
Rest (alternative) | krp.rest() |
C4, Cs4, C#4 |
Note by pitch name | krp.note("C4") |
Grouping: []¶
Square brackets play tokens simultaneously (stacked):
krp.p("[C4 E4] G4 B4") # C4 and E4 together, then G4, then B4
krp.p("[x x] . x .") # double hit, rest, hit, rest
Repeat: *N¶
Repeat a token N times:
Examples¶
Drum patterns¶
# Basic 4/4 kick
kr.play("kick", krp.p("x . . . x . . . x . . . x . . ."))
# Shorter: 4 hits with rests between
kr.play("kick", krp.p("x . x . x . . x"))
# Hi-hat 8ths
kr.play("hat", krp.p("x x x x x x x x"))
Melodic patterns¶
# Simple melody
kr.play("lead", krp.p("C4 E4 G4 ~ C5"))
# With simultaneous notes
kr.play("pad", krp.p("[C4 E4] [D4 F4] [E4 G4] ~"))
Composable¶
Mini-notation patterns support all the same transforms: