From 16fe871310b785275520ad355fa5e6e9870d4433 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Przemys=C5=82aw=20Pluta?= Date: Fri, 27 Mar 2020 14:16:54 +0100 Subject: [PATCH] Updated smnp.audio.synth (markdown) --- smnp.audio.synth.md | 55 +++++++++++++++++++++++++++++++++++++++------ 1 file changed, 48 insertions(+), 7 deletions(-) diff --git a/smnp.audio.synth.md b/smnp.audio.synth.md index c58a05a..aca27d3 100644 --- a/smnp.audio.synth.md +++ b/smnp.audio.synth.md @@ -1,8 +1,49 @@ # Functions -## `wave(config: map<>, notes: ...list)` -## `wave(...notes: list)` -## `synth(wave: list)` -## `synth(config: map<>, notes: ...list)` -## `synth(...notes: list)` -## `adsr(p1: float = 0.1, p2: float = 0.3, p3: float = 0.8, s: float = 0.8)` -## `constant()` \ No newline at end of file +## wave +``` +wave(config: map<>, notes: ...list) +wave(...notes: list) +``` +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. + +#### 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 | 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<>` | 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` - 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) #1` +synth(config: map<>, notes: ...list) #2 +synth(...notes: list) #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() +``` \ No newline at end of file