From fddb66d74c4130d480437d85365440bcac4bfd42 Mon Sep 17 00:00:00 2001 From: Matthew Kaney Date: Fri, 24 Jan 2025 16:45:29 -0500 Subject: [PATCH 1/4] Update list of undocumented functions --- jsdoc/undocumented.mjs | 2 +- undocumented.json | 108 ++++++++++++++++++++++++++++++----------- 2 files changed, 81 insertions(+), 29 deletions(-) diff --git a/jsdoc/undocumented.mjs b/jsdoc/undocumented.mjs index 9376a8b6a..4141b995a 100644 --- a/jsdoc/undocumented.mjs +++ b/jsdoc/undocumented.mjs @@ -10,7 +10,7 @@ function getExports(code) { let ast; try { ast = parse(code, { - ecmaVersion: 11, + ecmaVersion: 'latest', sourceType: 'module', }); } catch (err) { diff --git a/undocumented.json b/undocumented.json index 8a38f205f..ef9fad86e 100644 --- a/undocumented.json +++ b/undocumented.json @@ -61,7 +61,12 @@ "activateTheme" ], "/packages/codemirror/slider.mjs": [ - "acorn parse error: SyntaxError: undefined" + "sliderValues", + "SliderWidget", + "setSliderWidgets", + "updateSliderWidgets", + "sliderPlugin", + "sliderWithID" ], "/packages/codemirror/widget.mjs": [ "addWidget", @@ -78,19 +83,6 @@ "StrudelMirror" ], "/packages/codemirror/index.mjs": [], - "/packages/core/fraction.mjs": [ - "gcd", - "lcm" - ], - "/packages/core/timespan.mjs": [ - "TimeSpan" - ], - "/packages/core/hap.mjs": [ - "Hap" - ], - "/packages/core/state.mjs": [ - "State" - ], "/packages/core/logger.mjs": [ "logKey", "logger" @@ -103,7 +95,9 @@ "midiToFreq", "freqToMidi", "valueToMidi", + "getEventOffsetMs", "_mod", + "averageArray", "nanFallback", "getSoundIndex", "getPlayableNoteValue", @@ -112,6 +106,7 @@ "pipe", "compose", "flatten", + "id", "constant", "listRange", "curry", @@ -122,13 +117,35 @@ "fractionalArgs", "splitAt", "zipWith", + "pairs", "clamp", "sol2note", + "uniq", + "uniqsort", + "uniqsortr", "unicodeToBase64", "base64ToUnicode", "code2hash", "hash2code", - "objectMap" + "objectMap", + "cycleToSeconds", + "ClockCollator", + "getPerformanceTimeSeconds", + "keyAlias", + "getCurrentKeyboardState" + ], + "/packages/core/fraction.mjs": [ + "gcd", + "lcm" + ], + "/packages/core/timespan.mjs": [ + "TimeSpan" + ], + "/packages/core/hap.mjs": [ + "Hap" + ], + "/packages/core/state.mjs": [ + "State" ], "/packages/core/value.mjs": [ "unionWithObj", @@ -138,6 +155,7 @@ ], "/packages/core/drawLine.mjs": [], "/packages/core/pattern.mjs": [ + "calculateTactus", "setStringParser", "polyrhythm", "pr", @@ -150,7 +168,12 @@ "stackCentre", "stackBy", "fastcat", - "_polymeterListSteps", + "bind", + "innerBind", + "outerBind", + "squeezeBind", + "stepBind", + "polyBind", "set", "keep", "keepif", @@ -194,11 +217,21 @@ "bypass", "hsla", "hsl", + "_retime", + "_slices", + "_fitslice", + "_match", + "_polymeterListSteps", + "timeCat", + "s_extend", + "s_expand", + "s_contract", "loopat", "loopatcps" ], "/packages/core/controls.mjs": [ "createParam", + "registerControl", "sound", "src", "att", @@ -218,7 +251,6 @@ "loope", "ch", "phaserrate", - "phasr", "ph", "phs", "phc", @@ -242,7 +274,6 @@ "lpr", "hpr", "bpr", - "fanchor", "vibrato", "v", "vmod", @@ -392,15 +423,23 @@ "square2", "tri2", "time", + "mouseY", + "mouseX", + "randrun", + "shuffle", + "scramble", "_brandBy", "_irand", - "pickSqueeze", - "pickmodSqueeze", "__chooseWith", "randcat", "wrandcat", "perlinWith", - "degradeByWith" + "degradeByWith", + "_keyDown" + ], + "/packages/core/pick.mjs": [ + "pickSqueeze", + "pickmodSqueeze" ], "/packages/core/speak.mjs": [ "speak" @@ -440,13 +479,18 @@ "isTauri" ], "/packages/desktopbridge/midibridge.mjs": [], - "/packages/desktopbridge/oscbridge.mjs": [], + "/packages/desktopbridge/oscbridge.mjs": [ + "oscTriggerTauri" + ], "/packages/desktopbridge/index.mjs": [], "/packages/draw/draw.mjs": [ "getDrawContext", "cleanupDraw", "Framer", - "Drawer" + "Drawer", + "getComputedPropertyValue", + "getTheme", + "setTheme" ], "/packages/draw/animate.mjs": [ "x", @@ -472,6 +516,7 @@ "drawPianoroll" ], "/packages/draw/spiral.mjs": [], + "/packages/draw/pitchwheel.mjs": [], "/packages/draw/index.mjs": [], "/packages/midi/midi.mjs": [ "WebMidi", @@ -496,9 +541,7 @@ "/packages/repl/prebake.mjs": [ "prebake" ], - "/packages/repl/repl-component.mjs": [ - "acorn parse error: SyntaxError: undefined" - ], + "/packages/repl/repl-component.mjs": [], "/packages/repl/index.mjs": [], "/packages/soundfonts/gm.mjs": [], "/packages/soundfonts/fontloader.mjs": [ @@ -538,6 +581,7 @@ ], "/packages/superdough/helpers.mjs": [ "gainNode", + "getWorklet", "getParamADSR", "getCompressor", "getADSRValues", @@ -550,6 +594,8 @@ ], "/packages/superdough/sampler.mjs": [ "getCachedBuffer", + "getSampleInfo", + "getSampleBuffer", "getSampleBufferSource", "loadBuffer", "reverseBuffer", @@ -562,10 +608,15 @@ "soundMap", "registerSound", "getSound", + "setDefaultValue", + "getDefaultValue", + "setDefaultValues", + "resetDefaultValues", + "setVersionDefaults", "resetLoadedSounds", "setDefaultAudioContext", "getAudioContext", - "getWorklet", + "getAudioContextCurrentTime", "initAudio", "initAudioOnFirstClick", "initializeAudioOutput", @@ -589,7 +640,7 @@ "getOscillator" ], "/packages/superdough/zzfx_fork.mjs": [ - "acorn parse error: SyntaxError: undefined" + "buildSamples" ], "/packages/superdough/zzfx.mjs": [ "getZZFX", @@ -655,6 +706,7 @@ "drawTimeScope", "drawFrequencyScope" ], + "/packages/webaudio/spectrum.mjs": [], "/packages/webaudio/index.mjs": [], "/packages/xen/xen.mjs": [ "edo", From ecad4d0b11fb2488829a5af0e32bfc5ef8e3d65b Mon Sep 17 00:00:00 2001 From: Matthew Kaney Date: Tue, 28 Jan 2025 16:10:54 -0500 Subject: [PATCH 2/4] Fix issue with undocumented checker not acknowledging synonyms --- jsdoc/undocumented.mjs | 4 +- undocumented.json | 86 +----------------------------------------- 2 files changed, 2 insertions(+), 88 deletions(-) diff --git a/jsdoc/undocumented.mjs b/jsdoc/undocumented.mjs index 4141b995a..48bc1c8b2 100644 --- a/jsdoc/undocumented.mjs +++ b/jsdoc/undocumented.mjs @@ -49,9 +49,7 @@ function getExports(code) { } function isDocumented(name, docs) { - return docs.find( - (d) => d.name === name || d.tags?.find((t) => t.title === 'synonyms' && t.value.split(', ').includes(name)), - ); + return docs.find((d) => d.name === name || d.synonyms?.includes(name)); } async function getUndocumented(path, docs) { diff --git a/undocumented.json b/undocumented.json index ef9fad86e..73a443a84 100644 --- a/undocumented.json +++ b/undocumented.json @@ -157,9 +157,6 @@ "/packages/core/pattern.mjs": [ "calculateTactus", "setStringParser", - "polyrhythm", - "pr", - "pm", "nothing", "isPattern", "reify", @@ -167,7 +164,6 @@ "stackRight", "stackCentre", "stackBy", - "fastcat", "bind", "innerBind", "outerBind", @@ -197,23 +193,10 @@ "func", "compressSpan", "compressspan", - "fastgap", "focusSpan", "focusspan", - "density", - "sparsity", "zoomArc", "zoomarc", - "inv", - "juxby", - "echowith", - "stutWith", - "stutwith", - "iterback", - "slowchunk", - "slowChunk", - "chunkback", - "fastchunk", "bypass", "hsla", "hsl", @@ -222,7 +205,6 @@ "_fitslice", "_match", "_polymeterListSteps", - "timeCat", "s_extend", "s_expand", "s_contract", @@ -232,69 +214,20 @@ "/packages/core/controls.mjs": [ "createParam", "registerControl", - "sound", - "src", - "att", - "fmi", "fmrelease", "fmvelocity", "analyze", "fft", "dec", - "sus", - "rel", "hold", - "bandf", - "bp", - "bandq", - "loopb", - "loope", - "ch", "phaserrate", - "ph", - "phs", - "phc", - "phd", "phasdp", - "cutoff", - "ctf", - "lp", - "lpe", - "hpe", - "bpe", - "lpa", - "hpa", - "bpa", - "lpd", - "hpd", - "bpd", - "lps", - "hps", - "bps", - "lpr", - "hpr", - "bpr", - "vibrato", - "v", - "vmod", - "hcutoff", - "hp", - "hresonance", - "resonance", - "delayfb", - "dfb", - "delayt", - "dt", "lock", - "det", "fadeTime", "fadeOutTime", "fadeInTime", - "patt", - "pdec", "psustain", "psus", - "prel", "gate", "gat", "activeLabel", @@ -322,20 +255,11 @@ "offset", "octaves", "mode", - "rlp", - "rdim", - "rfade", - "ir", - "size", - "sz", - "rsize", - "dist", "compressorKnee", "compressorRatio", "compressorAttack", "compressorRelease", "waveloss", - "density", "expression", "sustainpedal", "tremolodepth", @@ -386,8 +310,6 @@ "uid", "val", "cps", - "legato", - "dur", "zrand", "curve", "deltaSlide", @@ -401,7 +323,6 @@ "zdelay", "tremolo", "zzfx", - "colour", "createParams", "ad", "ds", @@ -431,16 +352,11 @@ "_brandBy", "_irand", "__chooseWith", - "randcat", - "wrandcat", "perlinWith", "degradeByWith", "_keyDown" ], - "/packages/core/pick.mjs": [ - "pickSqueeze", - "pickmodSqueeze" - ], + "/packages/core/pick.mjs": [], "/packages/core/speak.mjs": [ "speak" ], From 58c88c56bae49f77bde950e399460b88fbf25b94 Mon Sep 17 00:00:00 2001 From: Matthew Kaney Date: Fri, 31 Jan 2025 16:10:51 -0500 Subject: [PATCH 3/4] Add documentation for some undocumented functions --- packages/core/pattern.mjs | 2 ++ packages/core/signal.mjs | 75 ++++++++++++++++++++++++++++++++++++--- undocumented.json | 16 +-------- 3 files changed, 73 insertions(+), 20 deletions(-) diff --git a/packages/core/pattern.mjs b/packages/core/pattern.mjs index 72d3b100e..5363d062f 100644 --- a/packages/core/pattern.mjs +++ b/packages/core/pattern.mjs @@ -2958,6 +2958,7 @@ export const striate = register('striate', function (n, pat) { /** * Makes the sample fit the given number of cycles by changing the speed. * @name loopAt + * @synonyms loopat * @memberof Pattern * @returns Pattern * @example @@ -3071,6 +3072,7 @@ export const fit = register('fit', (pat) => * given by a global clock and this function will be * deprecated/removed. * @name loopAtCps + * @synonyms loopatcps * @memberof Pattern * @returns Pattern * @example diff --git a/packages/core/signal.mjs b/packages/core/signal.mjs index 51aac609c..53507a841 100644 --- a/packages/core/signal.mjs +++ b/packages/core/signal.mjs @@ -10,23 +10,56 @@ import Fraction from './fraction.mjs'; import { id, keyAlias, getCurrentKeyboardState } from './util.mjs'; +/** + * A `signal` consisting of a constant value. Similar to `pure`, except that function + * creates a pattern with one event per cycle, whereas this pattern doesn't have an intrinsic + * structure. + * + * @param {*} value The constant value of the resulting pattern + * @returns Pattern + */ export function steady(value) { // A continuous value return new Pattern((state) => [new Hap(undefined, state.span, value)]); } +/** + * Creates a "signal", an unstructured pattern consisting of a single value that changes + * over time. + * + * + * @param {*} func + * @returns Pattern + */ export const signal = (func) => { const query = (state) => [new Hap(undefined, state.span, func(state.span.midpoint()))]; return new Pattern(query); }; +/** + * An inverse sawtooth signal between 1 and 0. + * + * @type {Pattern} + * @example + * note("*8") + * .clip(isaw.slow(2)) + * @example + * n(isaw.range(0,8).segment(8)) + * .scale('C major') + */ export const isaw = signal((t) => 1 - (t % 1)); + +/** + * Variant of `isaw` that ranges between 1 and -1. + * + * @type {Pattern} + */ export const isaw2 = isaw.toBipolar(); /** * A sawtooth signal between 0 and 1. * - * @return {Pattern} + * @type {Pattern} * @example * note("*8") * .clip(saw.slow(2)) @@ -36,8 +69,19 @@ export const isaw2 = isaw.toBipolar(); * */ export const saw = signal((t) => t % 1); + +/** + * Variant of `saw` that ranges between -1 and 1. + * + * @type {Pattern} + */ export const saw2 = saw.toBipolar(); +/** + * Variant of `sine` that ranges between -1 and 1. + * + * @type {Pattern} + */ export const sine2 = signal((t) => Math.sin(Math.PI * 2 * t)); /** @@ -61,6 +105,12 @@ export const sine = sine2.fromBipolar(); * */ export const cosine = sine._early(Fraction(1).div(4)); + +/** + * Variant of `cosine` that ranges between -1 and 1. + * + * @type {Pattern} + */ export const cosine2 = sine2._early(Fraction(1).div(4)); /** @@ -72,6 +122,12 @@ export const cosine2 = sine2._early(Fraction(1).div(4)); * */ export const square = signal((t) => Math.floor((t * 2) % 2)); + +/** + * Variant of `square` that ranges between -1 and 1. + * + * @type {Pattern} + */ export const square2 = square.toBipolar(); /** @@ -83,13 +139,25 @@ export const square2 = square.toBipolar(); * */ export const tri = fastcat(isaw, saw); + +/** + * Variant of `tri` that ranges between -1 and 1. + * + * @type {Pattern} + */ export const tri2 = fastcat(isaw2, saw2); +/** + * The current cycle count as a signal. + * + * @type {Pattern} + */ export const time = signal(id); /** * The mouse's x position value ranges from 0 to 1. * @name mousex + * @synonyms mouseX * @return {Pattern} * @example * n(mousex.segment(4).range(0,7)).scale("C:minor") @@ -99,6 +167,7 @@ export const time = signal(id); /** * The mouse's y position value ranges from 0 to 1. * @name mousey + * @synonyms mouseY * @return {Pattern} * @example * n(mousey.segment(4).range(0,7)).scale("C:minor") @@ -148,10 +217,6 @@ const timeToRandsPrime = (seed, n) => { const timeToRands = (t, n) => timeToRandsPrime(timeToIntSeed(t), n); -/** - * - */ - /** * A discrete pattern of numbers from 0 to n-1 * @example diff --git a/undocumented.json b/undocumented.json index 73a443a84..3363e3d3d 100644 --- a/undocumented.json +++ b/undocumented.json @@ -207,9 +207,7 @@ "_polymeterListSteps", "s_extend", "s_expand", - "s_contract", - "loopat", - "loopatcps" + "s_contract" ], "/packages/core/controls.mjs": [ "createParam", @@ -334,18 +332,6 @@ ], "/packages/core/zyklus.mjs": [], "/packages/core/signal.mjs": [ - "steady", - "signal", - "isaw", - "isaw2", - "saw2", - "sine2", - "cosine2", - "square2", - "tri2", - "time", - "mouseY", - "mouseX", "randrun", "shuffle", "scramble", From 2c7198a5f02ee3136511a581853abb2254a8fe69 Mon Sep 17 00:00:00 2001 From: Matthew Kaney Date: Fri, 31 Jan 2025 16:18:19 -0500 Subject: [PATCH 4/4] Add snapshot tests for new examples --- test/__snapshots__/examples.test.mjs.snap | 90 +++++++++++++++++++++++ 1 file changed, 90 insertions(+) diff --git a/test/__snapshots__/examples.test.mjs.snap b/test/__snapshots__/examples.test.mjs.snap index c8d538588..e34616de6 100644 --- a/test/__snapshots__/examples.test.mjs.snap +++ b/test/__snapshots__/examples.test.mjs.snap @@ -3863,6 +3863,96 @@ exports[`runs examples > example "iresponse" example index 0 1`] = ` ] `; +exports[`runs examples > example "isaw" example index 0 1`] = ` +[ + "[ 0/1 → 1/8 | note:c3 clip:0.96875 ]", + "[ 1/8 → 1/4 | note:eb3 clip:0.90625 ]", + "[ 1/8 → 1/4 | note:g3 clip:0.90625 ]", + "[ 1/4 → 3/8 | note:g2 clip:0.84375 ]", + "[ 3/8 → 1/2 | note:g3 clip:0.78125 ]", + "[ 3/8 → 1/2 | note:bb3 clip:0.78125 ]", + "[ 1/2 → 5/8 | note:c3 clip:0.71875 ]", + "[ 5/8 → 3/4 | note:eb3 clip:0.65625 ]", + "[ 5/8 → 3/4 | note:g3 clip:0.65625 ]", + "[ 3/4 → 7/8 | note:g2 clip:0.59375 ]", + "[ 7/8 → 1/1 | note:g3 clip:0.53125 ]", + "[ 7/8 → 1/1 | note:bb3 clip:0.53125 ]", + "[ 1/1 → 9/8 | note:c3 clip:0.46875 ]", + "[ 9/8 → 5/4 | note:eb3 clip:0.40625 ]", + "[ 9/8 → 5/4 | note:g3 clip:0.40625 ]", + "[ 5/4 → 11/8 | note:g2 clip:0.34375 ]", + "[ 11/8 → 3/2 | note:g3 clip:0.28125 ]", + "[ 11/8 → 3/2 | note:bb3 clip:0.28125 ]", + "[ 3/2 → 13/8 | note:c3 clip:0.21875 ]", + "[ 13/8 → 7/4 | note:eb3 clip:0.15625 ]", + "[ 13/8 → 7/4 | note:g3 clip:0.15625 ]", + "[ 7/4 → 15/8 | note:g2 clip:0.09375 ]", + "[ 15/8 → 2/1 | note:g3 clip:0.03125 ]", + "[ 15/8 → 2/1 | note:bb3 clip:0.03125 ]", + "[ 2/1 → 17/8 | note:c3 clip:0.96875 ]", + "[ 17/8 → 9/4 | note:eb3 clip:0.90625 ]", + "[ 17/8 → 9/4 | note:g3 clip:0.90625 ]", + "[ 9/4 → 19/8 | note:g2 clip:0.84375 ]", + "[ 19/8 → 5/2 | note:g3 clip:0.78125 ]", + "[ 19/8 → 5/2 | note:bb3 clip:0.78125 ]", + "[ 5/2 → 21/8 | note:c3 clip:0.71875 ]", + "[ 21/8 → 11/4 | note:eb3 clip:0.65625 ]", + "[ 21/8 → 11/4 | note:g3 clip:0.65625 ]", + "[ 11/4 → 23/8 | note:g2 clip:0.59375 ]", + "[ 23/8 → 3/1 | note:g3 clip:0.53125 ]", + "[ 23/8 → 3/1 | note:bb3 clip:0.53125 ]", + "[ 3/1 → 25/8 | note:c3 clip:0.46875 ]", + "[ 25/8 → 13/4 | note:eb3 clip:0.40625 ]", + "[ 25/8 → 13/4 | note:g3 clip:0.40625 ]", + "[ 13/4 → 27/8 | note:g2 clip:0.34375 ]", + "[ 27/8 → 7/2 | note:g3 clip:0.28125 ]", + "[ 27/8 → 7/2 | note:bb3 clip:0.28125 ]", + "[ 7/2 → 29/8 | note:c3 clip:0.21875 ]", + "[ 29/8 → 15/4 | note:eb3 clip:0.15625 ]", + "[ 29/8 → 15/4 | note:g3 clip:0.15625 ]", + "[ 15/4 → 31/8 | note:g2 clip:0.09375 ]", + "[ 31/8 → 4/1 | note:g3 clip:0.03125 ]", + "[ 31/8 → 4/1 | note:bb3 clip:0.03125 ]", +] +`; + +exports[`runs examples > example "isaw" example index 1 1`] = ` +[ + "[ 0/1 → 1/8 | note:D4 ]", + "[ 1/8 → 1/4 | note:C4 ]", + "[ 1/4 → 3/8 | note:B3 ]", + "[ 3/8 → 1/2 | note:A3 ]", + "[ 1/2 → 5/8 | note:G3 ]", + "[ 5/8 → 3/4 | note:F3 ]", + "[ 3/4 → 7/8 | note:E3 ]", + "[ 7/8 → 1/1 | note:D3 ]", + "[ 1/1 → 9/8 | note:D4 ]", + "[ 9/8 → 5/4 | note:C4 ]", + "[ 5/4 → 11/8 | note:B3 ]", + "[ 11/8 → 3/2 | note:A3 ]", + "[ 3/2 → 13/8 | note:G3 ]", + "[ 13/8 → 7/4 | note:F3 ]", + "[ 7/4 → 15/8 | note:E3 ]", + "[ 15/8 → 2/1 | note:D3 ]", + "[ 2/1 → 17/8 | note:D4 ]", + "[ 17/8 → 9/4 | note:C4 ]", + "[ 9/4 → 19/8 | note:B3 ]", + "[ 19/8 → 5/2 | note:A3 ]", + "[ 5/2 → 21/8 | note:G3 ]", + "[ 21/8 → 11/4 | note:F3 ]", + "[ 11/4 → 23/8 | note:E3 ]", + "[ 23/8 → 3/1 | note:D3 ]", + "[ 3/1 → 25/8 | note:D4 ]", + "[ 25/8 → 13/4 | note:C4 ]", + "[ 13/4 → 27/8 | note:B3 ]", + "[ 27/8 → 7/2 | note:A3 ]", + "[ 7/2 → 29/8 | note:G3 ]", + "[ 29/8 → 15/4 | note:F3 ]", + "[ 15/4 → 31/8 | note:E3 ]", + "[ 31/8 → 4/1 | note:D3 ]", +] +`; + exports[`runs examples > example "iter" example index 0 1`] = ` [ "[ 0/1 → 1/4 | note:A3 ]",