From a9f5bd679d3668687433d69a893f3dd279b826f3 Mon Sep 17 00:00:00 2001 From: Felix Roos Date: Sat, 21 May 2022 21:57:37 +0200 Subject: [PATCH] jsdoc voicings --- doc.json | 43 ++++++++++++++++++++++++++++++++++--- packages/tonal/tonal.mjs | 2 +- packages/tonal/voicings.mjs | 12 +++++++++++ 3 files changed, 53 insertions(+), 4 deletions(-) diff --git a/doc.json b/doc.json index 279769bc..cf49972a 100644 --- a/doc.json +++ b/doc.json @@ -2154,7 +2154,7 @@ "___s": true }, { - "comment": "/**\n * Change the pitch of each value by the given amount. Expects numbers or note strings as values.\n * The amount can be given as a number of semitones or as a string in interval short notation.\n * If you don't care about enharmonic correctness, just use numbers. Otherwise, pass the interval of\n * the form: ST where S is the degree number and T the type of interval with\n *\n * - M = major\n * - m = minor\n * - P = perfect\n * - A = augmented\n * - d = diminished\n *\n * Examples intervals:\n *\n * - 1P = unison = 0\n * - 3M = major third\n * - 3m = minor third\n * - 4P = perfect fourth\n * - 4A = augmented fourth\n * - 5P = perfect fifth\n * - 5d = diminished fifth\n *\n * @param {string | number} amount Either number of semitones or interval string.\n * @returns Pattern\n * @memberof Pattern\n * @name transpose\n * @example\n * \"c2 c3\".fast(2).transpose(\"<0 -2 5 3>\".slow(2)).transpose(0)\n * @example\n * \"c2 c3\".fast(2).transpose(\"<1P -2M 4P 3m>\".slow(2)).transpose(0)\n */", + "comment": "/**\n * Change the pitch of each value by the given amount. Expects numbers or note strings as values.\n * The amount can be given as a number of semitones or as a string in interval short notation.\n * If you don't care about enharmonic correctness, just use numbers. Otherwise, pass the interval of\n * the form: ST where S is the degree number and T the type of interval with\n *\n * - M = major\n * - m = minor\n * - P = perfect\n * - A = augmented\n * - d = diminished\n *\n * Examples intervals:\n *\n * - 1P = unison\n * - 3M = major third\n * - 3m = minor third\n * - 4P = perfect fourth\n * - 4A = augmented fourth\n * - 5P = perfect fifth\n * - 5d = diminished fifth\n *\n * @param {string | number} amount Either number of semitones or interval string.\n * @returns Pattern\n * @memberof Pattern\n * @name transpose\n * @example\n * \"c2 c3\".fast(2).transpose(\"<0 -2 5 3>\".slow(2)).transpose(0)\n * @example\n * \"c2 c3\".fast(2).transpose(\"<1P -2M 4P 3m>\".slow(2)).transpose(0)\n */", "meta": { "filename": "tonal.mjs", "lineno": 45, @@ -2162,7 +2162,7 @@ "path": "/home/felix/projects/strudel/packages/tonal", "code": {} }, - "description": "

Change the pitch of each value by the given amount. Expects numbers or note strings as values.\nThe amount can be given as a number of semitones or as a string in interval short notation.\nIf you don't care about enharmonic correctness, just use numbers. Otherwise, pass the interval of\nthe form: ST where S is the degree number and T the type of interval with

\n\n

Examples intervals:

\n", + "description": "

Change the pitch of each value by the given amount. Expects numbers or note strings as values.\nThe amount can be given as a number of semitones or as a string in interval short notation.\nIf you don't care about enharmonic correctness, just use numbers. Otherwise, pass the interval of\nthe form: ST where S is the degree number and T the type of interval with

\n\n

Examples intervals:

\n", "params": [ { "type": { @@ -2266,6 +2266,43 @@ "___id": "T000002R003683", "___s": true }, + { + "comment": "/**\n * Turns chord symbols into voicings, using the smoothest voice leading possible.\n * Uses [chord-voicings package](https://github.com/felixroos/chord-voicings#chord-voicings).\n *\n * @name voicings\n * @memberof Pattern\n * @param {range} range note range for possible voicings (optional, defaults to `['F3', 'A4']`)\n * @returns Pattern\n * @example\n * stack(\"\".voicings(), \"\")\n */", + "meta": { + "filename": "voicings.mjs", + "lineno": 34, + "columnno": 0, + "path": "/home/felix/projects/strudel/packages/tonal", + "code": {} + }, + "description": "

Turns chord symbols into voicings, using the smoothest voice leading possible.\nUses chord-voicings package.

", + "name": "voicings", + "memberof": "Pattern", + "params": [ + { + "type": { + "names": [ + "range" + ] + }, + "description": "

note range for possible voicings (optional, defaults to ['F3', 'A4'])

", + "name": "range" + } + ], + "returns": [ + { + "description": "

Pattern

" + } + ], + "examples": [ + "stack(\"\".voicings(), \"\")" + ], + "scope": "static", + "longname": "Pattern.voicings", + "kind": "member", + "___id": "T000002R003708", + "___s": true + }, { "kind": "package", "longname": "package:undefined", @@ -2345,7 +2382,7 @@ "/home/felix/projects/strudel/packages/xen/tunejs.js", "/home/felix/projects/strudel/packages/xen/xen.mjs" ], - "___id": "T000002R013976", + "___id": "T000002R013977", "___s": true } ] diff --git a/packages/tonal/tonal.mjs b/packages/tonal/tonal.mjs index 6b82255b..10140e78 100644 --- a/packages/tonal/tonal.mjs +++ b/packages/tonal/tonal.mjs @@ -56,7 +56,7 @@ function scaleOffset(scale, offset, note) { * * Examples intervals: * - * - 1P = unison = 0 + * - 1P = unison * - 3M = major third * - 3m = minor third * - 4P = perfect fourth diff --git a/packages/tonal/voicings.mjs b/packages/tonal/voicings.mjs index 5859c3bc..046fa02b 100644 --- a/packages/tonal/voicings.mjs +++ b/packages/tonal/voicings.mjs @@ -31,6 +31,18 @@ Pattern.prototype.fmapNested = function (func) { ); }; +/** + * Turns chord symbols into voicings, using the smoothest voice leading possible. + * Uses [chord-voicings package](https://github.com/felixroos/chord-voicings#chord-voicings). + * + * @name voicings + * @memberof Pattern + * @param {range} range note range for possible voicings (optional, defaults to `['F3', 'A4']`) + * @returns Pattern + * @example + * stack("".voicings(), "") + */ + Pattern.prototype.voicings = function (range) { let lastVoicing; if (!range?.length) {