[BREAKING] Feat: quotation is now using ()

This commit is contained in:
2026-02-28 20:25:59 +01:00
parent ec98274dfe
commit 651ed1219d
24 changed files with 182 additions and 169 deletions

View File

@@ -31,8 +31,8 @@ These are useful for parameters where perception is logarithmic, like frequency
The probability words take a quotation and execute it with some chance. `chance` takes a float from 0.0 to 1.0, `prob` takes a percentage from 0 to 100:
```forth
{ hat s . } 0.25 chance ;; 25% chance
{ hat s . } 75 prob ;; 75% chance
( hat s . ) 0.25 chance ;; 25% chance
( hat s . ) 75 prob ;; 75% chance
```
Named probability words save you from remembering numbers:
@@ -48,9 +48,9 @@ Named probability words save you from remembering numbers:
| `never` | 0% |
```forth
{ hat s . } often ;; 75%
{ snare s . } sometimes ;; 50%
{ clap s . } rarely ;; 25%
( hat s . ) often ;; 75%
( snare s . ) sometimes ;; 50%
( clap s . ) rarely ;; 25%
```
`always` and `never` are useful when you want to temporarily mute or unmute a voice without deleting code. Change `sometimes` to `never` to silence it, `always` to bring it back.
@@ -58,8 +58,8 @@ Named probability words save you from remembering numbers:
Use `?` and `!?` with `coin` for quick coin-flip decisions:
```forth
{ hat s . } coin ? ;; execute if coin is 1
{ rim s . } coin !? ;; execute if coin is 0
( hat s . ) coin ? ;; execute if coin is 1
( rim s . ) coin !? ;; execute if coin is 0
```
## Selection
@@ -74,7 +74,7 @@ kick snare hat 3 choose s . ;; random drum hit
When a chosen item is a quotation, it gets executed:
```forth
{ 0.1 decay } { 0.5 decay } { 0.9 decay } 3 choose
( 0.1 decay ) ( 0.5 decay ) ( 0.9 decay ) 3 choose
sine s .
```
@@ -115,7 +115,7 @@ The difference matters when patterns have different lengths. `cycle` counts per-
Quotations work here too:
```forth
{ c4 note } { e4 note } { g4 note } 3 cycle
( c4 note ) ( e4 note ) ( g4 note ) 3 cycle
sine s .
```
@@ -130,20 +130,20 @@ sine s .
`every` runs a quotation once every n pattern iterations:
```forth
{ crash s . } 4 every ;; crash cymbal every 4th iteration
( crash s . ) 4 every ;; crash cymbal every 4th iteration
```
`except` is the inverse -- it runs a quotation on all iterations *except* every nth:
```forth
{ 2 distort } 4 except ;; distort on all iterations except every 4th
( 2 distort ) 4 except ;; distort on all iterations except every 4th
```
`bjork` and `pbjork` use Bjorklund's algorithm to distribute k hits across n positions as evenly as possible. Classic Euclidean rhythms:
```forth
{ hat s . } 3 8 bjork ;; tresillo: x..x..x. (by step runs)
{ hat s . } 5 8 pbjork ;; cinquillo: x.xx.xx. (by pattern iterations)
( hat s . ) 3 8 bjork ;; tresillo: x..x..x. (by step runs)
( hat s . ) 5 8 pbjork ;; cinquillo: x.xx.xx. (by pattern iterations)
```
`bjork` counts by step runs (how many times this particular step has played). `pbjork` counts by pattern iterations. Some classic patterns:
@@ -172,7 +172,7 @@ The real power comes from mixing techniques. A hi-hat pattern with ghost notes:
```forth
hat s
{ 0.3 0.6 rand gain } { 0.8 gain } 2 cycle
( 0.3 0.6 rand gain ) ( 0.8 gain ) 2 cycle
.
```
@@ -181,18 +181,18 @@ Full volume on even runs, random quiet on odd runs.
A bass line that changes every 4 bars:
```forth
{ c2 note } { e2 note } { g2 note } { a2 note } 4 pcycle
{ 0.5 decay } often
( c2 note ) ( e2 note ) ( g2 note ) ( a2 note ) 4 pcycle
( 0.5 decay ) often
sine s .
```
Layered percussion with different densities:
```forth
{ kick s . } always
{ snare s . } 2 every
{ hat s . } 5 8 bjork
{ rim s . } rarely
( kick s . ) always
( snare s . ) 2 every
( hat s . ) 5 8 bjork
( rim s . ) rarely
```
A melodic step with weighted note selection and random timbre: