Updated smnp.audio.synth (markdown)
@@ -1,8 +1,49 @@
|
|||||||
# Functions
|
# Functions
|
||||||
## `wave(config: map<string><>, notes: ...list<note, int, string>)`
|
## wave
|
||||||
## `wave(...notes: list<note, int, string>)`
|
```
|
||||||
## `synth(wave: list<int>)`
|
wave(config: map<string><>, notes: ...list<note, int, string>)
|
||||||
## `synth(config: map<string><>, notes: ...list<note, int, string>)`
|
wave(...notes: list<note, int, string>)
|
||||||
## `synth(...notes: list<note, int, string>)`
|
```
|
||||||
## `adsr(p1: float = 0.1, p2: float = 0.3, p3: float = 0.8, s: float = 0.8)`
|
Compiles a given notes to wave, which is represented by list of integers with values between 0 and 255. You can pass additional config object which is a map overriding default configuration parameters.
|
||||||
## `constant()`
|
|
||||||
|
#### Arguments
|
||||||
|
* `config` - a config map of following schema:
|
||||||
|
|
||||||
|
| KEY | TYPE | VALUE | DEFAULT
|
||||||
|
|:---:|:----:|:-----:|:-----
|
||||||
|
| bpm | `int` | Tempo determined as a number of beats per minute. | 120
|
||||||
|
| overtones | list<float> | A list of magnitudes of index-determined overtones. | `[1.0, 0.7, 0.5, 0.3]`
|
||||||
|
| tuning | `float` | A base frequency for _A4_ sound | 440.0
|
||||||
|
| envelope | `map<string><>` | A config map that determines wave's envelope with respective parameters | `{ name -> "adsr", p1 -> 0.1, p2 -> 0.3, p3 -> 0.8, s -> 0.8 }`
|
||||||
|
|
||||||
|
* `notes` - a list of items intended for compilation to wave. Strings are not supported, however, because of compatibility with [smnp.audio.midi](https://github.com/bartlomiej-pluta/smnp/wiki/smnp.audio.midi/) module are accepted and simply ignored.
|
||||||
|
|
||||||
|
#### Output
|
||||||
|
* `list<int>` - compiled wave ready to be played via `synth()` function
|
||||||
|
|
||||||
|
#### Example
|
||||||
|
```
|
||||||
|
notes = [@c, @c, @g, @g, @a, @a, @g:2, @f, @f, @e, @e, @d, @d, @c:2];
|
||||||
|
music = wave({ bpm -> 170, overtones -> [0.7, 0.0, 0.0, 0.2, 0.0, 0.0, 0.1] }, notes);
|
||||||
|
synth(music);
|
||||||
|
```
|
||||||
|
|
||||||
|
## synth
|
||||||
|
```
|
||||||
|
synth(wave: list<int>) #1`
|
||||||
|
synth(config: map<string><>, notes: ...list<note, int, string>) #2
|
||||||
|
synth(...notes: list<note, int, string>) #3
|
||||||
|
Synthesises produced wave (`#1`) or calls internaly `wave()` function and then synthesises it (#2).
|
||||||
|
|
||||||
|
#### Arguments
|
||||||
|
* `wave` - a wave in the form of lists of integers with values between 0 and 255 (one byte)
|
||||||
|
```
|
||||||
|
## adsr
|
||||||
|
```
|
||||||
|
adsr(p1: float = 0.1, p2: float = 0.3, p3: float = 0.8, s: float = 0.8)
|
||||||
|
```
|
||||||
|
|
||||||
|
## constant
|
||||||
|
```
|
||||||
|
constant()
|
||||||
|
```
|
||||||
Reference in New Issue
Block a user