[BREAKING] Feat: quotation is now using ()
This commit is contained in:
@@ -29,22 +29,22 @@ These are compiled directly into branch instructions. For that reason, these wor
|
||||
When you already have a quotation, `?` executes it if the condition is truthy:
|
||||
|
||||
```forth
|
||||
{ 0.4 verb } coin ?
|
||||
( 0.4 verb ) coin ?
|
||||
saw s c4 note 0.5 gain . ;; reverb on half the hits
|
||||
```
|
||||
|
||||
`!?` is the opposite — executes when falsy:
|
||||
|
||||
```forth
|
||||
{ 0.2 gain } coin !?
|
||||
( 0.2 gain ) coin !?
|
||||
saw s c4 note . ;; quiet on half the hits
|
||||
```
|
||||
|
||||
These pair well with `chance`, `prob`, and the other probability words:
|
||||
|
||||
```forth
|
||||
{ 0.5 verb } 0.3 chance ? ;; occasional reverb wash
|
||||
{ 12 + } fill ? ;; octave up during fills
|
||||
( 0.5 verb ) 0.3 chance ? ;; occasional reverb wash
|
||||
( 12 + ) fill ? ;; octave up during fills
|
||||
```
|
||||
|
||||
## ifelse
|
||||
@@ -52,14 +52,14 @@ These pair well with `chance`, `prob`, and the other probability words:
|
||||
Two quotations, one condition. The true branch comes first:
|
||||
|
||||
```forth
|
||||
{ c3 note } { c4 note } coin ifelse
|
||||
( c3 note ) ( c4 note ) coin ifelse
|
||||
saw s 0.6 gain . ;; bass or lead, coin flip
|
||||
```
|
||||
|
||||
Reads naturally: "c3 or c4, depending on the coin."
|
||||
|
||||
```forth
|
||||
{ 0.8 gain } { 0.3 gain } fill ifelse
|
||||
( 0.8 gain ) ( 0.3 gain ) fill ifelse
|
||||
tri s c4 note 0.2 decay . ;; loud during fills, quiet otherwise
|
||||
```
|
||||
|
||||
@@ -68,7 +68,7 @@ tri s c4 note 0.2 decay . ;; loud during fills, quiet otherwise
|
||||
Choose the nth option from a list of quotations:
|
||||
|
||||
```forth
|
||||
{ c4 } { e4 } { g4 } { b4 } iter 4 mod select
|
||||
( c4 ) ( e4 ) ( g4 ) ( b4 ) iter 4 mod select
|
||||
note sine s 0.5 decay .
|
||||
```
|
||||
|
||||
@@ -79,7 +79,7 @@ Four notes cycling through a major seventh chord, one per pattern iteration. The
|
||||
When you have a quotation and want to execute it unconditionally, use `apply`:
|
||||
|
||||
```forth
|
||||
{ dup + } apply ;; doubles the top value
|
||||
( dup + ) apply ;; doubles the top value
|
||||
```
|
||||
|
||||
This is simpler than `?` when there is no condition to check. It pops the quotation and runs it.
|
||||
@@ -115,14 +115,14 @@ saw s c4 note .
|
||||
Repeat a quotation n times. The variable `@i` is automatically set to the current iteration index (starting from 0):
|
||||
|
||||
```forth
|
||||
3 { c4 @i 4 * + note } times
|
||||
3 ( c4 @i 4 * + note ) times
|
||||
sine s 0.4 gain 0.5 verb . ;; c4, e4, g#4 — a chord
|
||||
```
|
||||
|
||||
Subdivide with `at`:
|
||||
|
||||
```forth
|
||||
4 { @i 4 / at sine s c4 note 0.3 gain . } times
|
||||
4 ( @i 4 / at sine s c4 note 0.3 gain . ) times
|
||||
```
|
||||
|
||||
Four evenly spaced notes within the step.
|
||||
@@ -130,11 +130,11 @@ Four evenly spaced notes within the step.
|
||||
Vary intensity per iteration:
|
||||
|
||||
```forth
|
||||
8 {
|
||||
8 (
|
||||
@i 8 / at
|
||||
@i 4 mod 0 = if 0.7 else 0.2 then gain
|
||||
tri s c5 note 0.1 decay .
|
||||
} times
|
||||
) times
|
||||
```
|
||||
|
||||
Eight notes per step. Every fourth one louder.
|
||||
|
||||
Reference in New Issue
Block a user