Feat: docs should be good enough
This commit is contained in:
@@ -7,21 +7,25 @@ Music needs surprise. A pattern that plays identically every time gets boring fa
|
||||
`coin` pushes 0 or 1 with equal probability:
|
||||
|
||||
```forth
|
||||
coin note sine s . ;; either 0 or 1 as the note
|
||||
;; sometimes, reverb
|
||||
sine sound
|
||||
( 0.5 verb ) coin ?
|
||||
1 decay
|
||||
.
|
||||
```
|
||||
|
||||
`rand` takes a range and returns a random value. If both bounds are integers, the result is an integer. If either is a float, you get a float:
|
||||
|
||||
```forth
|
||||
60 72 rand note sine s . ;; random MIDI note from 60 to 72
|
||||
0.3 0.9 rand gain sine s . ;; random gain between 0.3 and 0.9
|
||||
60 72 rand note sine s .5 decay . ;; random MIDI note from 60 to 72
|
||||
0.3 0.9 rand gain sine s .5 decay . ;; random gain between 0.3 and 0.9
|
||||
```
|
||||
|
||||
`exprand` and `logrand` give you weighted distributions. `exprand` is biased toward the low end, `logrand` toward the high end:
|
||||
|
||||
```forth
|
||||
200.0 8000.0 exprand freq sine s . ;; mostly low frequencies
|
||||
200.0 8000.0 logrand freq sine s . ;; mostly high frequencies
|
||||
200.0 8000.0 exprand freq sine s .5 decay . ;; mostly low frequencies
|
||||
200.0 8000.0 logrand freq sine s .5 decay . ;; mostly high frequencies
|
||||
```
|
||||
|
||||
These are useful for parameters where perception is logarithmic, like frequency and duration.
|
||||
@@ -32,7 +36,7 @@ The probability words take a quotation and execute it with some chance. `chance`
|
||||
|
||||
```forth
|
||||
( hat s . ) 0.25 chance ;; 25% chance
|
||||
( hat s . ) 75 prob ;; 75% chance
|
||||
( kick s . ) 75 prob ;; 75% chance
|
||||
```
|
||||
|
||||
Named probability words save you from remembering numbers:
|
||||
@@ -67,8 +71,8 @@ Use `?` and `!?` with `coin` for quick coin-flip decisions:
|
||||
`choose` picks randomly from n items on the stack:
|
||||
|
||||
```forth
|
||||
kick snare hat 3 choose s . ;; random drum hit
|
||||
60 64 67 72 4 choose note sine s . ;; random note from a set
|
||||
kick snare hat 3 choose s . ;; random drum hit
|
||||
60 64 67 72 4 choose note sine s .5 decay . ;; random note from a set
|
||||
```
|
||||
|
||||
When a chosen item is a quotation, it gets executed:
|
||||
@@ -187,4 +191,4 @@ c4 0.4 e4 0.3 g4 0.2 b4 0.1 4 wchoose note
|
||||
modal s .
|
||||
```
|
||||
|
||||
The root note plays most often. Higher chord tones are rarer. Decay and harmonics vary continuously.
|
||||
The root note plays most often. Higher chord tones are rarer. Decay and harmonics vary continuously.
|
||||
|
||||
Reference in New Issue
Block a user