From 07bcaa65a9c35668701acd44f4bc1fed328cb674 Mon Sep 17 00:00:00 2001 From: "Jade (Rose) Rowland" Date: Fri, 6 Sep 2024 00:16:30 -0400 Subject: [PATCH 1/5] create meta params --- packages/core/controls.mjs | 43 +++++++++++++++++++++++++++++++++++ packages/superdough/synth.mjs | 5 ++-- 2 files changed, 46 insertions(+), 2 deletions(-) diff --git a/packages/core/controls.mjs b/packages/core/controls.mjs index 5a2752944..e0057c675 100644 --- a/packages/core/controls.mjs +++ b/packages/core/controls.mjs @@ -73,6 +73,49 @@ export function registerControl(names, ...aliases) { */ export const { s, sound } = registerControl(['s', 'n', 'gain'], 'sound'); +/** + * generic macro param for a sound synth + * + * @name z1 + * @synonyms z + * @param {number | Pattern} + * @example + * n(run(8)).scale("D:pentatonic").s("supersaw").x(".01 .75").release(0.5) + * + */ +export const { z1, z } = registerControl(['z1', 'z2', 'z3', 'z4'], 'z'); + +/** + * generic macro param for a sound synth + * + * @name z2 + * @param {number | Pattern} + * @example + * n(run(8)).scale("D:pentatonic").s("supersaw").x2("2 .7").release(0.5) + * + */ +export const { z2 } = registerControl('z2'); + +/** + * generic macro param for a sound synth + * + * @name z3 + * @param {number | Pattern} + * @example + * n(run(8)).scale("D:pentatonic").s("supersaw").x3(".1 .75").release(0.5) + * + */ +export const { z4 } = registerControl('z3'); + +/** + * generic macro param for a sound synth + * + * @name x4 + * @param {number | Pattern} + * + */ +export const { x4 } = registerControl('z4'); + /** * Define a custom webaudio node to use as a sound source. * diff --git a/packages/superdough/synth.mjs b/packages/superdough/synth.mjs index 621a6e598..113fb4e5e 100644 --- a/packages/superdough/synth.mjs +++ b/packages/superdough/synth.mjs @@ -73,8 +73,9 @@ export function registerSynthSounds() { 'supersaw', (begin, value, onended) => { const ac = getAudioContext(); - let { duration, n, unison = 5, spread = 0.6, detune } = value; - detune = detune ?? n ?? 0.18; + const {z1, z2, z3} = value; + let { duration, n, unison = z2 ?? 5, spread = z3 ?? 0.6, detune, } = value; + detune = detune ?? n ?? z1 ?? 0.18; const frequency = getFrequencyFromValue(value); const [attack, decay, sustain, release] = getADSRValues( From 1f7343f43d8c0b54c2581859c120305bd3ae2472 Mon Sep 17 00:00:00 2001 From: "Jade (Rose) Rowland" Date: Sat, 7 Sep 2024 12:31:43 -0400 Subject: [PATCH 2/5] normalize z param for supersaw --- packages/superdough/synth.mjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/superdough/synth.mjs b/packages/superdough/synth.mjs index 113fb4e5e..b2cc322b3 100644 --- a/packages/superdough/synth.mjs +++ b/packages/superdough/synth.mjs @@ -74,7 +74,7 @@ export function registerSynthSounds() { (begin, value, onended) => { const ac = getAudioContext(); const {z1, z2, z3} = value; - let { duration, n, unison = z2 ?? 5, spread = z3 ?? 0.6, detune, } = value; + let { duration, n, unison = z2 == null ? 5 : Math.round(z2 * 10), spread = z3 ?? 0.6, detune, } = value; detune = detune ?? n ?? z1 ?? 0.18; const frequency = getFrequencyFromValue(value); From 057bb42438d45849816818866251588f8f2acdb1 Mon Sep 17 00:00:00 2001 From: "Jade (Rose) Rowland" Date: Sat, 7 Sep 2024 12:32:55 -0400 Subject: [PATCH 3/5] formatting --- packages/superdough/synth.mjs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/superdough/synth.mjs b/packages/superdough/synth.mjs index b2cc322b3..a405138fb 100644 --- a/packages/superdough/synth.mjs +++ b/packages/superdough/synth.mjs @@ -73,8 +73,8 @@ export function registerSynthSounds() { 'supersaw', (begin, value, onended) => { const ac = getAudioContext(); - const {z1, z2, z3} = value; - let { duration, n, unison = z2 == null ? 5 : Math.round(z2 * 10), spread = z3 ?? 0.6, detune, } = value; + const { z1, z2, z3 } = value; + let { duration, n, unison = z2 == null ? 5 : Math.round(z2 * 10), spread = z3 ?? 0.6, detune } = value; detune = detune ?? n ?? z1 ?? 0.18; const frequency = getFrequencyFromValue(value); From 48bc3fca1386f83bd922bae75004c5ac2af5d9bb Mon Sep 17 00:00:00 2001 From: "Jade (Rose) Rowland" Date: Sat, 7 Sep 2024 12:33:43 -0400 Subject: [PATCH 4/5] fix typo --- packages/core/controls.mjs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/core/controls.mjs b/packages/core/controls.mjs index e0057c675..e7ba6379b 100644 --- a/packages/core/controls.mjs +++ b/packages/core/controls.mjs @@ -105,16 +105,16 @@ export const { z2 } = registerControl('z2'); * n(run(8)).scale("D:pentatonic").s("supersaw").x3(".1 .75").release(0.5) * */ -export const { z4 } = registerControl('z3'); +export const { z3 } = registerControl('z3'); /** * generic macro param for a sound synth * - * @name x4 + * @name z4 * @param {number | Pattern} * */ -export const { x4 } = registerControl('z4'); +export const { z4 } = registerControl('z4'); /** * Define a custom webaudio node to use as a sound source. From 44886ad90b08f9f5214bb2413bc03a28dfe23f12 Mon Sep 17 00:00:00 2001 From: "Jade (Rose) Rowland" Date: Sat, 7 Sep 2024 12:38:31 -0400 Subject: [PATCH 5/5] fix test --- packages/core/controls.mjs | 6 +- test/__snapshots__/examples.test.mjs.snap | 111 ++++++++++++++++++++++ 2 files changed, 114 insertions(+), 3 deletions(-) diff --git a/packages/core/controls.mjs b/packages/core/controls.mjs index e7ba6379b..8f202579d 100644 --- a/packages/core/controls.mjs +++ b/packages/core/controls.mjs @@ -80,7 +80,7 @@ export const { s, sound } = registerControl(['s', 'n', 'gain'], 'sound'); * @synonyms z * @param {number | Pattern} * @example - * n(run(8)).scale("D:pentatonic").s("supersaw").x(".01 .75").release(0.5) + * n(run(8)).scale("D:pentatonic").s("supersaw").z(".01 .75").release(0.5) * */ export const { z1, z } = registerControl(['z1', 'z2', 'z3', 'z4'], 'z'); @@ -91,7 +91,7 @@ export const { z1, z } = registerControl(['z1', 'z2', 'z3', 'z4'], 'z'); * @name z2 * @param {number | Pattern} * @example - * n(run(8)).scale("D:pentatonic").s("supersaw").x2("2 .7").release(0.5) + * n(run(8)).scale("D:pentatonic").s("supersaw").z2("2 .7").release(0.5) * */ export const { z2 } = registerControl('z2'); @@ -102,7 +102,7 @@ export const { z2 } = registerControl('z2'); * @name z3 * @param {number | Pattern} * @example - * n(run(8)).scale("D:pentatonic").s("supersaw").x3(".1 .75").release(0.5) + * n(run(8)).scale("D:pentatonic").s("supersaw").z3(".1 .75").release(0.5) * */ export const { z3 } = registerControl('z3'); diff --git a/test/__snapshots__/examples.test.mjs.snap b/test/__snapshots__/examples.test.mjs.snap index b34212ab1..c4f98ac2e 100644 --- a/test/__snapshots__/examples.test.mjs.snap +++ b/test/__snapshots__/examples.test.mjs.snap @@ -8597,6 +8597,117 @@ exports[`runs examples > example "xfade" example index 0 1`] = ` ] `; +exports[`runs examples > example "z1" example index 0 1`] = ` +[ + "[ 0/1 → 1/8 | note:D3 s:supersaw z1:0.01 release:0.5 ]", + "[ 1/8 → 1/4 | note:E3 s:supersaw z1:0.01 release:0.5 ]", + "[ 1/4 → 3/8 | note:F#3 s:supersaw z1:0.01 release:0.5 ]", + "[ 3/8 → 1/2 | note:A3 s:supersaw z1:0.01 release:0.5 ]", + "[ 1/2 → 5/8 | note:B3 s:supersaw z1:0.75 release:0.5 ]", + "[ 5/8 → 3/4 | note:D4 s:supersaw z1:0.75 release:0.5 ]", + "[ 3/4 → 7/8 | note:E4 s:supersaw z1:0.75 release:0.5 ]", + "[ 7/8 → 1/1 | note:F#4 s:supersaw z1:0.75 release:0.5 ]", + "[ 1/1 → 9/8 | note:D3 s:supersaw z1:0.01 release:0.5 ]", + "[ 9/8 → 5/4 | note:E3 s:supersaw z1:0.01 release:0.5 ]", + "[ 5/4 → 11/8 | note:F#3 s:supersaw z1:0.01 release:0.5 ]", + "[ 11/8 → 3/2 | note:A3 s:supersaw z1:0.01 release:0.5 ]", + "[ 3/2 → 13/8 | note:B3 s:supersaw z1:0.75 release:0.5 ]", + "[ 13/8 → 7/4 | note:D4 s:supersaw z1:0.75 release:0.5 ]", + "[ 7/4 → 15/8 | note:E4 s:supersaw z1:0.75 release:0.5 ]", + "[ 15/8 → 2/1 | note:F#4 s:supersaw z1:0.75 release:0.5 ]", + "[ 2/1 → 17/8 | note:D3 s:supersaw z1:0.01 release:0.5 ]", + "[ 17/8 → 9/4 | note:E3 s:supersaw z1:0.01 release:0.5 ]", + "[ 9/4 → 19/8 | note:F#3 s:supersaw z1:0.01 release:0.5 ]", + "[ 19/8 → 5/2 | note:A3 s:supersaw z1:0.01 release:0.5 ]", + "[ 5/2 → 21/8 | note:B3 s:supersaw z1:0.75 release:0.5 ]", + "[ 21/8 → 11/4 | note:D4 s:supersaw z1:0.75 release:0.5 ]", + "[ 11/4 → 23/8 | note:E4 s:supersaw z1:0.75 release:0.5 ]", + "[ 23/8 → 3/1 | note:F#4 s:supersaw z1:0.75 release:0.5 ]", + "[ 3/1 → 25/8 | note:D3 s:supersaw z1:0.01 release:0.5 ]", + "[ 25/8 → 13/4 | note:E3 s:supersaw z1:0.01 release:0.5 ]", + "[ 13/4 → 27/8 | note:F#3 s:supersaw z1:0.01 release:0.5 ]", + "[ 27/8 → 7/2 | note:A3 s:supersaw z1:0.01 release:0.5 ]", + "[ 7/2 → 29/8 | note:B3 s:supersaw z1:0.75 release:0.5 ]", + "[ 29/8 → 15/4 | note:D4 s:supersaw z1:0.75 release:0.5 ]", + "[ 15/4 → 31/8 | note:E4 s:supersaw z1:0.75 release:0.5 ]", + "[ 31/8 → 4/1 | note:F#4 s:supersaw z1:0.75 release:0.5 ]", +] +`; + +exports[`runs examples > example "z2" example index 0 1`] = ` +[ + "[ 0/1 → 1/8 | note:D3 s:supersaw z2:2 release:0.5 ]", + "[ 1/8 → 1/4 | note:E3 s:supersaw z2:2 release:0.5 ]", + "[ 1/4 → 3/8 | note:F#3 s:supersaw z2:2 release:0.5 ]", + "[ 3/8 → 1/2 | note:A3 s:supersaw z2:2 release:0.5 ]", + "[ 1/2 → 5/8 | note:B3 s:supersaw z2:0.7 release:0.5 ]", + "[ 5/8 → 3/4 | note:D4 s:supersaw z2:0.7 release:0.5 ]", + "[ 3/4 → 7/8 | note:E4 s:supersaw z2:0.7 release:0.5 ]", + "[ 7/8 → 1/1 | note:F#4 s:supersaw z2:0.7 release:0.5 ]", + "[ 1/1 → 9/8 | note:D3 s:supersaw z2:2 release:0.5 ]", + "[ 9/8 → 5/4 | note:E3 s:supersaw z2:2 release:0.5 ]", + "[ 5/4 → 11/8 | note:F#3 s:supersaw z2:2 release:0.5 ]", + "[ 11/8 → 3/2 | note:A3 s:supersaw z2:2 release:0.5 ]", + "[ 3/2 → 13/8 | note:B3 s:supersaw z2:0.7 release:0.5 ]", + "[ 13/8 → 7/4 | note:D4 s:supersaw z2:0.7 release:0.5 ]", + "[ 7/4 → 15/8 | note:E4 s:supersaw z2:0.7 release:0.5 ]", + "[ 15/8 → 2/1 | note:F#4 s:supersaw z2:0.7 release:0.5 ]", + "[ 2/1 → 17/8 | note:D3 s:supersaw z2:2 release:0.5 ]", + "[ 17/8 → 9/4 | note:E3 s:supersaw z2:2 release:0.5 ]", + "[ 9/4 → 19/8 | note:F#3 s:supersaw z2:2 release:0.5 ]", + "[ 19/8 → 5/2 | note:A3 s:supersaw z2:2 release:0.5 ]", + "[ 5/2 → 21/8 | note:B3 s:supersaw z2:0.7 release:0.5 ]", + "[ 21/8 → 11/4 | note:D4 s:supersaw z2:0.7 release:0.5 ]", + "[ 11/4 → 23/8 | note:E4 s:supersaw z2:0.7 release:0.5 ]", + "[ 23/8 → 3/1 | note:F#4 s:supersaw z2:0.7 release:0.5 ]", + "[ 3/1 → 25/8 | note:D3 s:supersaw z2:2 release:0.5 ]", + "[ 25/8 → 13/4 | note:E3 s:supersaw z2:2 release:0.5 ]", + "[ 13/4 → 27/8 | note:F#3 s:supersaw z2:2 release:0.5 ]", + "[ 27/8 → 7/2 | note:A3 s:supersaw z2:2 release:0.5 ]", + "[ 7/2 → 29/8 | note:B3 s:supersaw z2:0.7 release:0.5 ]", + "[ 29/8 → 15/4 | note:D4 s:supersaw z2:0.7 release:0.5 ]", + "[ 15/4 → 31/8 | note:E4 s:supersaw z2:0.7 release:0.5 ]", + "[ 31/8 → 4/1 | note:F#4 s:supersaw z2:0.7 release:0.5 ]", +] +`; + +exports[`runs examples > example "z3" example index 0 1`] = ` +[ + "[ 0/1 → 1/8 | note:D3 s:supersaw z3:0.1 release:0.5 ]", + "[ 1/8 → 1/4 | note:E3 s:supersaw z3:0.1 release:0.5 ]", + "[ 1/4 → 3/8 | note:F#3 s:supersaw z3:0.1 release:0.5 ]", + "[ 3/8 → 1/2 | note:A3 s:supersaw z3:0.1 release:0.5 ]", + "[ 1/2 → 5/8 | note:B3 s:supersaw z3:0.75 release:0.5 ]", + "[ 5/8 → 3/4 | note:D4 s:supersaw z3:0.75 release:0.5 ]", + "[ 3/4 → 7/8 | note:E4 s:supersaw z3:0.75 release:0.5 ]", + "[ 7/8 → 1/1 | note:F#4 s:supersaw z3:0.75 release:0.5 ]", + "[ 1/1 → 9/8 | note:D3 s:supersaw z3:0.1 release:0.5 ]", + "[ 9/8 → 5/4 | note:E3 s:supersaw z3:0.1 release:0.5 ]", + "[ 5/4 → 11/8 | note:F#3 s:supersaw z3:0.1 release:0.5 ]", + "[ 11/8 → 3/2 | note:A3 s:supersaw z3:0.1 release:0.5 ]", + "[ 3/2 → 13/8 | note:B3 s:supersaw z3:0.75 release:0.5 ]", + "[ 13/8 → 7/4 | note:D4 s:supersaw z3:0.75 release:0.5 ]", + "[ 7/4 → 15/8 | note:E4 s:supersaw z3:0.75 release:0.5 ]", + "[ 15/8 → 2/1 | note:F#4 s:supersaw z3:0.75 release:0.5 ]", + "[ 2/1 → 17/8 | note:D3 s:supersaw z3:0.1 release:0.5 ]", + "[ 17/8 → 9/4 | note:E3 s:supersaw z3:0.1 release:0.5 ]", + "[ 9/4 → 19/8 | note:F#3 s:supersaw z3:0.1 release:0.5 ]", + "[ 19/8 → 5/2 | note:A3 s:supersaw z3:0.1 release:0.5 ]", + "[ 5/2 → 21/8 | note:B3 s:supersaw z3:0.75 release:0.5 ]", + "[ 21/8 → 11/4 | note:D4 s:supersaw z3:0.75 release:0.5 ]", + "[ 11/4 → 23/8 | note:E4 s:supersaw z3:0.75 release:0.5 ]", + "[ 23/8 → 3/1 | note:F#4 s:supersaw z3:0.75 release:0.5 ]", + "[ 3/1 → 25/8 | note:D3 s:supersaw z3:0.1 release:0.5 ]", + "[ 25/8 → 13/4 | note:E3 s:supersaw z3:0.1 release:0.5 ]", + "[ 13/4 → 27/8 | note:F#3 s:supersaw z3:0.1 release:0.5 ]", + "[ 27/8 → 7/2 | note:A3 s:supersaw z3:0.1 release:0.5 ]", + "[ 7/2 → 29/8 | note:B3 s:supersaw z3:0.75 release:0.5 ]", + "[ 29/8 → 15/4 | note:D4 s:supersaw z3:0.75 release:0.5 ]", + "[ 15/4 → 31/8 | note:E4 s:supersaw z3:0.75 release:0.5 ]", + "[ 31/8 → 4/1 | note:F#4 s:supersaw z3:0.75 release:0.5 ]", +] +`; + exports[`runs examples > example "zoom" example index 0 1`] = ` [ "[ 0/1 → 1/6 | s:hh ]",