From 4df2cc30867b5ad4c4cf602028654768c8d4b3b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20=C5=BD=C3=A1ra?= Date: Mon, 3 Nov 2025 22:03:39 +0100 Subject: [PATCH 1/2] added docs for spaces in scale names --- packages/tonal/tonal.mjs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packages/tonal/tonal.mjs b/packages/tonal/tonal.mjs index 0dc468b2..427a66f4 100644 --- a/packages/tonal/tonal.mjs +++ b/packages/tonal/tonal.mjs @@ -229,6 +229,9 @@ function _getNearestScaleNote(scaleName, note, preferHigher = true) { * * A scale consists of a root note (e.g. `c4`, `c`, `f#`, `bb4`) followed by semicolon (':') and then a [scale type](https://github.com/tonaljs/tonal/blob/main/packages/scale-type/data.ts). * + * The scale name must be written without spaces (because it would be interpreted as a multi-step pattern otherwise). + * If your scale name includes spaces, replace them with colons. + * * The root note defaults to octave 3, if no octave number is given. * * @name scale @@ -250,6 +253,8 @@ function _getNearestScaleNote(scaleName, note, preferHigher = true) { * .s("piano") * @example * note("C1*16").transpose(irand(36)).scale('Cb2 major').scaleTranspose(3) + * @example + * n("[0 0] [1 2] [3 4] [5 6]").scale("C:major:blues") */ export const scale = register( 'scale', From a3f82f90a9c57033df1e9bf3f6ad377626d94b00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20=C5=BD=C3=A1ra?= Date: Thu, 6 Nov 2025 08:15:55 +0100 Subject: [PATCH 2/2] test fix --- test/__snapshots__/examples.test.mjs.snap | 37 +++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/test/__snapshots__/examples.test.mjs.snap b/test/__snapshots__/examples.test.mjs.snap index a27c5a6b..818c0270 100644 --- a/test/__snapshots__/examples.test.mjs.snap +++ b/test/__snapshots__/examples.test.mjs.snap @@ -9214,6 +9214,43 @@ exports[`runs examples > example "scale" example index 4 1`] = ` ] `; +exports[`runs examples > example "scale" example index 5 1`] = ` +[ + "[ 0/1 → 1/8 | note:C3 ]", + "[ 1/8 → 1/4 | note:C3 ]", + "[ 1/4 → 3/8 | note:D3 ]", + "[ 3/8 → 1/2 | note:Eb3 ]", + "[ 1/2 → 5/8 | note:E3 ]", + "[ 5/8 → 3/4 | note:G3 ]", + "[ 3/4 → 7/8 | note:A3 ]", + "[ 7/8 → 1/1 | note:C4 ]", + "[ 1/1 → 9/8 | note:C3 ]", + "[ 9/8 → 5/4 | note:C3 ]", + "[ 5/4 → 11/8 | note:D3 ]", + "[ 11/8 → 3/2 | note:Eb3 ]", + "[ 3/2 → 13/8 | note:E3 ]", + "[ 13/8 → 7/4 | note:G3 ]", + "[ 7/4 → 15/8 | note:A3 ]", + "[ 15/8 → 2/1 | note:C4 ]", + "[ 2/1 → 17/8 | note:C3 ]", + "[ 17/8 → 9/4 | note:C3 ]", + "[ 9/4 → 19/8 | note:D3 ]", + "[ 19/8 → 5/2 | note:Eb3 ]", + "[ 5/2 → 21/8 | note:E3 ]", + "[ 21/8 → 11/4 | note:G3 ]", + "[ 11/4 → 23/8 | note:A3 ]", + "[ 23/8 → 3/1 | note:C4 ]", + "[ 3/1 → 25/8 | note:C3 ]", + "[ 25/8 → 13/4 | note:C3 ]", + "[ 13/4 → 27/8 | note:D3 ]", + "[ 27/8 → 7/2 | note:Eb3 ]", + "[ 7/2 → 29/8 | note:E3 ]", + "[ 29/8 → 15/4 | note:G3 ]", + "[ 15/4 → 31/8 | note:A3 ]", + "[ 31/8 → 4/1 | note:C4 ]", +] +`; + exports[`runs examples > example "scaleTranspose" example index 0 1`] = ` [ "[ 0/1 → 1/2 | note:C3 ]",