From 243a350e2bc86129ef7c6508073824462f026d50 Mon Sep 17 00:00:00 2001 From: Felix Roos Date: Fri, 23 Dec 2022 17:32:25 +0100 Subject: [PATCH 1/3] fix: #317 --- website/src/repl/Reference.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/src/repl/Reference.jsx b/website/src/repl/Reference.jsx index 1460a8ac..b27809ef 100644 --- a/website/src/repl/Reference.jsx +++ b/website/src/repl/Reference.jsx @@ -1,7 +1,7 @@ import jsdocJson from '../../../doc.json'; const visibleFunctions = jsdocJson.docs .filter(({ name, description }) => name && !name.startsWith('_') && !!description) - .sort((a, b) => a.meta.filename.localeCompare(b.meta.filename) + a.name.localeCompare(b.name)); + .sort((a, b) => /* a.meta.filename.localeCompare(b.meta.filename) + */ a.name.localeCompare(b.name)); export function Reference() { return ( From 63fffd749308e12553c1e582a3b878f671932bce Mon Sep 17 00:00:00 2001 From: Felix Roos Date: Fri, 23 Dec 2022 17:57:01 +0100 Subject: [PATCH 2/3] docs: envelope functions --- packages/core/controls.mjs | 34 +++++++++++++++++++++++++++------- 1 file changed, 27 insertions(+), 7 deletions(-) diff --git a/packages/core/controls.mjs b/packages/core/controls.mjs index 7df34671..22e30f33 100644 --- a/packages/core/controls.mjs +++ b/packages/core/controls.mjs @@ -51,6 +51,7 @@ const generic_params = [ * * @name accelerate * @param {number | Pattern} amount acceleration. + * @superdirtOnly * @example * s("sax").accelerate("<0 1 2 4 8 16>").slow(2).osc() * @@ -75,19 +76,20 @@ const generic_params = [ * * @name amp * @param {number | Pattern} amount gain. + * @superdirtOnly * @example * s("bd*8").amp(".1*2 .5 .1*2 .5 .1 .5").osc() * */ ['f', 'amp', 'like @gain@, but linear.'], - // TODO: find out why 0 does not work, and it generally seems not right - /* + /** * A pattern of numbers to specify the attack time of an envelope applied to each sample. + * [More info about envelopes](/learn/synths-samples-effects/#envelope) * * @name attack * @param {number | Pattern} attack time in seconds. * @example - * n("c5 e5").s('superpiano').attack("<0 .1>").osc() + * note("c3 e3").attack("<0 .1 .5>") * */ [ @@ -107,18 +109,36 @@ const generic_params = [ */ ['f', 'bank', 'selects sound bank to use'], - // TODO: find out how this works? - /* - * Envelope decay time = the time it takes after the attack time to reach the sustain level. + /** + * Gain envelope decay time = the time it takes after the attack time to reach the sustain level. + * [More info about envelopes](/learn/synths-samples-effects/#envelope) * * @name decay * @param {number | Pattern} time decay time in seconds * @example - * s("sax").cut(1).decay("<.1 .2 .3 .4>").sustain(0).osc() + * note("c3 e3").decay("<.1 .2 .3 .4>").sustain(0) * */ ['f', 'decay', ''], + /** + * Gain envelope sustain level. [More info about envelopes](/learn/synths-samples-effects/#envelope) + * + * @name sustain + * @param {number | Pattern} gain sustain level between 0 and 1 + * @example + * note("c3 e3").decay(.2).sustain("<0 .1 .4 .6 1>") + * + */ ['f', 'sustain', ''], + /** + * Gain envelope release time. [More info about envelopes](/learn/synths-samples-effects/#envelope) + * + * @name release + * @param {number | Pattern} time release time in seconds + * @example + * note("c3 e3 g3 c4").release("<0 .1 .4 .6 1>/2") + * + */ [ 'f', 'release', From 8fe3fda27f6dd1c786b7f240690de9a5bd9f8461 Mon Sep 17 00:00:00 2001 From: Felix Roos Date: Fri, 23 Dec 2022 18:24:40 +0100 Subject: [PATCH 3/3] update snapshots --- test/__snapshots__/examples.test.mjs.snap | 60 +++++++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/test/__snapshots__/examples.test.mjs.snap b/test/__snapshots__/examples.test.mjs.snap index 716c6aa4..0bc774fb 100644 --- a/test/__snapshots__/examples.test.mjs.snap +++ b/test/__snapshots__/examples.test.mjs.snap @@ -257,6 +257,19 @@ exports[`runs examples > example "apply" example index 0 1`] = ` ] `; +exports[`runs examples > example "attack" example index 0 1`] = ` +[ + "[ 0/1 → 1/2 | note:c3 attack:0 ]", + "[ 1/2 → 1/1 | note:e3 attack:0 ]", + "[ 1/1 → 3/2 | note:c3 attack:0.1 ]", + "[ 3/2 → 2/1 | note:e3 attack:0.1 ]", + "[ 2/1 → 5/2 | note:c3 attack:0.5 ]", + "[ 5/2 → 3/1 | note:e3 attack:0.5 ]", + "[ 3/1 → 7/2 | note:c3 attack:0 ]", + "[ 7/2 → 4/1 | note:e3 attack:0 ]", +] +`; + exports[`runs examples > example "bandf" example index 0 1`] = ` [ "[ 0/1 → 1/2 | s:bd bandf:1000 ]", @@ -608,6 +621,19 @@ exports[`runs examples > example "cutoff" example index 0 1`] = ` ] `; +exports[`runs examples > example "decay" example index 0 1`] = ` +[ + "[ 0/1 → 1/2 | note:c3 decay:0.1 sustain:0 ]", + "[ 1/2 → 1/1 | note:e3 decay:0.1 sustain:0 ]", + "[ 1/1 → 3/2 | note:c3 decay:0.2 sustain:0 ]", + "[ 3/2 → 2/1 | note:e3 decay:0.2 sustain:0 ]", + "[ 2/1 → 5/2 | note:c3 decay:0.3 sustain:0 ]", + "[ 5/2 → 3/1 | note:e3 decay:0.3 sustain:0 ]", + "[ 3/1 → 7/2 | note:c3 decay:0.4 sustain:0 ]", + "[ 7/2 → 4/1 | note:e3 decay:0.4 sustain:0 ]", +] +`; + exports[`runs examples > example "degrade" example index 0 1`] = ` [ "[ 0/1 → 1/8 | s:hh ]", @@ -2319,6 +2345,27 @@ exports[`runs examples > example "rarely" example index 0 1`] = ` ] `; +exports[`runs examples > example "release" example index 0 1`] = ` +[ + "[ 0/1 → 1/4 | note:c3 release:0 ]", + "[ 1/4 → 1/2 | note:e3 release:0 ]", + "[ 1/2 → 3/4 | note:g3 release:0 ]", + "[ 3/4 → 1/1 | note:c4 release:0 ]", + "[ 1/1 → 5/4 | note:c3 release:0 ]", + "[ 5/4 → 3/2 | note:e3 release:0 ]", + "[ 3/2 → 7/4 | note:g3 release:0 ]", + "[ 7/4 → 2/1 | note:c4 release:0 ]", + "[ 2/1 → 9/4 | note:c3 release:0.1 ]", + "[ 9/4 → 5/2 | note:e3 release:0.1 ]", + "[ 5/2 → 11/4 | note:g3 release:0.1 ]", + "[ 11/4 → 3/1 | note:c4 release:0.1 ]", + "[ 3/1 → 13/4 | note:c3 release:0.1 ]", + "[ 13/4 → 7/2 | note:e3 release:0.1 ]", + "[ 7/2 → 15/4 | note:g3 release:0.1 ]", + "[ 15/4 → 4/1 | note:c4 release:0.1 ]", +] +`; + exports[`runs examples > example "resonance" example index 0 1`] = ` [ "[ 0/1 → 1/2 | s:bd cutoff:2000 resonance:0 ]", @@ -2935,6 +2982,19 @@ exports[`runs examples > example "superimpose" example index 0 1`] = ` ] `; +exports[`runs examples > example "sustain" example index 0 1`] = ` +[ + "[ 0/1 → 1/2 | note:c3 decay:0.2 sustain:0 ]", + "[ 1/2 → 1/1 | note:e3 decay:0.2 sustain:0 ]", + "[ 1/1 → 3/2 | note:c3 decay:0.2 sustain:0.1 ]", + "[ 3/2 → 2/1 | note:e3 decay:0.2 sustain:0.1 ]", + "[ 2/1 → 5/2 | note:c3 decay:0.2 sustain:0.4 ]", + "[ 5/2 → 3/1 | note:e3 decay:0.2 sustain:0.4 ]", + "[ 3/1 → 7/2 | note:c3 decay:0.2 sustain:0.6 ]", + "[ 7/2 → 4/1 | note:e3 decay:0.2 sustain:0.6 ]", +] +`; + exports[`runs examples > example "timeCat" example index 0 1`] = ` [ "[ 0/1 → 3/4 | note:e3 ]",