From 8d9278419d59aa9b30761c3b0902a1a246566119 Mon Sep 17 00:00:00 2001 From: Felix Roos Date: Thu, 15 Jun 2023 20:19:31 +0200 Subject: [PATCH 1/3] fix: flatten scale lists --- packages/tonal/tonal.mjs | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/tonal/tonal.mjs b/packages/tonal/tonal.mjs index 854fd1b6..d67a58b3 100644 --- a/packages/tonal/tonal.mjs +++ b/packages/tonal/tonal.mjs @@ -154,6 +154,7 @@ export const scale = register('scale', function (scale, pat) { if (!isNaN(asNumber)) { // TODO: worth keeping for supporting ':' in (non-mininotation) strings? scale = scale.replaceAll(':', ' '); + scale = scale.replaceAll(',', ' '); let [tonic, scaleName] = Scale.tokenize(scale); const { pc, oct = 3 } = Note.get(tonic); note = scaleOffset(pc + ' ' + scaleName, asNumber, pc + oct); From a71c5957cc2b6f7638b9bf43f942ed41c74a5ec5 Mon Sep 17 00:00:00 2001 From: Felix Roos Date: Fri, 16 Jun 2023 14:23:39 +0200 Subject: [PATCH 2/3] fix: better fix --- packages/tonal/tonal.mjs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/tonal/tonal.mjs b/packages/tonal/tonal.mjs index d67a58b3..9ba8ad24 100644 --- a/packages/tonal/tonal.mjs +++ b/packages/tonal/tonal.mjs @@ -145,7 +145,7 @@ export const scaleTranspose = register('scaleTranspose', function (offset /* : n export const scale = register('scale', function (scale, pat) { // Supports ':' list syntax in mininotation if (Array.isArray(scale)) { - scale = scale.join(' '); + scale = scale.flat().join(' '); } return pat.withHap((hap) => { const isObject = typeof hap.value === 'object'; @@ -154,7 +154,6 @@ export const scale = register('scale', function (scale, pat) { if (!isNaN(asNumber)) { // TODO: worth keeping for supporting ':' in (non-mininotation) strings? scale = scale.replaceAll(':', ' '); - scale = scale.replaceAll(',', ' '); let [tonic, scaleName] = Scale.tokenize(scale); const { pc, oct = 3 } = Note.get(tonic); note = scaleOffset(pc + ' ' + scaleName, asNumber, pc + oct); From 2a449ad3c0acba09515ff8e641344baf399f10c6 Mon Sep 17 00:00:00 2001 From: Felix Roos Date: Sun, 18 Jun 2023 10:32:51 +0200 Subject: [PATCH 3/3] rename tonal api -> tonal functions --- website/src/config.ts | 2 +- website/src/pages/learn/accumulation.mdx | 2 +- website/src/pages/learn/tonal.mdx | 36 ++++++++++++------------ 3 files changed, 20 insertions(+), 20 deletions(-) diff --git a/website/src/config.ts b/website/src/config.ts index e32e243d..d65c54fc 100644 --- a/website/src/config.ts +++ b/website/src/config.ts @@ -87,7 +87,7 @@ export const SIDEBAR: Sidebar = { { text: 'Signals', link: 'learn/signals' }, { text: 'Conditional Modifiers', link: 'learn/conditional-modifiers' }, { text: 'Accumulation', link: 'learn/accumulation' }, - { text: 'Tonal Modifiers', link: 'learn/tonal' }, + { text: 'Tonal Functions', link: 'learn/tonal' }, ], Development: [ { text: 'REPL', link: 'technical-manual/repl' }, diff --git a/website/src/pages/learn/accumulation.mdx b/website/src/pages/learn/accumulation.mdx index 4940d791..9bd39278 100644 --- a/website/src/pages/learn/accumulation.mdx +++ b/website/src/pages/learn/accumulation.mdx @@ -32,4 +32,4 @@ import { JsDoc } from '../../docs/JsDoc'; -There are also [Tonal Modifiers](/learn/tonal). +There are also [Tonal Functions](/learn/tonal). diff --git a/website/src/pages/learn/tonal.mdx b/website/src/pages/learn/tonal.mdx index 33121ab7..658d6ad4 100644 --- a/website/src/pages/learn/tonal.mdx +++ b/website/src/pages/learn/tonal.mdx @@ -1,14 +1,29 @@ --- -title: Tonal API +title: Tonal Functions layout: ../../layouts/MainLayout.astro --- import { MiniRepl } from '../../docs/MiniRepl'; import { JsDoc } from '../../docs/JsDoc'; -# Tonal API +# Tonal Functions -The Tonal API, uses [tonaljs](https://github.com/tonaljs/tonal) to provide helpers for musical operations. +These functions use [tonaljs](https://github.com/tonaljs/tonal) to provide helpers for musical operations. + +### scale(name) + +Turns numbers into notes in the scale (zero indexed). Also sets scale for other scale operations, like scaleTranspose. + + + +Note that the scale root is octaved here. You can also omit the octave, then index zero will default to octave 3. + +All the available scale names can be found [here](https://github.com/tonaljs/tonal/blob/main/packages/scale-type/data.ts). ### transpose(semitones) @@ -22,21 +37,6 @@ Instead of numbers, scientific interval notation can be used as well: ".slow(2)).note()`} /> -### scale(name) - -Turns numbers into notes in the scale (zero indexed). Also sets scale for other scale operations, like scaleTranspose. - - - -Note that the scale root is octaved here. You can also omit the octave, then index zero will default to octave 3. - -All the available scale names can be found [here](https://github.com/tonaljs/tonal/blob/main/packages/scale-type/data.ts). - ### scaleTranspose(steps) Transposes notes inside the scale by the number of steps: