Files
Cagire/docs/selection.md

63 lines
1.0 KiB
Markdown

# Selection
Cycle through values over time for evolving patterns.
## Step Cycle
`cycle` cycles through values based on step runs:
```forth
60 64 67 3 cycle note ( cycle through C, E, G )
```
Each time the step runs, it picks the next value.
## Pattern Cycle
`pcycle` cycles based on pattern iteration:
```forth
60 64 67 3 pcycle note ( change note each pattern loop )
```
## Emit-Time Cycle
`tcycle` creates a cycle list resolved at emit time, useful with `.!`:
```forth
60 64 67 3 tcycle note 3 .! ( emit C, E, G in sequence )
```
## Examples
Rotating bass notes:
```forth
"bass" s
c3 e3 g3 b3 4 cycle note
.
```
Evolving pattern over loops:
```forth
"lead" s
0.5 1.0 0.75 0.25 4 pcycle gain
.
```
Arpeggiated chord:
```forth
"pluck" s
c4 e4 g4 c5 4 tcycle note 4 .!
```
## Words
| Word | Stack | Description |
|------|-------|-------------|
| `cycle` | (v1..vn n -- val) | Cycle by step runs |
| `pcycle` | (v1..vn n -- val) | Cycle by pattern iteration |
| `tcycle` | (v1..vn n -- list) | Create cycle list for emit-time |