From 4d335002174223067fee0bed45d119e5ba9b2193 Mon Sep 17 00:00:00 2001 From: danigb Date: Sun, 4 Feb 2024 00:09:39 +0100 Subject: [PATCH 1/2] chore: bump versions --- .changeset/flat-games-sneeze.md | 52 ---------- .changeset/lovely-maps-promise.md | 6 -- .changeset/mean-dryers-compare.md | 7 -- .changeset/red-bags-scream.md | 7 -- .changeset/sweet-ants-leave.md | 5 - docs/CHANGELOG.md | 120 ++++++++++++++++++++++- packages/abc-notation/CHANGELOG.md | 8 ++ packages/abc-notation/package.json | 6 +- packages/array/package.json | 4 +- packages/chord-detect/CHANGELOG.md | 10 ++ packages/chord-detect/package.json | 8 +- packages/chord-dictionary/CHANGELOG.md | 6 ++ packages/chord-dictionary/package.json | 4 +- packages/chord-type/CHANGELOG.md | 9 ++ packages/chord-type/package.json | 6 +- packages/chord/CHANGELOG.md | 64 ++++++++++++ packages/chord/package.json | 16 +-- packages/core/CHANGELOG.md | 17 ++++ packages/core/package.json | 10 +- packages/interval/CHANGELOG.md | 14 +++ packages/interval/package.json | 8 +- packages/key/CHANGELOG.md | 10 ++ packages/key/package.json | 12 +-- packages/midi/CHANGELOG.md | 8 ++ packages/midi/package.json | 4 +- packages/mode/CHANGELOG.md | 12 +++ packages/mode/package.json | 10 +- packages/modules/CHANGELOG.md | 10 ++ packages/modules/package.json | 4 +- packages/note/CHANGELOG.md | 9 ++ packages/note/package.json | 6 +- packages/pcset/CHANGELOG.md | 8 ++ packages/pcset/package.json | 4 +- packages/pitch-distance/CHANGELOG.md | 11 +++ packages/pitch-distance/package.json | 8 +- packages/pitch-interval/CHANGELOG.md | 11 +++ packages/pitch-interval/package.json | 4 +- packages/pitch-note/CHANGELOG.md | 11 +++ packages/pitch-note/package.json | 4 +- packages/pitch/CHANGELOG.md | 6 ++ packages/pitch/package.json | 2 +- packages/progression/CHANGELOG.md | 11 +++ packages/progression/package.json | 8 +- packages/range/CHANGELOG.md | 6 ++ packages/range/package.json | 4 +- packages/roman-numeral/CHANGELOG.md | 8 ++ packages/roman-numeral/package.json | 4 +- packages/scale-dictionary/CHANGELOG.md | 6 ++ packages/scale-dictionary/package.json | 4 +- packages/scale-type/CHANGELOG.md | 9 ++ packages/scale-type/package.json | 6 +- packages/scale/CHANGELOG.md | 12 +++ packages/scale/package.json | 12 +-- packages/tonal/CHANGELOG.md | 107 +++++++++++--------- packages/tonal/package.json | 40 ++++---- packages/voice-leading/CHANGELOG.md | 6 ++ packages/voice-leading/package.json | 4 +- packages/voicing-dictionary/CHANGELOG.md | 9 ++ packages/voicing-dictionary/package.json | 8 +- packages/voicing/CHANGELOG.md | 13 +++ packages/voicing/package.json | 14 +-- 61 files changed, 596 insertions(+), 236 deletions(-) delete mode 100644 .changeset/flat-games-sneeze.md delete mode 100644 .changeset/lovely-maps-promise.md delete mode 100644 .changeset/mean-dryers-compare.md delete mode 100644 .changeset/red-bags-scream.md delete mode 100644 .changeset/sweet-ants-leave.md diff --git a/.changeset/flat-games-sneeze.md b/.changeset/flat-games-sneeze.md deleted file mode 100644 index ea1108e6..00000000 --- a/.changeset/flat-games-sneeze.md +++ /dev/null @@ -1,52 +0,0 @@ ---- -"@tonaljs/chord": major -"tonal": major ---- - -#### Breaking change: chord uses pitch classes, never notes with octaves - -- Breaking change: chords uses only pitch classes. Before `Chord.getChord('M', 'C4')` would consider `C4` to be the tonic and now is `C`` - -So **before**: - -```js -Chord.get("M", "C4"); // => -// { -// name: 'C4 major', -// tonic: 'C4', -// notes: [ 'C4', 'E4', 'G4' ] -// ... -// } -``` - -**Now**: - -```js -Chord.get("M", "C4"); // => -// { -// name: 'C major', -// tonic: 'C', -// notes: [ 'C', 'E', 'G' ] -// } -``` - -### Feature: slash chords - -- Chord now accepts a slash and a bass. The bass _must_ be a pitch class -- Chord properties include `bass` that is a pitch class that could or could not belong to the chord itself. - -Example: - -```js -Chord.get("Cmaj7/B"); -Chord.get("Eb/D"); -``` - -### Feature: chord `notes` - -Now `notes` property of a chord are always pitch classes, there's a new function to get the actual notes: - -```js -Chord.notes("Cmaj7", "C4"); // => ['C4', 'E4', 'G4', 'B4'] -Chord.notes("maj7", "D5"); // => ['D5', 'F#5', 'A5', 'C#6'] -``` diff --git a/.changeset/lovely-maps-promise.md b/.changeset/lovely-maps-promise.md deleted file mode 100644 index 75501f5b..00000000 --- a/.changeset/lovely-maps-promise.md +++ /dev/null @@ -1,6 +0,0 @@ ---- -"@tonaljs/interval": major -"tonal": major ---- - -Fix typo (breaking change): `substract` is now `subtract` diff --git a/.changeset/mean-dryers-compare.md b/.changeset/mean-dryers-compare.md deleted file mode 100644 index 167251ca..00000000 --- a/.changeset/mean-dryers-compare.md +++ /dev/null @@ -1,7 +0,0 @@ ---- -"@tonaljs/pitch-interval": major -"tonal": major -"@tonaljs/core": major ---- - -Breaking change: remove `NoInterval` interface. Return `Interval` type (with `emtpy: true`) when parsing invalid intervals. diff --git a/.changeset/red-bags-scream.md b/.changeset/red-bags-scream.md deleted file mode 100644 index 3bb85040..00000000 --- a/.changeset/red-bags-scream.md +++ /dev/null @@ -1,7 +0,0 @@ ---- -"@tonaljs/pitch-note": major -"tonal": major -"@tonaljs/core": major ---- - -Breaking change: `NoNote` interface is removed. Always return `Note` type (with `empty: true`) when parsing invalid notes. diff --git a/.changeset/sweet-ants-leave.md b/.changeset/sweet-ants-leave.md deleted file mode 100644 index 680a5dba..00000000 --- a/.changeset/sweet-ants-leave.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"@tonaljs/pitch": patch ---- - -Improve `isPitch` detection to accept `NaN` as values. diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 96ad85ca..572670c6 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -1,4 +1,122 @@ -# CHANGELOG +# tonal + +## 6.0.0 + +### Major Changes + +#### Breaking change: chord uses pitch classes, never notes with octaves + +Chords now uses only pitch classes. Before `Chord.getChord('M', 'C4')` would consider `C4` to be the tonic and now is `C`` + +So **before**: + +```js +Chord.get("M", "C4"); // => +// { +// name: 'C4 major', +// tonic: 'C4', +// notes: [ 'C4', 'E4', 'G4' ] +// ... +// } +``` + +**Now**: + +```js +Chord.get("M", "C4"); // => +// { +// name: 'C major', +// tonic: 'C', +// notes: [ 'C', 'E', 'G' ] +// } +``` + +#### Feature: slash chords + +- Chord now accepts a slash and a bass. The bass _must_ be a pitch class +- Chord properties include `bass` that is a pitch class that could or could not belong to the chord itself. + +Example: + +```js +Chord.get("Cmaj7/B"); +Chord.get("Eb/D"); +``` + +#### Feature: chord `notes` + +Now `notes` property of a chord are always pitch classes, there's a new function to get the actual notes: + +```js +Chord.notes("Cmaj7", "C4"); // => ['C4', 'E4', 'G4', 'B4'] +Chord.notes("maj7", "D5"); // => ['D5', 'F#5', 'A5', 'C#6'] +``` + +- 48fecc4: Fix typo (breaking change): `substract` is now `subtract` +- 48fecc4: Breaking change: remove `NoInterval` interface. Return `Interval` type (with `emtpy: true`) when parsing invalid intervals. +- 48fecc4: Breaking change: `NoNote` interface is removed. Always return `Note` type (with `empty: true`) when parsing invalid notes. + +### Patch Changes + +Updated dependencies + +## 5.2.x + +Updated dependencies + +## 5.2.0 + +### Minor Changes + +- Add `Pcset.notes()` function that returns the ordered pitch class notes of the given set + +### Patch Changes + +- Updated dependencies [f21525b] + +## 5.1.3 + +### Patch Changes + +- Named type was renamed to NamedPitch. Add old export for backwards compatibility +- Updated dependencies + +## 5.1.2 + +### Patch Changes + +- Move core into pitch modules +- Updated dependencies + - @tonaljs/core@4.10.2 + +## 5.1.1 + +### Patch Changes + +- Restructure code to use new `@tonaljs/pitch`. No changes to functionality +- Updated dependencies + - @tonaljs/core@4.10.1 + +## 5.1.0 + +### Minor Changes + +- Publish voicing packages. Now there a three new namespaces: + + ```ts + import { VoiceLeading, Voicing, VoicingDictionary } from "tonal"; + ``` + +- Updated dependencies [15017c0] + - @tonaljs/voicing-dictionary@5.0.0 + - @tonaljs/voice-leading@5.0.0 + - @tonaljs/voicing@5.0.0 + +## 5.0.1 + +- Add -maj7 chord alias +- Updated dependencies + - @tonaljs/chord-type@5.0.2 ## 5.0.0 diff --git a/packages/abc-notation/CHANGELOG.md b/packages/abc-notation/CHANGELOG.md index f80b4076..7132150e 100644 --- a/packages/abc-notation/CHANGELOG.md +++ b/packages/abc-notation/CHANGELOG.md @@ -1,5 +1,13 @@ # @tonaljs/abc-notation +## 4.8.3 + +### Patch Changes + +- Updated dependencies [48fecc4] + - @tonaljs/pitch-note@6.0.0 + - @tonaljs/pitch-distance@5.0.3 + ## 4.8.x ### Patch Changes diff --git a/packages/abc-notation/package.json b/packages/abc-notation/package.json index 361a8dd7..435f714e 100644 --- a/packages/abc-notation/package.json +++ b/packages/abc-notation/package.json @@ -1,6 +1,6 @@ { "name": "@tonaljs/abc-notation", - "version": "4.8.2", + "version": "4.8.3", "description": "Parse musical notes in abc notation", "main": "dist/index.js", "module": "dist/index.mjs", @@ -9,8 +9,8 @@ ], "types": "dist/index.d.ts", "dependencies": { - "@tonaljs/pitch-distance": "5.0.2", - "@tonaljs/pitch-note": "5.0.1" + "@tonaljs/pitch-distance": "5.0.3", + "@tonaljs/pitch-note": "6.0.0" }, "keywords": [ "note", diff --git a/packages/array/package.json b/packages/array/package.json index 85294a71..d202ed8e 100644 --- a/packages/array/package.json +++ b/packages/array/package.json @@ -1,6 +1,6 @@ { "name": "@tonaljs/array", - "version": "4.8.2", + "version": "4.8.3", "description": "Functions to work with arrays of tonal objects", "keywords": [ "array", @@ -15,7 +15,7 @@ ], "types": "dist/index.d.ts", "dependencies": { - "@tonaljs/pitch-note": "5.0.1" + "@tonaljs/pitch-note": "6.0.0" }, "author": "danigb@gmail.com", "license": "MIT", diff --git a/packages/chord-detect/CHANGELOG.md b/packages/chord-detect/CHANGELOG.md index c3b2369a..3ecbae17 100644 --- a/packages/chord-detect/CHANGELOG.md +++ b/packages/chord-detect/CHANGELOG.md @@ -1,5 +1,15 @@ # @tonaljs/chord-detect +## 4.8.5 + +### Patch Changes + +- Updated dependencies [48fecc4] +- Updated dependencies [48fecc4] + - @tonaljs/core@5.0.0 + - @tonaljs/chord-type@5.0.5 + - @tonaljs/pcset@4.9.2 + ## 4.8.4 ### Patch Changes diff --git a/packages/chord-detect/package.json b/packages/chord-detect/package.json index 5c876385..d0e95a93 100644 --- a/packages/chord-detect/package.json +++ b/packages/chord-detect/package.json @@ -1,6 +1,6 @@ { "name": "@tonaljs/chord-detect", - "version": "4.8.4", + "version": "4.8.5", "description": "Detect chord name based on note names", "keywords": [ "chord-detect", @@ -15,9 +15,9 @@ ], "types": "dist/index.d.ts", "dependencies": { - "@tonaljs/chord-type": "5.0.4", - "@tonaljs/core": "4.10.4", - "@tonaljs/pcset": "4.9.1" + "@tonaljs/chord-type": "5.0.5", + "@tonaljs/core": "5.0.0", + "@tonaljs/pcset": "4.9.2" }, "author": "danigb@gmail.com", "license": "MIT", diff --git a/packages/chord-dictionary/CHANGELOG.md b/packages/chord-dictionary/CHANGELOG.md index 895132a8..623f37fd 100644 --- a/packages/chord-dictionary/CHANGELOG.md +++ b/packages/chord-dictionary/CHANGELOG.md @@ -1,5 +1,11 @@ # @tonaljs/chord-dictionary +## 4.8.4 + +### Patch Changes + +- @tonaljs/chord-type@5.0.5 + ## 4.8.3 ### Patch Changes diff --git a/packages/chord-dictionary/package.json b/packages/chord-dictionary/package.json index 36c44bf2..9378ece9 100644 --- a/packages/chord-dictionary/package.json +++ b/packages/chord-dictionary/package.json @@ -1,6 +1,6 @@ { "name": "@tonaljs/chord-dictionary", - "version": "4.8.3", + "version": "4.8.4", "description": "A dictionary of musical chords", "keywords": [], "main": "dist/index.js", @@ -10,7 +10,7 @@ ], "types": "dist/index.d.ts", "dependencies": { - "@tonaljs/chord-type": "5.0.4" + "@tonaljs/chord-type": "5.0.5" }, "author": "danigb@gmail.com", "license": "MIT", diff --git a/packages/chord-type/CHANGELOG.md b/packages/chord-type/CHANGELOG.md index 4fe5c278..ca90cdfe 100644 --- a/packages/chord-type/CHANGELOG.md +++ b/packages/chord-type/CHANGELOG.md @@ -1,5 +1,14 @@ # @tonaljs/chord-type +## 5.0.5 + +### Patch Changes + +- Updated dependencies [48fecc4] +- Updated dependencies [48fecc4] + - @tonaljs/core@5.0.0 + - @tonaljs/pcset@4.9.2 + ## 5.0.4 ### Patch Changes diff --git a/packages/chord-type/package.json b/packages/chord-type/package.json index e55acbd3..b41da1e8 100644 --- a/packages/chord-type/package.json +++ b/packages/chord-type/package.json @@ -1,6 +1,6 @@ { "name": "@tonaljs/chord-type", - "version": "5.0.4", + "version": "5.0.5", "description": "A dictionary of musical chords", "keywords": [ "chord", @@ -17,8 +17,8 @@ ], "types": "dist/index.d.ts", "dependencies": { - "@tonaljs/core": "4.10.4", - "@tonaljs/pcset": "4.9.1" + "@tonaljs/core": "5.0.0", + "@tonaljs/pcset": "4.9.2" }, "author": "danigb@gmail.com", "license": "MIT", diff --git a/packages/chord/CHANGELOG.md b/packages/chord/CHANGELOG.md index 6fbd6ccc..21bd434e 100644 --- a/packages/chord/CHANGELOG.md +++ b/packages/chord/CHANGELOG.md @@ -1,5 +1,69 @@ # @tonaljs/chord +## 6.0.0 + +### Major Changes + +- 97f01d4: #### Breaking change: chord uses pitch classes, never notes with octaves + + - Breaking change: chords uses only pitch classes. Before `Chord.getChord('M', 'C4')` would consider `C4` to be the tonic and now is `C`` + + So **before**: + + ```js + Chord.get("M", "C4"); // => + // { + // name: 'C4 major', + // tonic: 'C4', + // notes: [ 'C4', 'E4', 'G4' ] + // ... + // } + ``` + + **Now**: + + ```js + Chord.get("M", "C4"); // => + // { + // name: 'C major', + // tonic: 'C', + // notes: [ 'C', 'E', 'G' ] + // } + ``` + + ### Feature: slash chords + + - Chord now accepts a slash and a bass. The bass _must_ be a pitch class + - Chord properties include `bass` that is a pitch class that could or could not belong to the chord itself. + + Example: + + ```js + Chord.get("Cmaj7/B"); + Chord.get("Eb/D"); + ``` + + ### Feature: chord `notes` + + Now `notes` property of a chord are always pitch classes, there's a new function to get the actual notes: + + ```js + Chord.notes("Cmaj7", "C4"); // => ['C4', 'E4', 'G4', 'B4'] + Chord.notes("maj7", "D5"); // => ['D5', 'F#5', 'A5', 'C#6'] + ``` + +### Patch Changes + +- Updated dependencies [48fecc4] +- Updated dependencies [48fecc4] + - @tonaljs/interval@5.0.0 + - @tonaljs/pitch-note@6.0.0 + - @tonaljs/pitch-distance@5.0.3 + - @tonaljs/chord-detect@4.8.5 + - @tonaljs/chord-type@5.0.5 + - @tonaljs/pcset@4.9.2 + - @tonaljs/scale-type@4.8.5 + ## 5.0.3 ### Patch Changes diff --git a/packages/chord/package.json b/packages/chord/package.json index adec7a12..34cb4ecb 100644 --- a/packages/chord/package.json +++ b/packages/chord/package.json @@ -1,6 +1,6 @@ { "name": "@tonaljs/chord", - "version": "5.0.3", + "version": "6.0.0", "description": "Musical chords and its relations", "keywords": [ "chord", @@ -16,14 +16,14 @@ ], "types": "dist/index.d.ts", "dependencies": { - "@tonaljs/chord-detect": "4.8.4", - "@tonaljs/chord-type": "5.0.4", + "@tonaljs/chord-detect": "4.8.5", + "@tonaljs/chord-type": "5.0.5", "@tonaljs/collection": "4.8.1", - "@tonaljs/interval": "^4.8.2", - "@tonaljs/pcset": "4.9.1", - "@tonaljs/pitch-distance": "5.0.2", - "@tonaljs/pitch-note": "5.0.3", - "@tonaljs/scale-type": "4.8.4" + "@tonaljs/interval": "^5.0.0", + "@tonaljs/pcset": "4.9.2", + "@tonaljs/pitch-distance": "5.0.3", + "@tonaljs/pitch-note": "6.0.0", + "@tonaljs/scale-type": "4.8.5" }, "author": "danigb@gmail.com", "license": "MIT", diff --git a/packages/core/CHANGELOG.md b/packages/core/CHANGELOG.md index 6897802a..17d29c98 100644 --- a/packages/core/CHANGELOG.md +++ b/packages/core/CHANGELOG.md @@ -1,5 +1,22 @@ # @tonaljs/core +## 5.0.0 + +### Major Changes + +- 48fecc4: Breaking change: remove `NoInterval` interface. Return `Interval` type (with `emtpy: true`) when parsing invalid intervals. +- 48fecc4: Breaking change: `NoNote` interface is removed. Always return `Note` type (with `empty: true`) when parsing invalid notes. + +### Patch Changes + +- Updated dependencies [48fecc4] +- Updated dependencies [48fecc4] +- Updated dependencies [48fecc4] + - @tonaljs/pitch-interval@6.0.0 + - @tonaljs/pitch-note@6.0.0 + - @tonaljs/pitch@5.0.2 + - @tonaljs/pitch-distance@5.0.3 + ## 4.10.4 ### Patch Changes diff --git a/packages/core/package.json b/packages/core/package.json index 17bbc700..4310f3d0 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -1,6 +1,6 @@ { "name": "@tonaljs/core", - "version": "4.10.4", + "version": "5.0.0", "description": "Music theory library", "keywords": [ "music", @@ -18,10 +18,10 @@ "access": "public" }, "dependencies": { - "@tonaljs/pitch": "5.0.1", - "@tonaljs/pitch-interval": "5.0.2", - "@tonaljs/pitch-distance": "5.0.2", - "@tonaljs/pitch-note": "5.0.3" + "@tonaljs/pitch": "5.0.2", + "@tonaljs/pitch-interval": "6.0.0", + "@tonaljs/pitch-distance": "5.0.3", + "@tonaljs/pitch-note": "6.0.0" }, "scripts": { "build": "tsup index.ts --sourcemap --dts --format esm,cjs" diff --git a/packages/interval/CHANGELOG.md b/packages/interval/CHANGELOG.md index 7d636f39..b1430998 100644 --- a/packages/interval/CHANGELOG.md +++ b/packages/interval/CHANGELOG.md @@ -1,5 +1,19 @@ # @tonaljs/interval +## 5.0.0 + +### Major Changes + +- 48fecc4: Fix typo (breaking change): `substract` is now `subtract` + +### Patch Changes + +- Updated dependencies [48fecc4] +- Updated dependencies [48fecc4] + - @tonaljs/pitch-interval@6.0.0 + - @tonaljs/pitch@5.0.2 + - @tonaljs/pitch-distance@5.0.3 + ## 4.8.2 ### Patch Changes diff --git a/packages/interval/package.json b/packages/interval/package.json index f4276317..2b09367d 100644 --- a/packages/interval/package.json +++ b/packages/interval/package.json @@ -1,6 +1,6 @@ { "name": "@tonaljs/interval", - "version": "4.8.2", + "version": "5.0.0", "description": "Parse and manipulate music intervals", "keywords": [ "interval", @@ -15,9 +15,9 @@ ], "types": "dist/index.d.ts", "dependencies": { - "@tonaljs/pitch": "^5.0.1", - "@tonaljs/pitch-distance": "^5.0.2", - "@tonaljs/pitch-interval": "^5.0.2" + "@tonaljs/pitch": "^5.0.2", + "@tonaljs/pitch-distance": "^5.0.3", + "@tonaljs/pitch-interval": "^6.0.0" }, "author": "danigb@gmail.com", "license": "MIT", diff --git a/packages/key/CHANGELOG.md b/packages/key/CHANGELOG.md index 1c585207..5184cf52 100644 --- a/packages/key/CHANGELOG.md +++ b/packages/key/CHANGELOG.md @@ -1,5 +1,15 @@ # @tonaljs/key +## 4.9.4 + +### Patch Changes + +- Updated dependencies [48fecc4] +- Updated dependencies [48fecc4] + - @tonaljs/core@5.0.0 + - @tonaljs/note@4.10.3 + - @tonaljs/roman-numeral@4.8.3 + ## 4.9.3 ### Patch Changes diff --git a/packages/key/package.json b/packages/key/package.json index 22429135..8a4778b9 100644 --- a/packages/key/package.json +++ b/packages/key/package.json @@ -1,6 +1,6 @@ { "name": "@tonaljs/key", - "version": "4.9.3", + "version": "4.9.4", "description": "Functions to work with musical keys", "keywords": [ "key", @@ -15,13 +15,13 @@ ], "types": "dist/index.d.ts", "dependencies": { - "@tonaljs/core": "4.10.4", - "@tonaljs/note": "4.10.2", - "@tonaljs/roman-numeral": "4.8.2" + "@tonaljs/core": "5.0.0", + "@tonaljs/note": "4.10.3", + "@tonaljs/roman-numeral": "4.8.3" }, "devDependencies": { - "@tonaljs/chord": "5.0.3", - "@tonaljs/scale": "4.12.4" + "@tonaljs/chord": "6.0.0", + "@tonaljs/scale": "4.12.5" }, "author": "danigb@gmail.com", "license": "MIT", diff --git a/packages/midi/CHANGELOG.md b/packages/midi/CHANGELOG.md index f8e70a54..a89967a2 100644 --- a/packages/midi/CHANGELOG.md +++ b/packages/midi/CHANGELOG.md @@ -1,5 +1,13 @@ # @tonaljs/midi +## 4.9.3 + +### Patch Changes + +- Updated dependencies [48fecc4] +- Updated dependencies [48fecc4] + - @tonaljs/core@5.0.0 + ## 4.9.2 ### Patch Changes diff --git a/packages/midi/package.json b/packages/midi/package.json index 4cbac1ea..1eef8699 100644 --- a/packages/midi/package.json +++ b/packages/midi/package.json @@ -1,6 +1,6 @@ { "name": "@tonaljs/midi", - "version": "4.9.2", + "version": "4.9.3", "description": "Functions to work with midi numbers", "keywords": [ "note", @@ -16,7 +16,7 @@ ], "types": "dist/index.d.ts", "dependencies": { - "@tonaljs/core": "4.10.4" + "@tonaljs/core": "5.0.0" }, "author": "danigb@gmail.com", "license": "MIT", diff --git a/packages/mode/CHANGELOG.md b/packages/mode/CHANGELOG.md index 4c1f6820..5c97cb4f 100644 --- a/packages/mode/CHANGELOG.md +++ b/packages/mode/CHANGELOG.md @@ -1,5 +1,17 @@ # @tonaljs/mode +## 4.8.4 + +### Patch Changes + +- Updated dependencies [48fecc4] +- Updated dependencies [48fecc4] +- Updated dependencies [48fecc4] + - @tonaljs/interval@5.0.0 + - @tonaljs/core@5.0.0 + - @tonaljs/pcset@4.9.2 + - @tonaljs/scale-type@4.8.5 + ## 4.8.3 ### Patch Changes diff --git a/packages/mode/package.json b/packages/mode/package.json index 09c7e048..d42cabd3 100644 --- a/packages/mode/package.json +++ b/packages/mode/package.json @@ -1,6 +1,6 @@ { "name": "@tonaljs/mode", - "version": "4.8.3", + "version": "4.8.4", "description": "Functions to work with musical modes", "keywords": [ "mode", @@ -16,10 +16,10 @@ "types": "dist/index.d.ts", "dependencies": { "@tonaljs/collection": "4.8.1", - "@tonaljs/core": "4.10.4", - "@tonaljs/interval": "4.8.2", - "@tonaljs/pcset": "4.9.1", - "@tonaljs/scale-type": "4.8.4" + "@tonaljs/core": "5.0.0", + "@tonaljs/interval": "5.0.0", + "@tonaljs/pcset": "4.9.2", + "@tonaljs/scale-type": "4.8.5" }, "author": "danigb@gmail.com", "license": "MIT", diff --git a/packages/modules/CHANGELOG.md b/packages/modules/CHANGELOG.md index b7269a47..fd5bf160 100644 --- a/packages/modules/CHANGELOG.md +++ b/packages/modules/CHANGELOG.md @@ -1,5 +1,15 @@ # @tonaljs/modules +## 4.8.4 + +### Patch Changes + +- Updated dependencies [97f01d4] +- Updated dependencies [48fecc4] +- Updated dependencies [48fecc4] +- Updated dependencies [48fecc4] + - tonal@6.0.0 + ## 4.8.3 ### Patch Changes diff --git a/packages/modules/package.json b/packages/modules/package.json index b844de6a..1c55e21c 100644 --- a/packages/modules/package.json +++ b/packages/modules/package.json @@ -1,6 +1,6 @@ { "name": "@tonaljs/modules", - "version": "4.8.3", + "version": "4.8.4", "description": "deprecated", "keywords": [], "main": "dist/index.js", @@ -10,7 +10,7 @@ ], "types": "dist/index.d.ts", "dependencies": { - "tonal": "5.2.1" + "tonal": "6.0.0" }, "author": "danigb@gmail.com", "license": "MIT", diff --git a/packages/note/CHANGELOG.md b/packages/note/CHANGELOG.md index 6c0431b3..2a0ec499 100644 --- a/packages/note/CHANGELOG.md +++ b/packages/note/CHANGELOG.md @@ -1,5 +1,14 @@ # @tonaljs/note +## 4.10.3 + +### Patch Changes + +- Updated dependencies [48fecc4] +- Updated dependencies [48fecc4] + - @tonaljs/core@5.0.0 + - @tonaljs/midi@4.9.3 + ## 4.10.2 ### Patch Changes diff --git a/packages/note/package.json b/packages/note/package.json index d837274f..309d08de 100644 --- a/packages/note/package.json +++ b/packages/note/package.json @@ -1,6 +1,6 @@ { "name": "@tonaljs/note", - "version": "4.10.2", + "version": "4.10.3", "description": "Parse and manipulate music notes in scientific notation", "keywords": [ "note", @@ -15,8 +15,8 @@ ], "types": "dist/index.d.ts", "dependencies": { - "@tonaljs/core": "4.10.4", - "@tonaljs/midi": "4.9.2" + "@tonaljs/core": "5.0.0", + "@tonaljs/midi": "4.9.3" }, "author": "danigb@gmail.com", "license": "MIT", diff --git a/packages/pcset/CHANGELOG.md b/packages/pcset/CHANGELOG.md index f5ea0086..087a4a14 100644 --- a/packages/pcset/CHANGELOG.md +++ b/packages/pcset/CHANGELOG.md @@ -1,5 +1,13 @@ # @tonaljs/pcset +## 4.9.2 + +### Patch Changes + +- Updated dependencies [48fecc4] +- Updated dependencies [48fecc4] + - @tonaljs/core@5.0.0 + ## 4.9.1 ### Patch Changes diff --git a/packages/pcset/package.json b/packages/pcset/package.json index 453eae56..e5a9edd6 100644 --- a/packages/pcset/package.json +++ b/packages/pcset/package.json @@ -1,6 +1,6 @@ { "name": "@tonaljs/pcset", - "version": "4.9.1", + "version": "4.9.2", "description": "Functions to work with midi numbers", "keywords": [ "note", @@ -17,7 +17,7 @@ "types": "dist/index.d.ts", "dependencies": { "@tonaljs/collection": "4.8.1", - "@tonaljs/core": "4.10.4" + "@tonaljs/core": "5.0.0" }, "author": "danigb@gmail.com", "license": "MIT", diff --git a/packages/pitch-distance/CHANGELOG.md b/packages/pitch-distance/CHANGELOG.md index bd5a6777..75dc8c09 100644 --- a/packages/pitch-distance/CHANGELOG.md +++ b/packages/pitch-distance/CHANGELOG.md @@ -1,5 +1,16 @@ # @tonaljs/pitch-distance +## 5.0.3 + +### Patch Changes + +- Updated dependencies [48fecc4] +- Updated dependencies [48fecc4] +- Updated dependencies [48fecc4] + - @tonaljs/pitch-interval@6.0.0 + - @tonaljs/pitch-note@6.0.0 + - @tonaljs/pitch@5.0.2 + ## 5.0.2 ### Patch Changes diff --git a/packages/pitch-distance/package.json b/packages/pitch-distance/package.json index 325adaf9..b78db720 100644 --- a/packages/pitch-distance/package.json +++ b/packages/pitch-distance/package.json @@ -1,6 +1,6 @@ { "name": "@tonaljs/pitch-distance", - "version": "5.0.2", + "version": "5.0.3", "description": "Parse intervals in shorthand notation", "keywords": [ "note", @@ -10,9 +10,9 @@ "shorthand notation" ], "dependencies": { - "@tonaljs/pitch": "5.0.1", - "@tonaljs/pitch-interval": "5.0.2", - "@tonaljs/pitch-note": "5.0.3" + "@tonaljs/pitch": "5.0.2", + "@tonaljs/pitch-interval": "6.0.0", + "@tonaljs/pitch-note": "6.0.0" }, "main": "dist/index.js", "module": "dist/index.mjs", diff --git a/packages/pitch-interval/CHANGELOG.md b/packages/pitch-interval/CHANGELOG.md index eb81328c..da70ca9c 100644 --- a/packages/pitch-interval/CHANGELOG.md +++ b/packages/pitch-interval/CHANGELOG.md @@ -1,5 +1,16 @@ # @tonaljs/pitch-interval +## 6.0.0 + +### Major Changes + +- 48fecc4: Breaking change: remove `NoInterval` interface. Return `Interval` type (with `emtpy: true`) when parsing invalid intervals. + +### Patch Changes + +- Updated dependencies [48fecc4] + - @tonaljs/pitch@5.0.2 + ## 5.0.2 ### Patch Changes diff --git a/packages/pitch-interval/package.json b/packages/pitch-interval/package.json index a66ea377..27737748 100644 --- a/packages/pitch-interval/package.json +++ b/packages/pitch-interval/package.json @@ -1,6 +1,6 @@ { "name": "@tonaljs/pitch-interval", - "version": "5.0.2", + "version": "6.0.0", "description": "Parse intervals in shorthand notation", "keywords": [ "note", @@ -10,7 +10,7 @@ "shorthand notation" ], "dependencies": { - "@tonaljs/pitch": "5.0.1" + "@tonaljs/pitch": "5.0.2" }, "main": "dist/index.js", "module": "dist/index.mjs", diff --git a/packages/pitch-note/CHANGELOG.md b/packages/pitch-note/CHANGELOG.md index 0eb604f5..733012b7 100644 --- a/packages/pitch-note/CHANGELOG.md +++ b/packages/pitch-note/CHANGELOG.md @@ -1,5 +1,16 @@ # @tonaljs/pitch-note +## 6.0.0 + +### Major Changes + +- 48fecc4: Breaking change: `NoNote` interface is removed. Always return `Note` type (with `empty: true`) when parsing invalid notes. + +### Patch Changes + +- Updated dependencies [48fecc4] + - @tonaljs/pitch@5.0.2 + ## 5.0.3 ### Patch Changes diff --git a/packages/pitch-note/package.json b/packages/pitch-note/package.json index 7d048cc5..124d2693 100644 --- a/packages/pitch-note/package.json +++ b/packages/pitch-note/package.json @@ -1,6 +1,6 @@ { "name": "@tonaljs/pitch-note", - "version": "5.0.3", + "version": "6.0.0", "description": "Parse intervals in shorthand notation", "keywords": [ "note", @@ -10,7 +10,7 @@ "shorthand notation" ], "dependencies": { - "@tonaljs/pitch": "5.0.1" + "@tonaljs/pitch": "5.0.2" }, "main": "dist/index.js", "module": "dist/index.mjs", diff --git a/packages/pitch/CHANGELOG.md b/packages/pitch/CHANGELOG.md index 086c69b5..dc314f70 100644 --- a/packages/pitch/CHANGELOG.md +++ b/packages/pitch/CHANGELOG.md @@ -1,5 +1,11 @@ # @tonaljs/pitch +## 5.0.2 + +### Patch Changes + +- 48fecc4: Improve `isPitch` detection to accept `NaN` as values. + ## 5.0.1 ### Patch Changes diff --git a/packages/pitch/package.json b/packages/pitch/package.json index b6a1a7b4..f6d50757 100644 --- a/packages/pitch/package.json +++ b/packages/pitch/package.json @@ -1,6 +1,6 @@ { "name": "@tonaljs/pitch", - "version": "5.0.1", + "version": "5.0.2", "description": "Pitch in (western) music theory", "keywords": [ "pitch", diff --git a/packages/progression/CHANGELOG.md b/packages/progression/CHANGELOG.md index f9bfa767..d3c0f1aa 100644 --- a/packages/progression/CHANGELOG.md +++ b/packages/progression/CHANGELOG.md @@ -1,5 +1,16 @@ # @tonaljs/progression +## 4.8.4 + +### Patch Changes + +- Updated dependencies [97f01d4] +- Updated dependencies [48fecc4] +- Updated dependencies [48fecc4] + - @tonaljs/chord@6.0.0 + - @tonaljs/core@5.0.0 + - @tonaljs/roman-numeral@4.8.3 + ## 4.8.3 ### Patch Changes diff --git a/packages/progression/package.json b/packages/progression/package.json index 90ca92eb..1434b6ea 100644 --- a/packages/progression/package.json +++ b/packages/progression/package.json @@ -1,6 +1,6 @@ { "name": "@tonaljs/progression", - "version": "4.8.3", + "version": "4.8.4", "description": "Build musical chord progressions", "keywords": [ "chord", @@ -16,9 +16,9 @@ ], "types": "dist/index.d.ts", "dependencies": { - "@tonaljs/chord": "5.0.3", - "@tonaljs/core": "4.10.4", - "@tonaljs/roman-numeral": "4.8.2" + "@tonaljs/chord": "6.0.0", + "@tonaljs/core": "5.0.0", + "@tonaljs/roman-numeral": "4.8.3" }, "author": "danigb@gmail.com", "license": "MIT", diff --git a/packages/range/CHANGELOG.md b/packages/range/CHANGELOG.md index 576480e3..91b3f439 100644 --- a/packages/range/CHANGELOG.md +++ b/packages/range/CHANGELOG.md @@ -1,5 +1,11 @@ # @tonaljs/range +## 4.8.4 + +### Patch Changes + +- @tonaljs/midi@4.9.3 + ## 4.8.3 ### Patch Changes diff --git a/packages/range/package.json b/packages/range/package.json index a67dc19e..7fbe3003 100644 --- a/packages/range/package.json +++ b/packages/range/package.json @@ -1,6 +1,6 @@ { "name": "@tonaljs/range", - "version": "4.8.3", + "version": "4.8.4", "description": "Create (musical) note ranges", "keywords": [ "range", @@ -16,7 +16,7 @@ "types": "dist/index.d.ts", "dependencies": { "@tonaljs/collection": "4.8.1", - "@tonaljs/midi": "4.9.2" + "@tonaljs/midi": "4.9.3" }, "author": "danigb@gmail.com", "license": "MIT", diff --git a/packages/roman-numeral/CHANGELOG.md b/packages/roman-numeral/CHANGELOG.md index 27f6ce0d..1c9769a9 100644 --- a/packages/roman-numeral/CHANGELOG.md +++ b/packages/roman-numeral/CHANGELOG.md @@ -1,5 +1,13 @@ # @tonaljs/roman-numeral +## 4.8.3 + +### Patch Changes + +- Updated dependencies [48fecc4] +- Updated dependencies [48fecc4] + - @tonaljs/core@5.0.0 + ## 4.8.2 ### Patch Changes diff --git a/packages/roman-numeral/package.json b/packages/roman-numeral/package.json index 7064a7f2..fbe6b140 100644 --- a/packages/roman-numeral/package.json +++ b/packages/roman-numeral/package.json @@ -1,6 +1,6 @@ { "name": "@tonaljs/roman-numeral", - "version": "4.8.2", + "version": "4.8.3", "description": "Parse and properties of roman numeral strings", "keywords": [ "roman-numeral", @@ -16,7 +16,7 @@ ], "types": "dist/index.d.ts", "dependencies": { - "@tonaljs/core": "4.10.4" + "@tonaljs/core": "5.0.0" }, "author": "danigb@gmail.com", "license": "MIT", diff --git a/packages/scale-dictionary/CHANGELOG.md b/packages/scale-dictionary/CHANGELOG.md index c7d2c4f8..d8a63003 100644 --- a/packages/scale-dictionary/CHANGELOG.md +++ b/packages/scale-dictionary/CHANGELOG.md @@ -1,5 +1,11 @@ # @tonaljs/scale-dictionary +## 4.8.3 + +### Patch Changes + +- @tonaljs/scale-type@4.8.5 + ## 4.8.2 ### Patch Changes diff --git a/packages/scale-dictionary/package.json b/packages/scale-dictionary/package.json index 39317477..39f6d06a 100644 --- a/packages/scale-dictionary/package.json +++ b/packages/scale-dictionary/package.json @@ -1,6 +1,6 @@ { "name": "@tonaljs/scale-dictionary", - "version": "4.8.2", + "version": "4.8.3", "description": "A dictionary of musical scales", "keywords": [], "main": "dist/index.js", @@ -10,7 +10,7 @@ ], "types": "dist/index.d.ts", "dependencies": { - "@tonaljs/scale-type": "4.8.4" + "@tonaljs/scale-type": "4.8.5" }, "author": "danigb@gmail.com", "license": "MIT", diff --git a/packages/scale-type/CHANGELOG.md b/packages/scale-type/CHANGELOG.md index f5e130f8..eb8a1391 100644 --- a/packages/scale-type/CHANGELOG.md +++ b/packages/scale-type/CHANGELOG.md @@ -1,5 +1,14 @@ # @tonaljs/scale-type +## 4.8.5 + +### Patch Changes + +- Updated dependencies [48fecc4] +- Updated dependencies [48fecc4] + - @tonaljs/core@5.0.0 + - @tonaljs/pcset@4.9.2 + ## 4.8.4 ### Patch Changes diff --git a/packages/scale-type/package.json b/packages/scale-type/package.json index 38bc7fc4..5ff00167 100644 --- a/packages/scale-type/package.json +++ b/packages/scale-type/package.json @@ -1,6 +1,6 @@ { "name": "@tonaljs/scale-type", - "version": "4.8.4", + "version": "4.8.5", "description": "A dictionary of musical scales", "keywords": [ "scale", @@ -16,8 +16,8 @@ ], "types": "dist/index.d.ts", "dependencies": { - "@tonaljs/core": "4.10.4", - "@tonaljs/pcset": "4.9.1" + "@tonaljs/core": "5.0.0", + "@tonaljs/pcset": "4.9.2" }, "author": "danigb@gmail.com", "license": "MIT", diff --git a/packages/scale/CHANGELOG.md b/packages/scale/CHANGELOG.md index e9f9fd8f..d14d742f 100644 --- a/packages/scale/CHANGELOG.md +++ b/packages/scale/CHANGELOG.md @@ -1,5 +1,17 @@ # @tonaljs/scale +## 4.12.5 + +### Patch Changes + +- Updated dependencies [48fecc4] +- Updated dependencies [48fecc4] + - @tonaljs/core@5.0.0 + - @tonaljs/chord-type@5.0.5 + - @tonaljs/note@4.10.3 + - @tonaljs/pcset@4.9.2 + - @tonaljs/scale-type@4.8.5 + ## 4.12.4 ### Patch Changes diff --git a/packages/scale/package.json b/packages/scale/package.json index 667a1a89..ce8e9cd2 100644 --- a/packages/scale/package.json +++ b/packages/scale/package.json @@ -1,6 +1,6 @@ { "name": "@tonaljs/scale", - "version": "4.12.4", + "version": "4.12.5", "description": "Musical scales and its relations", "keywords": [ "scale", @@ -16,12 +16,12 @@ ], "types": "dist/index.d.ts", "dependencies": { - "@tonaljs/chord-type": "5.0.4", + "@tonaljs/chord-type": "5.0.5", "@tonaljs/collection": "4.8.1", - "@tonaljs/core": "4.10.4", - "@tonaljs/note": "4.10.2", - "@tonaljs/pcset": "4.9.1", - "@tonaljs/scale-type": "4.8.4" + "@tonaljs/core": "5.0.0", + "@tonaljs/note": "4.10.3", + "@tonaljs/pcset": "4.9.2", + "@tonaljs/scale-type": "4.8.5" }, "author": "danigb@gmail.com", "license": "MIT", diff --git a/packages/tonal/CHANGELOG.md b/packages/tonal/CHANGELOG.md index ffcb96c1..572670c6 100644 --- a/packages/tonal/CHANGELOG.md +++ b/packages/tonal/CHANGELOG.md @@ -1,41 +1,78 @@ # tonal -## 5.2.1 +## 6.0.0 + +### Major Changes + +#### Breaking change: chord uses pitch classes, never notes with octaves + +Chords now uses only pitch classes. Before `Chord.getChord('M', 'C4')` would consider `C4` to be the tonic and now is `C`` + +So **before**: + +```js +Chord.get("M", "C4"); // => +// { +// name: 'C4 major', +// tonic: 'C4', +// notes: [ 'C4', 'E4', 'G4' ] +// ... +// } +``` + +**Now**: + +```js +Chord.get("M", "C4"); // => +// { +// name: 'C major', +// tonic: 'C', +// notes: [ 'C', 'E', 'G' ] +// } +``` + +#### Feature: slash chords + +- Chord now accepts a slash and a bass. The bass _must_ be a pitch class +- Chord properties include `bass` that is a pitch class that could or could not belong to the chord itself. + +Example: + +```js +Chord.get("Cmaj7/B"); +Chord.get("Eb/D"); +``` + +#### Feature: chord `notes` + +Now `notes` property of a chord are always pitch classes, there's a new function to get the actual notes: + +```js +Chord.notes("Cmaj7", "C4"); // => ['C4', 'E4', 'G4', 'B4'] +Chord.notes("maj7", "D5"); // => ['D5', 'F#5', 'A5', 'C#6'] +``` + +- 48fecc4: Fix typo (breaking change): `substract` is now `subtract` +- 48fecc4: Breaking change: remove `NoInterval` interface. Return `Interval` type (with `emtpy: true`) when parsing invalid intervals. +- 48fecc4: Breaking change: `NoNote` interface is removed. Always return `Note` type (with `empty: true`) when parsing invalid notes. ### Patch Changes -- Dependencies between packages are now fixed -- Updated dependencies - - @tonaljs/voicing-dictionary@5.0.2 - - @tonaljs/roman-numeral@4.8.2 - - @tonaljs/voice-leading@5.0.2 - - @tonaljs/abc-notation@4.8.2 - - @tonaljs/progression@4.8.3 - - @tonaljs/chord-type@5.0.4 - - @tonaljs/scale-type@4.8.4 - - @tonaljs/interval@4.8.2 - - @tonaljs/voicing@5.0.2 - - @tonaljs/array@4.8.2 - - @tonaljs/chord@5.0.3 - - @tonaljs/pcset@4.9.1 - - @tonaljs/range@4.8.3 - - @tonaljs/scale@4.12.4 - - @tonaljs/core@4.10.4 - - @tonaljs/midi@4.9.2 - - @tonaljs/mode@4.8.3 - - @tonaljs/note@4.10.2 - - @tonaljs/key@4.9.3 +Updated dependencies + +## 5.2.x + +Updated dependencies ## 5.2.0 ### Minor Changes -- f21525b: Add `Pcset.notes()` function that returns the ordered pitch class notes of the given set +- Add `Pcset.notes()` function that returns the ordered pitch class notes of the given set ### Patch Changes - Updated dependencies [f21525b] - - @tonaljs/pcset@4.9.0 ## 5.1.3 @@ -43,28 +80,6 @@ - Named type was renamed to NamedPitch. Add old export for backwards compatibility - Updated dependencies - - @tonaljs/abc-notation@4.8.1 - - @tonaljs/array@4.8.1 - - @tonaljs/chord@5.0.1 - - @tonaljs/chord-type@5.0.3 - - @tonaljs/collection@4.8.1 - - @tonaljs/core@4.10.3 - - @tonaljs/duration-value@4.8.1 - - @tonaljs/interval@4.8.1 - - @tonaljs/key@4.9.2 - - @tonaljs/midi@4.9.1 - - @tonaljs/mode@4.8.2 - - @tonaljs/note@4.10.1 - - @tonaljs/pcset@4.8.3 - - @tonaljs/progression@4.8.2 - - @tonaljs/range@4.8.2 - - @tonaljs/roman-numeral@4.8.1 - - @tonaljs/scale@4.12.3 - - @tonaljs/scale-type@4.8.3 - - @tonaljs/time-signature@4.8.1 - - @tonaljs/voice-leading@5.0.1 - - @tonaljs/voicing@5.0.1 - - @tonaljs/voicing-dictionary@5.0.1 ## 5.1.2 diff --git a/packages/tonal/package.json b/packages/tonal/package.json index 0b081ef0..1345881f 100644 --- a/packages/tonal/package.json +++ b/packages/tonal/package.json @@ -1,6 +1,6 @@ { "name": "tonal", - "version": "5.2.1", + "version": "6.0.0", "description": "tonaljs music theory library", "keywords": [ "music", @@ -16,28 +16,28 @@ ], "types": "dist/index.d.ts", "dependencies": { - "@tonaljs/abc-notation": "4.8.2", - "@tonaljs/array": "4.8.2", - "@tonaljs/chord-type": "5.0.4", - "@tonaljs/chord": "5.0.3", + "@tonaljs/abc-notation": "4.8.3", + "@tonaljs/array": "4.8.3", + "@tonaljs/chord-type": "5.0.5", + "@tonaljs/chord": "6.0.0", "@tonaljs/collection": "4.8.1", - "@tonaljs/core": "4.10.4", + "@tonaljs/core": "5.0.0", "@tonaljs/duration-value": "4.8.1", - "@tonaljs/interval": "4.8.2", - "@tonaljs/key": "4.9.3", - "@tonaljs/midi": "4.9.2", - "@tonaljs/mode": "4.8.3", - "@tonaljs/note": "4.10.2", - "@tonaljs/pcset": "4.9.1", - "@tonaljs/progression": "4.8.3", - "@tonaljs/range": "4.8.3", - "@tonaljs/roman-numeral": "4.8.2", - "@tonaljs/scale-type": "4.8.4", - "@tonaljs/scale": "4.12.4", + "@tonaljs/interval": "5.0.0", + "@tonaljs/key": "4.9.4", + "@tonaljs/midi": "4.9.3", + "@tonaljs/mode": "4.8.4", + "@tonaljs/note": "4.10.3", + "@tonaljs/pcset": "4.9.2", + "@tonaljs/progression": "4.8.4", + "@tonaljs/range": "4.8.4", + "@tonaljs/roman-numeral": "4.8.3", + "@tonaljs/scale-type": "4.8.5", + "@tonaljs/scale": "4.12.5", "@tonaljs/time-signature": "4.8.1", - "@tonaljs/voice-leading": "5.0.2", - "@tonaljs/voicing-dictionary": "5.0.2", - "@tonaljs/voicing": "5.0.2" + "@tonaljs/voice-leading": "5.0.3", + "@tonaljs/voicing-dictionary": "5.0.3", + "@tonaljs/voicing": "5.0.3" }, "author": "danigb@gmail.com", "license": "MIT", diff --git a/packages/voice-leading/CHANGELOG.md b/packages/voice-leading/CHANGELOG.md index 76140ae8..caa2deae 100644 --- a/packages/voice-leading/CHANGELOG.md +++ b/packages/voice-leading/CHANGELOG.md @@ -1,5 +1,11 @@ # @tonaljs/voice-leading +## 5.0.3 + +### Patch Changes + +- @tonaljs/note@4.10.3 + ## 5.0.2 ### Patch Changes diff --git a/packages/voice-leading/package.json b/packages/voice-leading/package.json index e79a52e8..8fe08dc2 100644 --- a/packages/voice-leading/package.json +++ b/packages/voice-leading/package.json @@ -1,6 +1,6 @@ { "name": "@tonaljs/voice-leading", - "version": "5.0.2", + "version": "5.0.3", "description": "Voice leading logic for transitions between voicings", "keywords": [ "chord", @@ -17,7 +17,7 @@ ], "types": "dist/index.d.ts", "dependencies": { - "@tonaljs/note": "4.10.2" + "@tonaljs/note": "4.10.3" }, "author": "felix91@gmail.com", "license": "MIT", diff --git a/packages/voicing-dictionary/CHANGELOG.md b/packages/voicing-dictionary/CHANGELOG.md index eb548c49..5569d5fc 100644 --- a/packages/voicing-dictionary/CHANGELOG.md +++ b/packages/voicing-dictionary/CHANGELOG.md @@ -1,5 +1,14 @@ # @tonaljs/voicing-dictionary +## 5.0.3 + +### Patch Changes + +- Updated dependencies [97f01d4] + - @tonaljs/chord@6.0.0 + - @tonaljs/note@4.10.3 + - @tonaljs/voice-leading@5.0.3 + ## 5.0.2 ### Patch Changes diff --git a/packages/voicing-dictionary/package.json b/packages/voicing-dictionary/package.json index d30eebc2..16f443eb 100644 --- a/packages/voicing-dictionary/package.json +++ b/packages/voicing-dictionary/package.json @@ -1,6 +1,6 @@ { "name": "@tonaljs/voicing-dictionary", - "version": "5.0.2", + "version": "5.0.3", "description": "Collections of chord voicings", "keywords": [ "chord", @@ -17,9 +17,9 @@ ], "types": "dist/index.d.ts", "dependencies": { - "@tonaljs/chord": "5.0.3", - "@tonaljs/note": "4.10.2", - "@tonaljs/voice-leading": "5.0.2" + "@tonaljs/chord": "6.0.0", + "@tonaljs/note": "4.10.3", + "@tonaljs/voice-leading": "5.0.3" }, "author": "felix91@gmail.com", "license": "MIT", diff --git a/packages/voicing/CHANGELOG.md b/packages/voicing/CHANGELOG.md index 0531b9e4..9ff59cce 100644 --- a/packages/voicing/CHANGELOG.md +++ b/packages/voicing/CHANGELOG.md @@ -1,5 +1,18 @@ # @tonaljs/voicing +## 5.0.3 + +### Patch Changes + +- Updated dependencies [97f01d4] +- Updated dependencies [48fecc4] + - @tonaljs/chord@6.0.0 + - @tonaljs/interval@5.0.0 + - @tonaljs/voicing-dictionary@5.0.3 + - @tonaljs/note@4.10.3 + - @tonaljs/range@4.8.4 + - @tonaljs/voice-leading@5.0.3 + ## 5.0.2 ### Patch Changes diff --git a/packages/voicing/package.json b/packages/voicing/package.json index df9c2378..d1c74553 100644 --- a/packages/voicing/package.json +++ b/packages/voicing/package.json @@ -1,6 +1,6 @@ { "name": "@tonaljs/voicing", - "version": "5.0.2", + "version": "5.0.3", "description": "Voicings and Voice Leading for Chords", "keywords": [ "chord", @@ -17,12 +17,12 @@ ], "types": "dist/index.d.ts", "dependencies": { - "@tonaljs/chord": "5.0.3", - "@tonaljs/interval": "4.8.2", - "@tonaljs/note": "4.10.2", - "@tonaljs/range": "4.8.3", - "@tonaljs/voice-leading": "5.0.2", - "@tonaljs/voicing-dictionary": "5.0.2" + "@tonaljs/chord": "6.0.0", + "@tonaljs/interval": "5.0.0", + "@tonaljs/note": "4.10.3", + "@tonaljs/range": "4.8.4", + "@tonaljs/voice-leading": "5.0.3", + "@tonaljs/voicing-dictionary": "5.0.3" }, "author": "felix91@gmail.com", "license": "MIT", From 2e63c8facd79b213fc29eaa07b784d6c03bd68f8 Mon Sep 17 00:00:00 2001 From: danigb Date: Sun, 4 Feb 2024 00:11:10 +0100 Subject: [PATCH 2/2] chore: browser version --- packages/tonal/browser/tonal.min.js | 2 +- packages/tonal/browser/tonal.min.js.map | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/tonal/browser/tonal.min.js b/packages/tonal/browser/tonal.min.js index dc32bbea..b990f2bb 100644 --- a/packages/tonal/browser/tonal.min.js +++ b/packages/tonal/browser/tonal.min.js @@ -1,2 +1,2 @@ -"use strict";var Tonal=(()=>{var It=Object.defineProperty;var je=Object.getOwnPropertyDescriptor;var xe=Object.getOwnPropertyNames;var Ce=Object.prototype.hasOwnProperty;var St=(t,n)=>{for(var e in n)It(t,e,{get:n[e],enumerable:!0})},Ee=(t,n,e,r)=>{if(n&&typeof n=="object"||typeof n=="function")for(let o of xe(n))!Ce.call(t,o)&&o!==e&&It(t,o,{get:()=>n[o],enumerable:!(r=je(n,o))||r.enumerable});return t};var De=t=>Ee(It({},"__esModule",{value:!0}),t);var fi={};St(fi,{AbcNotation:()=>In,Array:()=>wt,Chord:()=>Q,ChordDictionary:()=>ui,ChordType:()=>kt,Collection:()=>_n,Core:()=>ct,DurationValue:()=>Ln,Interval:()=>pt,Key:()=>re,Midi:()=>Un,Mode:()=>se,Note:()=>b,PcSet:()=>ci,Pcset:()=>Vt,Progression:()=>ce,Range:()=>At,RomanNumeral:()=>te,Scale:()=>pe,ScaleDictionary:()=>li,ScaleType:()=>zt,TimeSignature:()=>Pe,Tonal:()=>si,VoiceLeading:()=>Nt,Voicing:()=>Ne,VoicingDictionary:()=>Z,accToAlt:()=>q,altToAcc:()=>R,chroma:()=>mn,coordToInterval:()=>$,coordToNote:()=>ot,coordinates:()=>j,deprecate:()=>h,distance:()=>I,fillStr:()=>En,height:()=>Tt,interval:()=>d,isNamed:()=>st,isNamedPitch:()=>g,isPitch:()=>A,midi:()=>sn,note:()=>c,pitch:()=>F,stepToLetter:()=>Et,tokenizeInterval:()=>xt,tokenizeNote:()=>U,tonicIntervalsTransposer:()=>V,transpose:()=>f});function g(t){return t!==null&&typeof t=="object"&&"name"in t&&typeof t.name=="string"}var an=[0,2,4,5,7,9,11],mn=({step:t,alt:n})=>(an[t]+n+120)%12,Tt=({step:t,alt:n,oct:e,dir:r=1})=>r*(an[t]+n+12*(e===void 0?-100:e)),sn=t=>{let n=Tt(t);return t.oct!==void 0&&n>=-12&&n<=115?n+12:null};function A(t){return t!==null&&typeof t=="object"&&"step"in t&&typeof t.step=="number"&&"alt"in t&&typeof t.alt=="number"&&!isNaN(t.step)&&!isNaN(t.alt)}var cn=[0,2,4,-1,1,3,5],un=cn.map(t=>Math.floor(t*7/12));function j(t){let{step:n,alt:e,oct:r,dir:o=1}=t,a=cn[n]+7*e;if(r===void 0)return[o*a];let i=r-un[n]-4*e;return[o*a,o*i]}var _e=[3,0,4,1,5,2,6];function F(t){let[n,e,r]=t,o=_e[we(n)],a=Math.floor((n+1)/7);if(e===void 0)return{step:o,alt:a,dir:r};let i=e+4*a+un[o];return{step:o,alt:a,oct:i,dir:r}}function we(t){let n=(t+1)%7;return n<0?7+n:n}var ln=(t,n)=>Array(Math.abs(n)+1).join(t),jt=Object.freeze({empty:!0,name:"",num:NaN,q:"",type:"",step:NaN,alt:NaN,dir:NaN,simple:NaN,semitones:NaN,chroma:NaN,coord:[],oct:NaN}),Fe="([-+]?\\d+)(d{1,4}|m|M|P|A{1,4})",Re="(AA|A|P|M|m|d|dd)([-+]?\\d+)",Ve=new RegExp("^"+Fe+"|"+Re+"$");function xt(t){let n=Ve.exec(`${t}`);return n===null?["",""]:n[1]?[n[1],n[2]]:[n[4],n[3]]}var fn={};function d(t){return typeof t=="string"?fn[t]||(fn[t]=ke(t)):A(t)?d($e(t)):g(t)?d(t.name):jt}var dn=[0,2,4,5,7,9,11],pn="PMMPPMM";function ke(t){let n=xt(t);if(n[0]==="")return jt;let e=+n[0],r=n[1],o=(Math.abs(e)-1)%7,a=pn[o];if(a==="M"&&r==="P")return jt;let i=a==="M"?"majorable":"perfectable",m=""+e+r,s=e<0?-1:1,l=e===8||e===-8?e:s*(o+1),p=Oe(i,r),P=Math.floor((Math.abs(e)-1)/7),u=s*(dn[o]+p+12*P),y=(s*(dn[o]+p)%12+12)%12,M=j({step:o,alt:p,oct:P,dir:s});return{empty:!1,name:m,num:e,q:r,step:o,alt:p,dir:s,type:i,simple:l,semitones:u,chroma:y,coord:M,oct:P}}function $(t,n){let[e,r=0]=t,o=e*7+r*12<0,a=n||o?[-e,-r,-1]:[e,r,1];return d(F(a))}function Oe(t,n){return n==="M"&&t==="majorable"||n==="P"&&t==="perfectable"?0:n==="m"&&t==="majorable"?-1:/^A+$/.test(n)?n.length:/^d+$/.test(n)?-1*(t==="perfectable"?n.length:n.length+1):0}function $e(t){let{step:n,alt:e,oct:r=0,dir:o}=t;if(!o)return"";let a=n+1+7*r,i=a===0?n+1:a,m=o<0?"-":"",s=pn[n]==="M"?"majorable":"perfectable";return m+i+qe(s,e)}function qe(t,n){return n===0?t==="majorable"?"M":"P":n===-1&&t==="majorable"?"m":n>0?ln("A",n):ln("d",t==="perfectable"?n:n+1)}var Mn=(t,n)=>Array(Math.abs(n)+1).join(t),hn=Object.freeze({empty:!0,name:"",letter:"",acc:"",pc:"",step:NaN,alt:NaN,chroma:NaN,height:NaN,coord:[],midi:null,freq:null}),Pn=new Map,Et=t=>"CDEFGAB".charAt(t),R=t=>t<0?Mn("b",-t):Mn("#",t),q=t=>t[0]==="b"?-t.length:t.length;function c(t){let n=JSON.stringify(t),e=Pn.get(n);if(e)return e;let r=typeof t=="string"?ze(t):A(t)?c(Be(t)):g(t)?c(t.name):hn;return Pn.set(n,r),r}var Ge=/^([a-gA-G]?)(#{1,}|b{1,}|x{1,}|)(-?\d*)\s*(.*)$/;function U(t){let n=Ge.exec(t);return n?[n[1].toUpperCase(),n[2].replace(/x/g,"##"),n[3],n[4]]:["","","",""]}function ot(t){return c(F(t))}var Le=(t,n)=>(t%n+n)%n,Ct=[0,2,4,5,7,9,11];function ze(t){let n=U(t);if(n[0]===""||n[3]!=="")return hn;let e=n[0],r=n[1],o=n[2],a=(e.charCodeAt(0)+3)%7,i=q(r),m=o.length?+o:void 0,s=j({step:a,alt:i,oct:m}),l=e+r+o,p=e+r,P=(Ct[a]+i+120)%12,u=m===void 0?Le(Ct[a]+i,12)-12*99:Ct[a]+i+12*(m+1),y=u>=0&&u<=127?u:null,M=m===void 0?null:Math.pow(2,(u-69)/12)*440;return{empty:!1,acc:r,alt:i,chroma:P,coord:s,freq:M,height:u,letter:e,midi:y,name:l,oct:m,pc:p,step:a}}function Be(t){let{step:n,alt:e,oct:r}=t,o=Et(n);if(!o)return"";let a=o+R(e);return r||r===0?a+r:a}function f(t,n){let e=c(t),r=Array.isArray(n)?n:d(n).coord;if(e.empty||!r||r.length<2)return"";let o=e.coord,a=o.length===1?[o[0]+r[0]]:[o[0]+r[0],o[1]+r[1]];return ot(a).name}function V(t,n){let e=t.length;return r=>{if(!n)return"";let o=r<0?(e- -r%e)%e:r%e,a=Math.floor(r/e),i=f(n,[0,a]);return f(i,t[o])}}function I(t,n){let e=c(t),r=c(n);if(e.empty||r.empty)return"";let o=e.coord,a=r.coord,i=a[0]-o[0],m=o.length===2&&a.length===2?a[1]-o[1]:-Math.floor(i*7/12),s=r.height===e.height&&r.midi!==null&&e.midi!==null&&e.step>r.step;return $([i,m],s).name}var vn=(t,n)=>Array(Math.abs(n)+1).join(t),bn={empty:!0,name:"",pc:"",acc:""},yn=new Map,Ue=t=>"CDEFGAB".charAt(t),Xe=t=>t<0?vn("b",-t):vn("#",t),He=t=>t[0]==="b"?-t.length:t.length;function at(t){let n=JSON.stringify(t),e=yn.get(n);if(e)return e;let r=typeof t=="string"?Ze(t):A(t)?at(We(t)):g(t)?at(t.name):bn;return yn.set(n,r),r}var Ke=/^([a-gA-G]?)(#{1,}|b{1,}|x{1,}|)(-?\d*)\s*(.*)$/;function Je(t){let n=Ke.exec(t);return[n[1].toUpperCase(),n[2].replace(/x/g,"##"),n[3],n[4]]}var Qe=(t,n)=>(t%n+n)%n,Dt=[0,2,4,5,7,9,11];function Ze(t){let n=Je(t);if(n[0]===""||n[3]!=="")return bn;let e=n[0],r=n[1],o=n[2],a=(e.charCodeAt(0)+3)%7,i=He(r),m=o.length?+o:void 0,s=j({step:a,alt:i,oct:m}),l=e+r+o,p=e+r,P=(Dt[a]+i+120)%12,u=m===void 0?Qe(Dt[a]+i,12)-12*99:Dt[a]+i+12*(m+1),y=u>=0&&u<=127?u:null,M=m===void 0?null:Math.pow(2,(u-69)/12)*440;return{empty:!1,acc:r,alt:i,chroma:P,coord:s,freq:M,height:u,letter:e,midi:y,name:l,oct:m,pc:p,step:a}}function We(t){let{step:n,alt:e,oct:r}=t,o=Ue(n);if(!o)return"";let a=o+Xe(e);return r||r===0?a+r:a}var gn=(t,n)=>Array(n+1).join(t),Ye=/^(_{1,}|=|\^{1,}|)([abcdefgABCDEFG])([,']*)$/;function An(t){let n=Ye.exec(t);return n?[n[1],n[2],n[3]]:["","",""]}function it(t){let[n,e,r]=An(t);if(e==="")return"";let o=4;for(let i=0;i96?e.toUpperCase()+a+(o+1):e+a+o}function Nn(t){let n=at(t);if(n.empty||!n.oct&&n.oct!==0)return"";let{letter:e,acc:r,oct:o}=n,a=r[0]==="b"?r.replace(/b/g,"_"):r.replace(/#/g,"^"),i=o>4?e.toLowerCase():e,m=o===5?"":o>4?gn("'",o-5):gn(",",4-o);return a+i+m}function tr(t,n){return Nn(f(it(t),n))}function nr(t,n){return I(it(t),it(n))}var In={abcToScientificNotation:it,scientificToAbcNotation:Nn,tokenize:An,transpose:tr,distance:nr};var wt={};St(wt,{compact:()=>pr,permutations:()=>Cn,range:()=>fr,rotate:()=>dr,shuffle:()=>Pr,sortedNoteNames:()=>xn,sortedUniqNoteNames:()=>Mr});var Sn=(t,n)=>Array(Math.abs(n)+1).join(t),jn={empty:!0,name:"",pc:"",acc:""},Tn=new Map,er=t=>"CDEFGAB".charAt(t),rr=t=>t<0?Sn("b",-t):Sn("#",t),or=t=>t[0]==="b"?-t.length:t.length;function mt(t){let n=JSON.stringify(t),e=Tn.get(n);if(e)return e;let r=typeof t=="string"?sr(t):A(t)?mt(cr(t)):g(t)?mt(t.name):jn;return Tn.set(n,r),r}var ar=/^([a-gA-G]?)(#{1,}|b{1,}|x{1,}|)(-?\d*)\s*(.*)$/;function ir(t){let n=ar.exec(t);return[n[1].toUpperCase(),n[2].replace(/x/g,"##"),n[3],n[4]]}var mr=(t,n)=>(t%n+n)%n,_t=[0,2,4,5,7,9,11];function sr(t){let n=ir(t);if(n[0]===""||n[3]!=="")return jn;let e=n[0],r=n[1],o=n[2],a=(e.charCodeAt(0)+3)%7,i=or(r),m=o.length?+o:void 0,s=j({step:a,alt:i,oct:m}),l=e+r+o,p=e+r,P=(_t[a]+i+120)%12,u=m===void 0?mr(_t[a]+i,12)-12*99:_t[a]+i+12*(m+1),y=u>=0&&u<=127?u:null,M=m===void 0?null:Math.pow(2,(u-69)/12)*440;return{empty:!1,acc:r,alt:i,chroma:P,coord:s,freq:M,height:u,letter:e,midi:y,name:l,oct:m,pc:p,step:a}}function cr(t){let{step:n,alt:e,oct:r}=t,o=er(n);if(!o)return"";let a=o+rr(e);return r||r===0?a+r:a}function ur(t,n){let e=[];for(;n--;e[n]=n+t);return e}function lr(t,n){let e=[];for(;n--;e[n]=t-n);return e}function fr(t,n){return tn===0||n)}function xn(t){return t.map(e=>mt(e)).filter(e=>!e.empty).sort((e,r)=>e.height-r.height).map(e=>e.name)}function Mr(t){return xn(t).filter((n,e,r)=>e===0||n!==r[e-1])}function Pr(t,n=Math.random){let e,r,o=t.length;for(;o;)e=Math.floor(n()*o--),r=t[o],t[o]=t[e],t[e]=r;return t}function Cn(t){return t.length===0?[[]]:Cn(t.slice(1)).reduce((n,e)=>n.concat(t.map((r,o)=>{let a=e.slice();return a.splice(o,0,t[0]),a})),[])}var ct={};St(ct,{accToAlt:()=>q,altToAcc:()=>R,chroma:()=>mn,coordToInterval:()=>$,coordToNote:()=>ot,coordinates:()=>j,deprecate:()=>h,distance:()=>I,fillStr:()=>En,height:()=>Tt,interval:()=>d,isNamed:()=>st,isNamedPitch:()=>g,isPitch:()=>A,midi:()=>sn,note:()=>c,pitch:()=>F,stepToLetter:()=>Et,tokenizeInterval:()=>xt,tokenizeNote:()=>U,tonicIntervalsTransposer:()=>V,transpose:()=>f});var En=(t,n)=>Array(Math.abs(n)+1).join(t);function h(t,n,e){return function(...r){return console.warn(`${t} is deprecated. Use ${n}.`),e.apply(this,r)}}var st=h("isNamed","isNamedPitch",g);function hr(t,n){let e=[];for(;n--;e[n]=n+t);return e}function vr(t,n){let e=[];for(;n--;e[n]=t-n);return e}function G(t,n){return tn===0||n)}function yr(t,n=Math.random){let e,r,o=t.length;for(;o;)e=Math.floor(n()*o--),r=t[o],t[o]=t[e],t[e]=r;return t}function Dn(t){return t.length===0?[[]]:Dn(t.slice(1)).reduce((n,e)=>n.concat(t.map((r,o)=>{let a=e.slice();return a.splice(o,0,t[0]),a})),[])}var _n={compact:W,permutations:Dn,range:G,rotate:D,shuffle:yr};var x={empty:!0,name:"",setNum:0,chroma:"000000000000",normalized:"000000000000",intervals:[]},Ft=t=>Number(t).toString(2).padStart(12,"0"),wn=t=>parseInt(t,2),br=/^[01]{12}$/;function ut(t){return br.test(t)}var gr=t=>typeof t=="number"&&t>=0&&t<=4095,Ar=t=>t&&ut(t.chroma),Fn={[x.chroma]:x};function v(t){let n=ut(t)?t:gr(t)?Ft(t):Array.isArray(t)?Fr(t):Ar(t)?t.chroma:x.chroma;return Fn[n]=Fn[n]||wr(n)}var Nr=h("Pcset.pcset","Pcset.get",v),Rt=t=>v(t).chroma,Ir=t=>v(t).intervals,Sr=t=>v(t).setNum,Tr=["1P","2m","2M","3m","3M","4P","5d","5P","6m","6M","7m","7M"];function jr(t){let n=[];for(let e=0;e<12;e++)t.charAt(e)==="1"&&n.push(Tr[e]);return n}function xr(t){return v(t).intervals.map(n=>f("C",n))}function Cr(){return G(2048,4095).map(Ft)}function Y(t,n=!0){let r=v(t).chroma.split("");return W(r.map((o,a)=>{let i=D(a,r);return n&&i[0]==="0"?null:i.join("")}))}function Er(t,n){return v(t).setNum===v(n).setNum}function X(t){let n=v(t).setNum;return e=>{let r=v(e).setNum;return n&&n!==r&&(r&n)===r}}function H(t){let n=v(t).setNum;return e=>{let r=v(e).setNum;return n&&n!==r&&(r|n)===r}}function Rn(t){let n=v(t);return e=>{let r=c(e);return n&&!r.empty&&n.chroma.charAt(r.chroma)==="1"}}function Dr(t){let n=Rn(t);return e=>e.filter(n)}var Vt={get:v,chroma:Rt,num:Sr,intervals:Ir,chromas:Cr,isSupersetOf:H,isSubsetOf:X,isNoteIncludedIn:Rn,isEqual:Er,filter:Dr,modes:Y,notes:xr,pcset:Nr};function _r(t){let n=t.split("");return n.map((e,r)=>D(r,n).join(""))}function wr(t){let n=wn(t),e=_r(t).map(wn).filter(a=>a>=2048).sort()[0],r=Ft(e),o=jr(t);return{empty:!1,name:"",setNum:n,chroma:t,normalized:r,intervals:o}}function Fr(t){if(t.length===0)return x.chroma;let n,e=[0,0,0,0,0,0,0,0,0,0,0,0];for(let r=0;rt.name).filter(t=>t)}function qr(){return K.map(t=>t.aliases[0]).filter(t=>t)}function Gr(){return Object.keys(L)}function _(){return K.slice()}var Lr=h("ChordType.entries","ChordType.all",_);function zr(){K=[],L={}}function Vn(t,n,e){let r=Ur(t),o={...v(t),name:e||"",quality:r,intervals:t,aliases:n};K.push(o),o.name&&(L[o.name]=o),L[o.setNum]=o,L[o.chroma]=o,o.aliases.forEach(a=>Br(o,a))}function Br(t,n){L[n]=t}function Ur(t){let n=e=>t.indexOf(e)!==-1;return n("5A")?"Augmented":n("3M")?"Major":n("5d")?"Diminished":n("3m")?"Minor":"Unknown"}Vr.forEach(([t,n,e])=>Vn(t.split(" "),e.split(" "),n));K.sort((t,n)=>t.setNum-n.setNum);var kt={names:$r,symbols:qr,get:lt,all:_,add:Vn,removeAll:zr,keys:Gr,entries:Lr,chordType:Or};var Xr=t=>{let n=t.reduce((e,r)=>{let o=c(r).chroma;return o!==void 0&&(e[o]=e[o]||c(r).name),e},{});return e=>n[e]};function Ot(t,n={}){let e=t.map(o=>c(o).pc).filter(o=>o);return c.length===0?[]:Yr(e,1,n).filter(o=>o.weight).sort((o,a)=>a.weight-o.weight).map(o=>o.name)}var ft={anyThirds:384,perfectFifth:16,nonPerfectFifths:40,anySeventh:3},dt=t=>n=>!!(n&t),Hr=dt(ft.anyThirds),Kr=dt(ft.perfectFifth),Jr=dt(ft.anySeventh),Qr=dt(ft.nonPerfectFifths);function Zr(t){let n=parseInt(t.chroma,2);return Hr(n)&&Kr(n)&&Jr(n)}function Wr(t){let n=parseInt(t,2);return Qr(n)?t:(n|16).toString(2)}function Yr(t,n,e){let r=t[0],o=c(r).chroma,a=Xr(t),i=Y(t,!1),m=[];return i.forEach((s,l)=>{let p=e.assumePerfectFifth&&Wr(s);_().filter(u=>e.assumePerfectFifth&&Zr(u)?u.chroma===p:u.chroma===s).forEach(u=>{let y=u.aliases[0],M=a(l);l!==o?m.push({weight:.5*n,name:`${M}${y}/${r}`}):m.push({weight:1*n,name:`${M}${y}`})})}),m}function to(){return"1P 2M 3M 4P 5P 6m 7m".split(" ")}var kn=d,no=t=>d(t).name,eo=t=>d(t).semitones,ro=t=>d(t).q,oo=t=>d(t).num;function $t(t){let n=d(t);return n.empty?"":n.simple+n.q}function ao(t){let n=d(t);if(n.empty)return"";let e=(7-n.step)%7,r=n.type==="perfectable"?-n.alt:-(n.alt+1);return d({step:e,alt:r,oct:n.oct,dir:n.dir}).name}var io=[1,2,2,3,3,4,5,5,6,6,7,7],mo="P m M m M P d P m M m M".split(" ");function so(t){let n=t<0?-1:1,e=Math.abs(t),r=e%12,o=Math.floor(e/12);return n*(io[r]+7*o)+mo[r]}var co=I,On=$n((t,n)=>[t[0]+n[0],t[1]+n[1]]),uo=t=>n=>On(t,n),qt=$n((t,n)=>[t[0]-n[0],t[1]-n[1]]);function Gt(t,n){let e=kn(t);if(e.empty)return"";let[r,o,a]=e.coord;return $([r+n,o,a]).name}var pt={names:to,get:kn,name:no,num:oo,semitones:eo,quality:ro,fromSemitones:so,distance:co,invert:ao,simplify:$t,add:On,addTo:uo,subtract:qt,transposeFifths:Gt};function $n(t){return(n,e)=>{let r=d(n).coord,o=d(e).coord;if(r&&o){let a=t(r,o);return $(a).name}}}var lo=[["1P 2M 3M 5P 6M","major pentatonic","pentatonic"],["1P 2M 3M 4P 5P 6M 7M","major","ionian"],["1P 2M 3m 4P 5P 6m 7m","minor","aeolian"],["1P 2M 3m 3M 5P 6M","major blues"],["1P 3m 4P 5d 5P 7m","minor blues","blues"],["1P 2M 3m 4P 5P 6M 7M","melodic minor"],["1P 2M 3m 4P 5P 6m 7M","harmonic minor"],["1P 2M 3M 4P 5P 6M 7m 7M","bebop"],["1P 2M 3m 4P 5d 6m 6M 7M","diminished","whole-half diminished"],["1P 2M 3m 4P 5P 6M 7m","dorian"],["1P 2M 3M 4A 5P 6M 7M","lydian"],["1P 2M 3M 4P 5P 6M 7m","mixolydian","dominant"],["1P 2m 3m 4P 5P 6m 7m","phrygian"],["1P 2m 3m 4P 5d 6m 7m","locrian"],["1P 3M 4P 5P 7M","ionian pentatonic"],["1P 3M 4P 5P 7m","mixolydian pentatonic","indian"],["1P 2M 4P 5P 6M","ritusen"],["1P 2M 4P 5P 7m","egyptian"],["1P 3M 4P 5d 7m","neopolitan major pentatonic"],["1P 3m 4P 5P 6m","vietnamese 1"],["1P 2m 3m 5P 6m","pelog"],["1P 2m 4P 5P 6m","kumoijoshi"],["1P 2M 3m 5P 6m","hirajoshi"],["1P 2m 4P 5d 7m","iwato"],["1P 2m 4P 5P 7m","in-sen"],["1P 3M 4A 5P 7M","lydian pentatonic","chinese"],["1P 3m 4P 6m 7m","malkos raga"],["1P 3m 4P 5d 7m","locrian pentatonic","minor seven flat five pentatonic"],["1P 3m 4P 5P 7m","minor pentatonic","vietnamese 2"],["1P 3m 4P 5P 6M","minor six pentatonic"],["1P 2M 3m 5P 6M","flat three pentatonic","kumoi"],["1P 2M 3M 5P 6m","flat six pentatonic"],["1P 2m 3M 5P 6M","scriabin"],["1P 3M 5d 6m 7m","whole tone pentatonic"],["1P 3M 4A 5A 7M","lydian #5P pentatonic"],["1P 3M 4A 5P 7m","lydian dominant pentatonic"],["1P 3m 4P 5P 7M","minor #7M pentatonic"],["1P 3m 4d 5d 7m","super locrian pentatonic"],["1P 2M 3m 4P 5P 7M","minor hexatonic"],["1P 2A 3M 5P 5A 7M","augmented"],["1P 2M 4P 5P 6M 7m","piongio"],["1P 2m 3M 4A 6M 7m","prometheus neopolitan"],["1P 2M 3M 4A 6M 7m","prometheus"],["1P 2m 3M 5d 6m 7m","mystery #1"],["1P 2m 3M 4P 5A 6M","six tone symmetric"],["1P 2M 3M 4A 5A 6A","whole tone","messiaen's mode #1"],["1P 2m 4P 4A 5P 7M","messiaen's mode #5"],["1P 2M 3M 4P 5d 6m 7m","locrian major","arabian"],["1P 2m 3M 4A 5P 6m 7M","double harmonic lydian"],["1P 2m 2A 3M 4A 6m 7m","altered","super locrian","diminished whole tone","pomeroy"],["1P 2M 3m 4P 5d 6m 7m","locrian #2","half-diminished","aeolian b5"],["1P 2M 3M 4P 5P 6m 7m","mixolydian b6","melodic minor fifth mode","hindu"],["1P 2M 3M 4A 5P 6M 7m","lydian dominant","lydian b7","overtone"],["1P 2M 3M 4A 5A 6M 7M","lydian augmented"],["1P 2m 3m 4P 5P 6M 7m","dorian b2","phrygian #6","melodic minor second mode"],["1P 2m 3m 4d 5d 6m 7d","ultralocrian","superlocrian bb7","superlocrian diminished"],["1P 2m 3m 4P 5d 6M 7m","locrian 6","locrian natural 6","locrian sharp 6"],["1P 2A 3M 4P 5P 5A 7M","augmented heptatonic"],["1P 2M 3m 4A 5P 6M 7m","dorian #4","ukrainian dorian","romanian minor","altered dorian"],["1P 2M 3m 4A 5P 6M 7M","lydian diminished"],["1P 2M 3M 4A 5A 7m 7M","leading whole tone"],["1P 2M 3M 4A 5P 6m 7m","lydian minor"],["1P 2m 3M 4P 5P 6m 7m","phrygian dominant","spanish","phrygian major"],["1P 2m 3m 4P 5P 6m 7M","balinese"],["1P 2m 3m 4P 5P 6M 7M","neopolitan major"],["1P 2M 3M 4P 5P 6m 7M","harmonic major"],["1P 2m 3M 4P 5P 6m 7M","double harmonic major","gypsy"],["1P 2M 3m 4A 5P 6m 7M","hungarian minor"],["1P 2A 3M 4A 5P 6M 7m","hungarian major"],["1P 2m 3M 4P 5d 6M 7m","oriental"],["1P 2m 3m 3M 4A 5P 7m","flamenco"],["1P 2m 3m 4A 5P 6m 7M","todi raga"],["1P 2m 3M 4P 5d 6m 7M","persian"],["1P 2m 3M 5d 6m 7m 7M","enigmatic"],["1P 2M 3M 4P 5A 6M 7M","major augmented","major #5","ionian augmented","ionian #5"],["1P 2A 3M 4A 5P 6M 7M","lydian #9"],["1P 2m 2M 4P 4A 5P 6m 7M","messiaen's mode #4"],["1P 2m 3M 4P 4A 5P 6m 7M","purvi raga"],["1P 2m 3m 3M 4P 5P 6m 7m","spanish heptatonic"],["1P 2M 3m 3M 4P 5P 6M 7m","bebop minor"],["1P 2M 3M 4P 5P 5A 6M 7M","bebop major"],["1P 2m 3m 4P 5d 5P 6m 7m","bebop locrian"],["1P 2M 3m 4P 5P 6m 7m 7M","minor bebop"],["1P 2M 3M 4P 5d 5P 6M 7M","ichikosucho"],["1P 2M 3m 4P 5P 6m 6M 7M","minor six diminished"],["1P 2m 3m 3M 4A 5P 6M 7m","half-whole diminished","dominant diminished","messiaen's mode #2"],["1P 3m 3M 4P 5P 6M 7m 7M","kafi raga"],["1P 2M 3M 4P 4A 5A 6A 7M","messiaen's mode #6"],["1P 2M 3m 3M 4P 5d 5P 6M 7m","composite blues"],["1P 2M 3m 3M 4A 5P 6m 7m 7M","messiaen's mode #3"],["1P 2m 2M 3m 4P 4A 5P 6m 6M 7M","messiaen's mode #7"],["1P 2m 2M 3m 3M 4P 5d 5P 6m 6M 7m 7M","chromatic"]],fo=lo,po={...x,intervals:[],aliases:[]},Mt=[],z={};function Lt(){return Mt.map(t=>t.name)}function J(t){return z[t]||po}var Mo=h("ScaleDictionary.scaleType","ScaleType.get",J);function w(){return Mt.slice()}var Po=h("ScaleDictionary.entries","ScaleType.all",w);function ho(){return Object.keys(z)}function vo(){Mt=[],z={}}function qn(t,n,e=[]){let r={...v(t),name:n,intervals:t,aliases:e};return Mt.push(r),z[r.name]=r,z[r.setNum]=r,z[r.chroma]=r,r.aliases.forEach(o=>yo(r,o)),r}function yo(t,n){z[n]=t}fo.forEach(([t,n,...e])=>qn(t.split(" "),n,e));var zt={names:Lt,get:J,all:w,add:qn,removeAll:vo,keys:ho,entries:Po,scaleType:Mo};var Gn={empty:!0,name:"",symbol:"",root:"",bass:"",rootDegree:0,type:"",tonic:null,setNum:NaN,quality:"Unknown",chroma:"",normalized:"",aliases:[],notes:[],intervals:[]};function tt(t){let[n,e,r,o]=U(t);return n===""?Bt("",t):n==="A"&&o==="ug"?Bt("","aug"):Bt(n+e,r+o)}function Bt(t,n){let e=n.split("/");if(e.length===1)return[t,e[0],""];let[r,o,a,i]=U(e[1]);return r!==""&&a===""&&i===""?[t,e[0],r+o]:[t,n,""]}function k(t){if(Array.isArray(t))return Pt(t[1]||"",t[0],t[2]);if(t==="")return Gn;{let[n,e,r]=tt(t),o=Pt(e,n,r);return o.empty?Pt(t):o}}function Pt(t,n,e){let r=lt(t),o=c(n||""),a=c(e||"");if(r.empty||n&&o.empty||e&&a.empty)return Gn;let i=I(o.pc,a.pc),m=r.intervals.indexOf(i),s=m>=0,l=s?a:c(""),p=m===-1?NaN:m+1,P=a.pc&&a.pc!==o.pc,u=Array.from(r.intervals);if(s)for(let O=1;Of(o.pc,O));t=r.aliases.indexOf(t)!==-1?t:r.aliases[0];let M=`${o.empty?"":o.pc}${t}${s&&p>1?"/"+l.pc:P?"/"+a.pc:""}`,rt=`${n?o.pc+" ":""}${r.name}${s&&p>1?" over "+l.pc:P?" over "+a.pc:""}`;return{...r,name:rt,symbol:M,tonic:o.pc,type:r.name,root:l.pc,bass:P?a.pc:"",intervals:u,rootDegree:p,notes:y}}var bo=k;function go(t,n){let[e,r,o]=tt(t);if(!e)return t;let a=f(o,n),i=a?"/"+a:"";return f(e,n)+r+i}function Ao(t){let n=k(t),e=H(n.chroma);return w().filter(r=>e(r.chroma)).map(r=>r.name)}function No(t){let n=k(t),e=H(n.chroma);return _().filter(r=>e(r.chroma)).map(r=>n.tonic+r.aliases[0])}function Io(t){let n=k(t),e=X(n.chroma);return _().filter(r=>e(r.chroma)).map(r=>n.tonic+r.aliases[0])}function So(t,n){let e=k(t),r=n||e.tonic;return!r||e.empty?[]:e.intervals.map(o=>f(r,o))}function To(t,n){let e=k(t),r=n||e.tonic,o=V(e.intervals,r);return a=>a?o(a>0?a-1:a):""}function jo(t,n){let e=k(t),r=n||e.tonic;return V(e.intervals,r)}var Q={getChord:Pt,get:k,detect:Ot,chordScales:Ao,extended:No,reduced:Io,tokenize:tt,transpose:go,degrees:To,steps:jo,notes:So,chord:bo};var xo=[[.125,"dl",["large","duplex longa","maxima","octuple","octuple whole"]],[.25,"l",["long","longa"]],[.5,"d",["double whole","double","breve"]],[1,"w",["whole","semibreve"]],[2,"h",["half","minim"]],[4,"q",["quarter","crotchet"]],[8,"e",["eighth","quaver"]],[16,"s",["sixteenth","semiquaver"]],[32,"t",["thirty-second","demisemiquaver"]],[64,"sf",["sixty-fourth","hemidemisemiquaver"]],[128,"h",["hundred twenty-eighth"]],[256,"th",["two hundred fifty-sixth"]]],Co=xo,ht=[];Co.forEach(([t,n,e])=>Vo(t,n,e));var Eo={empty:!0,name:"",value:0,fraction:[0,0],shorthand:"",dots:"",names:[]};function Do(){return ht.reduce((t,n)=>(n.names.forEach(e=>t.push(e)),t),[])}function _o(){return ht.map(t=>t.shorthand)}var wo=/^([^.]+)(\.*)$/;function Ut(t){let[n,e,r]=wo.exec(t)||[],o=ht.find(m=>m.shorthand===e||m.names.includes(e));if(!o)return Eo;let a=ko(o.fraction,r.length),i=a[0]/a[1];return{...o,name:t,dots:r,value:i,fraction:a}}var Fo=t=>Ut(t).value,Ro=t=>Ut(t).fraction,Ln={names:Do,shorthands:_o,get:Ut,value:Fo,fraction:Ro};function Vo(t,n,e){ht.push({empty:!1,dots:"",name:"",value:1/t,fraction:t<1?[1/t,1]:[1,t],shorthand:n,names:e})}function ko(t,n){let e=Math.pow(2,n),r=t[0]*e,o=t[1]*e,a=r;for(let i=0;i=0&&+t<=127}function Xt(t){if(zn(t))return+t;let n=c(t);return n.empty?null:n.midi}function Oo(t,n=440){return Math.pow(2,(t-69)/12)*n}var $o=Math.log(2),qo=Math.log(440);function vt(t){let n=12*(Math.log(t)-qo)/$o+69;return Math.round(n*100)/100}var Go="C C# D D# E F F# G G# A A# B".split(" "),Lo="C Db D Eb E F Gb G Ab A Bb B".split(" ");function C(t,n={}){if(isNaN(t)||t===-1/0||t===1/0)return"";t=Math.round(t);let r=(n.sharps===!0?Go:Lo)[t%12];if(n.pitchClass)return r;let o=Math.floor(t/12)-1;return r+o}function Ht(t){return t%12}function zo(t){return t.split("").reduce((n,e,r)=>(r<12&&e==="1"&&n.push(r),n),[])}function Bo(t){return t.map(Ht).sort((n,e)=>n-e).filter((n,e,r)=>e===0||n!==r[e-1])}function Kt(t){return Array.isArray(t)?Bo(t):zo(t)}function Uo(t){let n=Kt(t);return e=>{let r=Ht(e);for(let o=0;o<12;o++){if(n.includes(r+o))return e+o;if(n.includes(r-o))return e-o}}}function Bn(t,n){let e=Kt(t),r=e.length;return o=>{let a=o<0?(r- -o%r)%r:o%r,i=Math.floor(o/r);return e[a]+i*12+n}}function Xo(t,n){let e=Bn(t,n);return r=>{if(r!==0)return e(r>0?r-1:r)}}var Un={chroma:Ht,freqToMidi:vt,isMidi:zn,midiToFreq:Oo,midiToNoteName:C,pcsetNearest:Uo,pcset:Kt,pcsetDegrees:Xo,pcsetSteps:Bn,toMidi:Xt};var Ho=["C","D","E","F","G","A","B"],Xn=t=>t.name,Hn=t=>t.map(c).filter(n=>!n.empty);function Ko(t){return t===void 0?Ho.slice():Array.isArray(t)?Hn(t).map(Xn):[]}var S=c,Jo=t=>S(t).name,Qo=t=>S(t).pc,Zo=t=>S(t).acc,Wo=t=>S(t).oct,Yo=t=>S(t).midi,ta=t=>S(t).freq,na=t=>S(t).chroma;function Jt(t){return C(t)}function ea(t){return C(vt(t))}function ra(t){return C(vt(t),{sharps:!0})}function oa(t){return C(t,{sharps:!0})}var nt=f,aa=f,Kn=t=>n=>nt(n,t),ia=Kn,Jn=t=>n=>nt(t,n),ma=Jn;function et(t,n){return nt(t,[n,0])}var sa=et;function ca(t,n){return nt(t,[0,n])}var Qt=(t,n)=>t.height-n.height,ua=(t,n)=>n.height-t.height;function Qn(t,n){return n=n||Qt,Hn(t).sort(n).map(Xn)}function Zt(t){return Qn(t,Qt).filter((n,e,r)=>e===0||n!==r[e-1])}var la=t=>{let n=S(t);return n.empty?"":C(n.midi||n.chroma,{sharps:n.alt>0,pitchClass:n.midi===null})};function Wt(t,n){let e=S(t);if(e.empty)return"";let r=S(n||C(e.midi||e.chroma,{sharps:e.alt<0,pitchClass:!0}));if(r.empty||r.chroma!==e.chroma)return"";if(e.oct===void 0)return r.pc;let o=e.chroma-e.alt,a=r.chroma-r.alt,i=o>11||a<0?-1:o<0||a>11?1:0,m=e.oct+i;return r.pc+m}var b={names:Ko,get:S,name:Jo,pitchClass:Qo,accidentals:Zo,octave:Wo,midi:Yo,ascending:Qt,descending:ua,sortedNames:Qn,sortedUniqNames:Zt,fromMidi:Jt,fromMidiSharps:oa,freq:ta,fromFreq:ea,fromFreqSharps:ra,chroma:na,transpose:nt,tr:aa,transposeBy:Kn,trBy:ia,transposeFrom:Jn,trFrom:ma,transposeFifths:et,transposeOctaves:ca,trFifths:sa,simplify:la,enharmonic:Wt};var Wn={empty:!0,name:"",chordType:""},Zn={};function T(t){return typeof t=="string"?Zn[t]||(Zn[t]=va(t)):typeof t=="number"?T(yt[t]||""):A(t)?pa(t):st(t)?T(t.name):Wn}var fa=h("RomanNumeral.romanNumeral","RomanNumeral.get",T);function da(t=!0){return(t?yt:ha).slice()}function pa(t){return T(R(t.alt)+yt[t.step])}var Ma=/^(#{1,}|b{1,}|x{1,}|)(IV|I{1,3}|VI{0,2}|iv|i{1,3}|vi{0,2})([^IViv]*)$/;function Pa(t){return Ma.exec(t)||["","","",""]}var Yn="I II III IV V VI VII",yt=Yn.split(" "),ha=Yn.toLowerCase().split(" ");function va(t){let[n,e,r,o]=Pa(t);if(!r)return Wn;let a=r.toUpperCase(),i=yt.indexOf(a),m=q(e),s=1;return{empty:!1,name:n,roman:r,interval:d({step:i,alt:m,dir:s}).name,acc:e,chordType:o,alt:m,step:i,major:r===a,oct:0,dir:s}}var te={names:da,get:T,romanNumeral:fa};var N=Object.freeze([]),ne={type:"major",tonic:"",alteration:0,keySignature:""},bt={tonic:"",grades:N,intervals:N,scale:N,triads:N,chords:N,chordsHarmonicFunction:N,chordScales:N},ya={...ne,...bt,type:"major",minorRelative:"",scale:N,secondaryDominants:N,secondaryDominantsMinorRelative:N,substituteDominants:N,substituteDominantsMinorRelative:N},ba={...ne,type:"minor",relativeMajor:"",natural:bt,harmonic:bt,melodic:bt},Yt=(t,n,e="")=>n.map((r,o)=>`${t[o]}${e}${r}`);function gt(t,n,e,r,o){return a=>{let i=t.map(s=>T(s).interval||""),m=i.map(s=>f(a,s));return{tonic:a,grades:t,intervals:i,scale:m,triads:Yt(m,n),chords:Yt(m,e),chordsHarmonicFunction:r.slice(),chordScales:Yt(m,o," ")}}}var ee=(t,n)=>{let e=c(t),r=c(n);return e.empty||r.empty?0:r.coord[0]-e.coord[0]},ga=gt("I II III IV V VI VII".split(" ")," m m m dim".split(" "),"maj7 m7 m7 maj7 7 m7 m7b5".split(" "),"T SD T SD D T D".split(" "),"major,dorian,phrygian,lydian,mixolydian,minor,locrian".split(",")),Aa=gt("I II bIII IV V bVI bVII".split(" "),"m dim m m ".split(" "),"m7 m7b5 maj7 m7 m7 maj7 7".split(" "),"T SD T SD D SD SD".split(" "),"minor,locrian,major,dorian,phrygian,lydian,mixolydian".split(",")),Na=gt("I II bIII IV V bVI VII".split(" "),"m dim aug m dim".split(" "),"mMaj7 m7b5 +maj7 m7 7 maj7 o7".split(" "),"T SD T SD D SD D".split(" "),"harmonic minor,locrian 6,major augmented,lydian diminished,phrygian dominant,lydian #9,ultralocrian".split(",")),Ia=gt("I II bIII IV V VI VII".split(" "),"m m aug dim dim".split(" "),"m6 m7 +maj7 7 7 m7b5 m7b5".split(" "),"T SD T SD D ".split(" "),"melodic minor,dorian b2,lydian augmented,lydian dominant,mixolydian b6,locrian #2,altered".split(","));function Sa(t){let n=c(t).pc;if(!n)return ya;let e=ga(n),r=ee("C",n),o=a=>{let i=T(a);return i.empty?"":f(t,i.interval)+i.chordType};return{...e,type:"major",minorRelative:f(n,"-3m"),alteration:r,keySignature:R(r),secondaryDominants:"- VI7 VII7 I7 II7 III7 -".split(" ").map(o),secondaryDominantsMinorRelative:"- IIIm7b5 IV#m7 Vm7 VIm7 VIIm7b5 -".split(" ").map(o),substituteDominants:"- bIII7 IV7 bV7 bVI7 bVII7 -".split(" ").map(o),substituteDominantsMinorRelative:"- IIIm7 Im7 IIbm7 VIm7 IVm7 -".split(" ").map(o)}}function Ta(t){let n=c(t).pc;if(!n)return ba;let e=ee("C",n)-3;return{type:"minor",tonic:n,relativeMajor:f(n,"3m"),alteration:e,keySignature:R(e),natural:Aa(n),harmonic:Na(n),melodic:Ia(n)}}function ja(t){return typeof t=="number"?et("C",t):typeof t=="string"&&/^b+|#+$/.test(t)?et("C",q(t)):null}var re={majorKey:Sa,majorTonicFromKeySignature:ja,minorKey:Ta};var nn=[[0,2773,0,"ionian","","Maj7","major"],[1,2902,2,"dorian","m","m7"],[2,3418,4,"phrygian","m","m7"],[3,2741,-1,"lydian","","Maj7"],[4,2774,1,"mixolydian","","7"],[5,2906,3,"aeolian","m","m7","minor"],[6,3434,5,"locrian","dim","m7b5"]],oe={...x,name:"",alt:0,modeNum:NaN,triad:"",seventh:"",aliases:[]},en=nn.map(Da),tn={};en.forEach(t=>{tn[t.name]=t,t.aliases.forEach(n=>{tn[n]=t})});function B(t){return typeof t=="string"?tn[t.toLowerCase()]||oe:t&&t.name?B(t.name):oe}var xa=h("Mode.mode","Mode.get",B);function ae(){return en.slice()}var Ca=h("Mode.mode","Mode.all",ae);function Ea(){return en.map(t=>t.name)}function Da(t){let[n,e,r,o,a,i,m]=t,s=m?[m]:[],l=Number(e).toString(2);return{empty:!1,intervals:J(o).intervals,modeNum:n,chroma:l,normalized:l,name:o,setNum:e,alt:r,triad:a,seventh:i,aliases:s}}function _a(t,n){return B(t).intervals.map(e=>f(n,e))}function ie(t){return(n,e)=>{let r=B(n);if(r.empty)return[];let o=D(r.modeNum,t),a=r.intervals.map(i=>f(e,i));return o.map((i,m)=>a[m]+i)}}var wa=ie(nn.map(t=>t[4])),Fa=ie(nn.map(t=>t[5]));function me(t,n){let e=B(n),r=B(t);return e.empty||r.empty?"":$t(Gt("1P",r.alt-e.alt))}function Ra(t,n,e){return f(e,me(t,n))}var se={get:B,names:Ea,all:ae,distance:me,relativeTonic:Ra,notes:_a,triads:wa,seventhChords:Fa,entries:Ca,mode:xa};function Va(t,n){return n.map(T).map(r=>f(t,d(r))+r.chordType)}function ka(t,n){return n.map(e=>{let[r,o]=tt(e),a=I(t,r);return T(d(a)).name+o})}var ce={fromRomanNumerals:Va,toRomanNumerals:ka};function ue(t){let n=W(t.map(e=>typeof e=="number"?e:Xt(e)));return!t.length||n.length!==t.length?[]:n.reduce((e,r)=>{let o=e[e.length-1];return e.concat(G(o,r).slice(1))},[n[0]])}function Oa(t,n){return ue(t).map(e=>C(e,n))}var At={numeric:ue,chromatic:Oa};var $a={empty:!0,name:"",type:"",tonic:null,setNum:NaN,chroma:"",normalized:"",aliases:[],notes:[],intervals:[]};function le(t){if(typeof t!="string")return["",""];let n=t.indexOf(" "),e=c(t.substring(0,n));if(e.empty){let o=c(t);return o.empty?["",t]:[o.name,""]}let r=t.substring(e.name.length+1);return[e.name,r.length?r:""]}var qa=Lt;function E(t){let n=Array.isArray(t)?t:le(t),e=c(n[0]).name,r=J(n[1]);if(r.empty)return $a;let o=r.name,a=e?r.intervals.map(m=>f(e,m)):[],i=e?e+" "+o:o;return{...r,name:i,type:o,tonic:e,notes:a}}var Ga=h("Scale.scale","Scale.get",E);function La(t,n={}){let e=Rt(t),r=c(n.tonic??t[0]??""),o=r.chroma;if(o===void 0)return[];let a=e.split("");a[o]="1";let i=D(o,a).join(""),m=w().find(l=>l.chroma===i),s=[];return m&&s.push(r.name+" "+m.name),n.match==="exact"||fe(i).forEach(l=>{s.push(r.name+" "+l)}),s}function za(t){let n=E(t),e=X(n.chroma);return _().filter(r=>e(r.chroma)).map(r=>r.aliases[0])}function fe(t){let n=ut(t)?t:E(t).chroma,e=H(n);return w().filter(r=>e(r.chroma)).map(r=>r.name)}function Ba(t){let n=X(E(t).chroma);return w().filter(e=>n(e.chroma)).map(e=>e.name)}function de(t){let n=t.map(o=>c(o).pc).filter(o=>o),e=n[0],r=Zt(n);return D(r.indexOf(e),r)}function Ua(t){let n=E(t);if(n.empty)return[];let e=n.tonic?n.notes:n.intervals;return Y(n.chroma).map((r,o)=>{let a=E(r).name;return a?[e[o],a]:["",""]}).filter(r=>r[0])}function Xa(t){let n=Array.isArray(t)?de(t):E(t).notes,e=n.map(r=>c(r).chroma);return r=>{let o=typeof r=="number"?c(Jt(r)):c(r),a=o.height;if(a===void 0)return;let i=a%12,m=e.indexOf(i);if(m!==-1)return Wt(o.name,n[m])}}function Ha(t){let n=Xa(t);return(e,r)=>{let o=c(e).height,a=c(r).height;return o===void 0||a===void 0?[]:G(o,a).map(n).filter(i=>i)}}function Ka(t){let{intervals:n,tonic:e}=E(t),r=V(n,e);return o=>o?r(o>0?o-1:o):""}function Ja(t){let{intervals:n,tonic:e}=E(t);return V(n,e)}var pe={degrees:Ka,detect:La,extended:fe,get:E,modeNames:Ua,names:qa,rangeOf:Ha,reduced:Ba,scaleChords:za,scaleNotes:de,steps:Ja,tokenize:le,scale:Ga};var Qa={empty:!0,name:"",upper:void 0,lower:void 0,type:void 0,additive:[]},Za=["4/4","3/4","2/4","2/2","12/8","9/8","6/8","3/8"];function Wa(){return Za.slice()}var Ya=/^(\d*\d(?:\+\d)*)\/(\d+)$/,Me=new Map;function ti(t){let n=JSON.stringify(t),e=Me.get(n);if(e)return e;let r=ei(rn(t));return Me.set(n,r),r}function rn(t){if(typeof t=="string"){let[a,i,m]=Ya.exec(t)||[];return rn([i,m])}let[n,e]=t,r=+e;if(typeof n=="number")return[n,r];let o=n.split("+").map(a=>+a);return o.length===1?[o[0],r]:[o,r]}var Pe={names:Wa,parse:rn,get:ti},ni=t=>Math.log(t)/Math.log(2)%1===0;function ei([t,n]){let e=Array.isArray(t)?t.reduce((m,s)=>m+s,0):t,r=n;if(e===0||r===0)return Qa;let o=Array.isArray(t)?`${t.join("+")}/${n}`:`${t}/${n}`,a=Array.isArray(t)?t:[],i=r===4||r===2?"simple":r===8&&e%3===0?"compound":ni(r)?"irregular":"irrational";return{empty:!1,name:o,type:i,upper:e,lower:r,additive:a}}var ri=(t,n)=>{if(!n||!n.length)return t[0];let e=o=>b.midi(o[o.length-1])||0,r=o=>Math.abs(e(n)-e(o));return t.sort((o,a)=>r(o)-r(a))[0]},Nt={topNoteDiff:ri};var oi={M:["1P 3M 5P","3M 5P 8P","5P 8P 10M"],m:["1P 3m 5P","3m 5P 8P","5P 8P 10m"],o:["1P 3m 5d","3m 5d 8P","5d 8P 10m"],aug:["1P 3m 5A","3m 5A 8P","5A 8P 10m"]},he={m7:["3m 5P 7m 9M","7m 9M 10m 12P"],7:["3M 6M 7m 9M","7m 9M 10M 13M"],"^7":["3M 5P 7M 9M","7M 9M 10M 12P"],69:["3M 5P 6A 9M"],m7b5:["3m 5d 7m 8P","7m 8P 10m 12d"],"7b9":["3M 6m 7m 9m","7m 9m 10M 13m"],"7b13":["3M 6m 7m 9m","7m 9m 10M 13m"],o7:["1P 3m 5d 6M","5d 6M 8P 10m"],"7#11":["7m 9M 11A 13A"],"7#9":["3M 7m 9A"],mM7:["3m 5P 7M 9M","7M 9M 10m 12P"],m6:["3m 5P 6M 9M","6M 9M 10m 12P"]},ai={M:["1P 3M 5P","3M 5P 8P","5P 8P 10M"],m:["1P 3m 5P","3m 5P 8P","5P 8P 10m"],o:["1P 3m 5d","3m 5d 8P","5d 8P 10m"],aug:["1P 3m 5A","3m 5A 8P","5A 8P 10m"],m7:["3m 5P 7m 9M","7m 9M 10m 12P"],7:["3M 6M 7m 9M","7m 9M 10M 13M"],"^7":["3M 5P 7M 9M","7M 9M 10M 12P"],69:["3M 5P 6A 9M"],m7b5:["3m 5d 7m 8P","7m 8P 10m 12d"],"7b9":["3M 6m 7m 9m","7m 9m 10M 13m"],"7b13":["3M 6m 7m 9m","7m 9m 10M 13m"],o7:["1P 3m 5d 6M","5d 6M 8P 10m"],"7#11":["7m 9M 11A 13A"],"7#9":["3M 7m 9A"],mM7:["3m 5P 7M 9M","7M 9M 10m 12P"],m6:["3m 5P 6M 9M","6M 9M 10m 12P"]},ve=he;function ii(t,n=ve){if(n[t])return n[t];let{aliases:e}=Q.get("C"+t),r=Object.keys(n).find(o=>e.includes(o))||"";if(r!==void 0)return n[r]}var Z={lookup:ii,lefthand:he,triads:oi,all:ai,defaultDictionary:ve};var on=["C3","C5"],ye=Z.all,be=Nt.topNoteDiff;function ge(t,n=on,e=ye,r=be,o){let a=Ae(t,n,e);return!o||!o.length?a[0]:r(a,o)}function Ae(t,n=on,e=Z.triads){let[r,o]=Q.tokenize(t),a=Z.lookup(o,e);if(!a)return[];let i=a.map(s=>s.split(" ")),m=At.chromatic(n);return i.reduce((s,l)=>{let p=l.map(M=>pt.subtract(M,l[0])||""),P=b.transpose(r,l[0]),y=m.filter(M=>b.chroma(M)===b.chroma(P)).filter(M=>(b.midi(b.transpose(M,p[p.length-1]))||0)<=(b.midi(n[1])||0)).map(M=>b.enharmonic(M,P)).map(M=>p.map(rt=>b.transpose(M,rt)));return s.concat(y)},[])}function mi(t,n=on,e=ye,r=be,o){let{voicings:a}=t.reduce(({voicings:i,lastVoicing:m},s)=>{let l=ge(s,n,e,r,m);return m=l,i.push(l),{voicings:i,lastVoicing:m}},{voicings:[],lastVoicing:o});return a}var Ne={get:ge,search:Ae,sequence:mi};var si=ct,ci=Vt,ui=kt,li=zt;return De(fi);})(); +"use strict";var Tonal=(()=>{var Nt=Object.defineProperty;var Ae=Object.getOwnPropertyDescriptor;var Ne=Object.getOwnPropertyNames;var Ie=Object.prototype.hasOwnProperty;var It=(t,n)=>{for(var e in n)Nt(t,e,{get:n[e],enumerable:!0})},Se=(t,n,e,r)=>{if(n&&typeof n=="object"||typeof n=="function")for(let o of Ne(n))!Ie.call(t,o)&&o!==e&&Nt(t,o,{get:()=>n[o],enumerable:!(r=Ae(n,o))||r.enumerable});return t};var Te=t=>Se(Nt({},"__esModule",{value:!0}),t);var Ya={};It(Ya,{AbcNotation:()=>yn,Array:()=>Dt,Chord:()=>Q,ChordDictionary:()=>Za,ChordType:()=>Ft,Collection:()=>jn,Core:()=>st,DurationValue:()=>On,Interval:()=>dt,Key:()=>Wn,Midi:()=>qn,Mode:()=>re,Note:()=>y,PcSet:()=>Qa,Pcset:()=>Vt,Progression:()=>oe,Range:()=>gt,RomanNumeral:()=>Jn,Scale:()=>ce,ScaleDictionary:()=>Wa,ScaleType:()=>Gt,TimeSignature:()=>le,Tonal:()=>Ja,VoiceLeading:()=>At,Voicing:()=>ve,VoicingDictionary:()=>Z,accToAlt:()=>q,altToAcc:()=>V,chroma:()=>on,coordToInterval:()=>$,coordToNote:()=>ot,coordinates:()=>w,deprecate:()=>P,distance:()=>A,fillStr:()=>Sn,height:()=>St,interval:()=>d,isNamed:()=>it,isNamedPitch:()=>S,isPitch:()=>T,midi:()=>an,note:()=>s,pitch:()=>k,stepToLetter:()=>Ct,tokenizeInterval:()=>jt,tokenizeNote:()=>U,tonicIntervalsTransposer:()=>F,transpose:()=>u});function S(t){return t!==null&&typeof t=="object"&&"name"in t&&typeof t.name=="string"}var rn=[0,2,4,5,7,9,11],on=({step:t,alt:n})=>(rn[t]+n+120)%12,St=({step:t,alt:n,oct:e,dir:r=1})=>r*(rn[t]+n+12*(e===void 0?-100:e)),an=t=>{let n=St(t);return t.oct!==void 0&&n>=-12&&n<=115?n+12:null};function T(t){return t!==null&&typeof t=="object"&&"step"in t&&typeof t.step=="number"&&"alt"in t&&typeof t.alt=="number"&&!isNaN(t.step)&&!isNaN(t.alt)}var mn=[0,2,4,-1,1,3,5],sn=mn.map(t=>Math.floor(t*7/12));function w(t){let{step:n,alt:e,oct:r,dir:o=1}=t,a=mn[n]+7*e;if(r===void 0)return[o*a];let m=r-sn[n]-4*e;return[o*a,o*m]}var je=[3,0,4,1,5,2,6];function k(t){let[n,e,r]=t,o=je[xe(n)],a=Math.floor((n+1)/7);if(e===void 0)return{step:o,alt:a,dir:r};let m=e+4*a+sn[o];return{step:o,alt:a,oct:m,dir:r}}function xe(t){let n=(t+1)%7;return n<0?7+n:n}var cn=(t,n)=>Array(Math.abs(n)+1).join(t),Tt=Object.freeze({empty:!0,name:"",num:NaN,q:"",type:"",step:NaN,alt:NaN,dir:NaN,simple:NaN,semitones:NaN,chroma:NaN,coord:[],oct:NaN}),Ce="([-+]?\\d+)(d{1,4}|m|M|P|A{1,4})",Ee="(AA|A|P|M|m|d|dd)([-+]?\\d+)",De=new RegExp("^"+Ce+"|"+Ee+"$");function jt(t){let n=De.exec(`${t}`);return n===null?["",""]:n[1]?[n[1],n[2]]:[n[4],n[3]]}var un={};function d(t){return typeof t=="string"?un[t]||(un[t]=_e(t)):T(t)?d(Ve(t)):S(t)?d(t.name):Tt}var ln=[0,2,4,5,7,9,11],fn="PMMPPMM";function _e(t){let n=jt(t);if(n[0]==="")return Tt;let e=+n[0],r=n[1],o=(Math.abs(e)-1)%7,a=fn[o];if(a==="M"&&r==="P")return Tt;let m=a==="M"?"majorable":"perfectable",i=""+e+r,c=e<0?-1:1,f=e===8||e===-8?e:c*(o+1),p=we(m,r),v=Math.floor((Math.abs(e)-1)/7),l=c*(ln[o]+p+12*v),b=(c*(ln[o]+p)%12+12)%12,M=w({step:o,alt:p,oct:v,dir:c});return{empty:!1,name:i,num:e,q:r,step:o,alt:p,dir:c,type:m,simple:f,semitones:l,chroma:b,coord:M,oct:v}}function $(t,n){let[e,r=0]=t,o=e*7+r*12<0,a=n||o?[-e,-r,-1]:[e,r,1];return d(k(a))}function we(t,n){return n==="M"&&t==="majorable"||n==="P"&&t==="perfectable"?0:n==="m"&&t==="majorable"?-1:/^A+$/.test(n)?n.length:/^d+$/.test(n)?-1*(t==="perfectable"?n.length:n.length+1):0}function Ve(t){let{step:n,alt:e,oct:r=0,dir:o}=t;if(!o)return"";let a=n+1+7*r,m=a===0?n+1:a,i=o<0?"-":"",c=fn[n]==="M"?"majorable":"perfectable";return i+m+Fe(c,e)}function Fe(t,n){return n===0?t==="majorable"?"M":"P":n===-1&&t==="majorable"?"m":n>0?cn("A",n):cn("d",t==="perfectable"?n:n+1)}var dn=(t,n)=>Array(Math.abs(n)+1).join(t),Mn=Object.freeze({empty:!0,name:"",letter:"",acc:"",pc:"",step:NaN,alt:NaN,chroma:NaN,height:NaN,coord:[],midi:null,freq:null}),pn=new Map,Ct=t=>"CDEFGAB".charAt(t),V=t=>t<0?dn("b",-t):dn("#",t),q=t=>t[0]==="b"?-t.length:t.length;function s(t){let n=JSON.stringify(t),e=pn.get(n);if(e)return e;let r=typeof t=="string"?ke(t):T(t)?s($e(t)):S(t)?s(t.name):Mn;return pn.set(n,r),r}var Re=/^([a-gA-G]?)(#{1,}|b{1,}|x{1,}|)(-?\d*)\s*(.*)$/;function U(t){let n=Re.exec(t);return n?[n[1].toUpperCase(),n[2].replace(/x/g,"##"),n[3],n[4]]:["","","",""]}function ot(t){return s(k(t))}var Oe=(t,n)=>(t%n+n)%n,xt=[0,2,4,5,7,9,11];function ke(t){let n=U(t);if(n[0]===""||n[3]!=="")return Mn;let e=n[0],r=n[1],o=n[2],a=(e.charCodeAt(0)+3)%7,m=q(r),i=o.length?+o:void 0,c=w({step:a,alt:m,oct:i}),f=e+r+o,p=e+r,v=(xt[a]+m+120)%12,l=i===void 0?Oe(xt[a]+m,12)-12*99:xt[a]+m+12*(i+1),b=l>=0&&l<=127?l:null,M=i===void 0?null:Math.pow(2,(l-69)/12)*440;return{empty:!1,acc:r,alt:m,chroma:v,coord:c,freq:M,height:l,letter:e,midi:b,name:f,oct:i,pc:p,step:a}}function $e(t){let{step:n,alt:e,oct:r}=t,o=Ct(n);if(!o)return"";let a=o+V(e);return r||r===0?a+r:a}function u(t,n){let e=s(t),r=Array.isArray(n)?n:d(n).coord;if(e.empty||!r||r.length<2)return"";let o=e.coord,a=o.length===1?[o[0]+r[0]]:[o[0]+r[0],o[1]+r[1]];return ot(a).name}function F(t,n){let e=t.length;return r=>{if(!n)return"";let o=r<0?(e- -r%e)%e:r%e,a=Math.floor(r/e),m=u(n,[0,a]);return u(m,t[o])}}function A(t,n){let e=s(t),r=s(n);if(e.empty||r.empty)return"";let o=e.coord,a=r.coord,m=a[0]-o[0],i=o.length===2&&a.length===2?a[1]-o[1]:-Math.floor(m*7/12),c=r.height===e.height&&r.midi!==null&&e.midi!==null&&e.step>r.step;return $([m,i],c).name}var Pn=(t,n)=>Array(n+1).join(t),qe=/^(_{1,}|=|\^{1,}|)([abcdefgABCDEFG])([,']*)$/;function hn(t){let n=qe.exec(t);return n?[n[1],n[2],n[3]]:["","",""]}function at(t){let[n,e,r]=hn(t);if(e==="")return"";let o=4;for(let m=0;m96?e.toUpperCase()+a+(o+1):e+a+o}function vn(t){let n=s(t);if(n.empty||!n.oct&&n.oct!==0)return"";let{letter:e,acc:r,oct:o}=n,a=r[0]==="b"?r.replace(/b/g,"_"):r.replace(/#/g,"^"),m=o>4?e.toLowerCase():e,i=o===5?"":o>4?Pn("'",o-5):Pn(",",4-o);return a+m+i}function Ge(t,n){return vn(u(at(t),n))}function Le(t,n){return A(at(t),at(n))}var yn={abcToScientificNotation:at,scientificToAbcNotation:vn,tokenize:hn,transpose:Ge,distance:Le};var Dt={};It(Dt,{compact:()=>nr,permutations:()=>In,range:()=>Ye,rotate:()=>tr,shuffle:()=>rr,sortedNoteNames:()=>Nn,sortedUniqNoteNames:()=>er});var bn=(t,n)=>Array(Math.abs(n)+1).join(t),An={empty:!0,name:"",pc:"",acc:""},gn=new Map,ze=t=>"CDEFGAB".charAt(t),Be=t=>t<0?bn("b",-t):bn("#",t),Ue=t=>t[0]==="b"?-t.length:t.length;function mt(t){let n=JSON.stringify(t),e=gn.get(n);if(e)return e;let r=typeof t=="string"?Je(t):T(t)?mt(Qe(t)):S(t)?mt(t.name):An;return gn.set(n,r),r}var He=/^([a-gA-G]?)(#{1,}|b{1,}|x{1,}|)(-?\d*)\s*(.*)$/;function Xe(t){let n=He.exec(t);return[n[1].toUpperCase(),n[2].replace(/x/g,"##"),n[3],n[4]]}var Ke=(t,n)=>(t%n+n)%n,Et=[0,2,4,5,7,9,11];function Je(t){let n=Xe(t);if(n[0]===""||n[3]!=="")return An;let e=n[0],r=n[1],o=n[2],a=(e.charCodeAt(0)+3)%7,m=Ue(r),i=o.length?+o:void 0,c=w({step:a,alt:m,oct:i}),f=e+r+o,p=e+r,v=(Et[a]+m+120)%12,l=i===void 0?Ke(Et[a]+m,12)-12*99:Et[a]+m+12*(i+1),b=l>=0&&l<=127?l:null,M=i===void 0?null:Math.pow(2,(l-69)/12)*440;return{empty:!1,acc:r,alt:m,chroma:v,coord:c,freq:M,height:l,letter:e,midi:b,name:f,oct:i,pc:p,step:a}}function Qe(t){let{step:n,alt:e,oct:r}=t,o=ze(n);if(!o)return"";let a=o+Be(e);return r||r===0?a+r:a}function Ze(t,n){let e=[];for(;n--;e[n]=n+t);return e}function We(t,n){let e=[];for(;n--;e[n]=t-n);return e}function Ye(t,n){return tn===0||n)}function Nn(t){return t.map(e=>mt(e)).filter(e=>!e.empty).sort((e,r)=>e.height-r.height).map(e=>e.name)}function er(t){return Nn(t).filter((n,e,r)=>e===0||n!==r[e-1])}function rr(t,n=Math.random){let e,r,o=t.length;for(;o;)e=Math.floor(n()*o--),r=t[o],t[o]=t[e],t[e]=r;return t}function In(t){return t.length===0?[[]]:In(t.slice(1)).reduce((n,e)=>n.concat(t.map((r,o)=>{let a=e.slice();return a.splice(o,0,t[0]),a})),[])}var st={};It(st,{accToAlt:()=>q,altToAcc:()=>V,chroma:()=>on,coordToInterval:()=>$,coordToNote:()=>ot,coordinates:()=>w,deprecate:()=>P,distance:()=>A,fillStr:()=>Sn,height:()=>St,interval:()=>d,isNamed:()=>it,isNamedPitch:()=>S,isPitch:()=>T,midi:()=>an,note:()=>s,pitch:()=>k,stepToLetter:()=>Ct,tokenizeInterval:()=>jt,tokenizeNote:()=>U,tonicIntervalsTransposer:()=>F,transpose:()=>u});var Sn=(t,n)=>Array(Math.abs(n)+1).join(t);function P(t,n,e){return function(...r){return console.warn(`${t} is deprecated. Use ${n}.`),e.apply(this,r)}}var it=P("isNamed","isNamedPitch",S);function or(t,n){let e=[];for(;n--;e[n]=n+t);return e}function ar(t,n){let e=[];for(;n--;e[n]=t-n);return e}function G(t,n){return tn===0||n)}function mr(t,n=Math.random){let e,r,o=t.length;for(;o;)e=Math.floor(n()*o--),r=t[o],t[o]=t[e],t[e]=r;return t}function Tn(t){return t.length===0?[[]]:Tn(t.slice(1)).reduce((n,e)=>n.concat(t.map((r,o)=>{let a=e.slice();return a.splice(o,0,t[0]),a})),[])}var jn={compact:W,permutations:Tn,range:G,rotate:E,shuffle:mr};var j={empty:!0,name:"",setNum:0,chroma:"000000000000",normalized:"000000000000",intervals:[]},_t=t=>Number(t).toString(2).padStart(12,"0"),xn=t=>parseInt(t,2),ir=/^[01]{12}$/;function ct(t){return ir.test(t)}var sr=t=>typeof t=="number"&&t>=0&&t<=4095,cr=t=>t&&ct(t.chroma),Cn={[j.chroma]:j};function h(t){let n=ct(t)?t:sr(t)?_t(t):Array.isArray(t)?gr(t):cr(t)?t.chroma:j.chroma;return Cn[n]=Cn[n]||br(n)}var ur=P("Pcset.pcset","Pcset.get",h),wt=t=>h(t).chroma,lr=t=>h(t).intervals,fr=t=>h(t).setNum,dr=["1P","2m","2M","3m","3M","4P","5d","5P","6m","6M","7m","7M"];function pr(t){let n=[];for(let e=0;e<12;e++)t.charAt(e)==="1"&&n.push(dr[e]);return n}function Mr(t){return h(t).intervals.map(n=>u("C",n))}function Pr(){return G(2048,4095).map(_t)}function Y(t,n=!0){let r=h(t).chroma.split("");return W(r.map((o,a)=>{let m=E(a,r);return n&&m[0]==="0"?null:m.join("")}))}function hr(t,n){return h(t).setNum===h(n).setNum}function H(t){let n=h(t).setNum;return e=>{let r=h(e).setNum;return n&&n!==r&&(r&n)===r}}function X(t){let n=h(t).setNum;return e=>{let r=h(e).setNum;return n&&n!==r&&(r|n)===r}}function En(t){let n=h(t);return e=>{let r=s(e);return n&&!r.empty&&n.chroma.charAt(r.chroma)==="1"}}function vr(t){let n=En(t);return e=>e.filter(n)}var Vt={get:h,chroma:wt,num:fr,intervals:lr,chromas:Pr,isSupersetOf:X,isSubsetOf:H,isNoteIncludedIn:En,isEqual:hr,filter:vr,modes:Y,notes:Mr,pcset:ur};function yr(t){let n=t.split("");return n.map((e,r)=>E(r,n).join(""))}function br(t){let n=xn(t),e=yr(t).map(xn).filter(a=>a>=2048).sort()[0],r=_t(e),o=pr(t);return{empty:!1,name:"",setNum:n,chroma:t,normalized:r,intervals:o}}function gr(t){if(t.length===0)return j.chroma;let n,e=[0,0,0,0,0,0,0,0,0,0,0,0];for(let r=0;rt.name).filter(t=>t)}function jr(){return K.map(t=>t.aliases[0]).filter(t=>t)}function xr(){return Object.keys(L)}function D(){return K.slice()}var Cr=P("ChordType.entries","ChordType.all",D);function Er(){K=[],L={}}function Dn(t,n,e){let r=_r(t),o={...h(t),name:e||"",quality:r,intervals:t,aliases:n};K.push(o),o.name&&(L[o.name]=o),L[o.setNum]=o,L[o.chroma]=o,o.aliases.forEach(a=>Dr(o,a))}function Dr(t,n){L[n]=t}function _r(t){let n=e=>t.indexOf(e)!==-1;return n("5A")?"Augmented":n("3M")?"Major":n("5d")?"Diminished":n("3m")?"Minor":"Unknown"}Nr.forEach(([t,n,e])=>Dn(t.split(" "),e.split(" "),n));K.sort((t,n)=>t.setNum-n.setNum);var Ft={names:Tr,symbols:jr,get:ut,all:D,add:Dn,removeAll:Er,keys:xr,entries:Cr,chordType:Sr};var wr=t=>{let n=t.reduce((e,r)=>{let o=s(r).chroma;return o!==void 0&&(e[o]=e[o]||s(r).name),e},{});return e=>n[e]};function Rt(t,n={}){let e=t.map(o=>s(o).pc).filter(o=>o);return s.length===0?[]:qr(e,1,n).filter(o=>o.weight).sort((o,a)=>a.weight-o.weight).map(o=>o.name)}var lt={anyThirds:384,perfectFifth:16,nonPerfectFifths:40,anySeventh:3},ft=t=>n=>!!(n&t),Vr=ft(lt.anyThirds),Fr=ft(lt.perfectFifth),Rr=ft(lt.anySeventh),Or=ft(lt.nonPerfectFifths);function kr(t){let n=parseInt(t.chroma,2);return Vr(n)&&Fr(n)&&Rr(n)}function $r(t){let n=parseInt(t,2);return Or(n)?t:(n|16).toString(2)}function qr(t,n,e){let r=t[0],o=s(r).chroma,a=wr(t),m=Y(t,!1),i=[];return m.forEach((c,f)=>{let p=e.assumePerfectFifth&&$r(c);D().filter(l=>e.assumePerfectFifth&&kr(l)?l.chroma===p:l.chroma===c).forEach(l=>{let b=l.aliases[0],M=a(f);f!==o?i.push({weight:.5*n,name:`${M}${b}/${r}`}):i.push({weight:1*n,name:`${M}${b}`})})}),i}function Gr(){return"1P 2M 3M 4P 5P 6m 7m".split(" ")}var _n=d,Lr=t=>d(t).name,zr=t=>d(t).semitones,Br=t=>d(t).q,Ur=t=>d(t).num;function Ot(t){let n=d(t);return n.empty?"":n.simple+n.q}function Hr(t){let n=d(t);if(n.empty)return"";let e=(7-n.step)%7,r=n.type==="perfectable"?-n.alt:-(n.alt+1);return d({step:e,alt:r,oct:n.oct,dir:n.dir}).name}var Xr=[1,2,2,3,3,4,5,5,6,6,7,7],Kr="P m M m M P d P m M m M".split(" ");function Jr(t){let n=t<0?-1:1,e=Math.abs(t),r=e%12,o=Math.floor(e/12);return n*(Xr[r]+7*o)+Kr[r]}var Qr=A,wn=Vn((t,n)=>[t[0]+n[0],t[1]+n[1]]),Zr=t=>n=>wn(t,n),kt=Vn((t,n)=>[t[0]-n[0],t[1]-n[1]]);function $t(t,n){let e=_n(t);if(e.empty)return"";let[r,o,a]=e.coord;return $([r+n,o,a]).name}var dt={names:Gr,get:_n,name:Lr,num:Ur,semitones:zr,quality:Br,fromSemitones:Jr,distance:Qr,invert:Hr,simplify:Ot,add:wn,addTo:Zr,subtract:kt,transposeFifths:$t};function Vn(t){return(n,e)=>{let r=d(n).coord,o=d(e).coord;if(r&&o){let a=t(r,o);return $(a).name}}}var Wr=[["1P 2M 3M 5P 6M","major pentatonic","pentatonic"],["1P 2M 3M 4P 5P 6M 7M","major","ionian"],["1P 2M 3m 4P 5P 6m 7m","minor","aeolian"],["1P 2M 3m 3M 5P 6M","major blues"],["1P 3m 4P 5d 5P 7m","minor blues","blues"],["1P 2M 3m 4P 5P 6M 7M","melodic minor"],["1P 2M 3m 4P 5P 6m 7M","harmonic minor"],["1P 2M 3M 4P 5P 6M 7m 7M","bebop"],["1P 2M 3m 4P 5d 6m 6M 7M","diminished","whole-half diminished"],["1P 2M 3m 4P 5P 6M 7m","dorian"],["1P 2M 3M 4A 5P 6M 7M","lydian"],["1P 2M 3M 4P 5P 6M 7m","mixolydian","dominant"],["1P 2m 3m 4P 5P 6m 7m","phrygian"],["1P 2m 3m 4P 5d 6m 7m","locrian"],["1P 3M 4P 5P 7M","ionian pentatonic"],["1P 3M 4P 5P 7m","mixolydian pentatonic","indian"],["1P 2M 4P 5P 6M","ritusen"],["1P 2M 4P 5P 7m","egyptian"],["1P 3M 4P 5d 7m","neopolitan major pentatonic"],["1P 3m 4P 5P 6m","vietnamese 1"],["1P 2m 3m 5P 6m","pelog"],["1P 2m 4P 5P 6m","kumoijoshi"],["1P 2M 3m 5P 6m","hirajoshi"],["1P 2m 4P 5d 7m","iwato"],["1P 2m 4P 5P 7m","in-sen"],["1P 3M 4A 5P 7M","lydian pentatonic","chinese"],["1P 3m 4P 6m 7m","malkos raga"],["1P 3m 4P 5d 7m","locrian pentatonic","minor seven flat five pentatonic"],["1P 3m 4P 5P 7m","minor pentatonic","vietnamese 2"],["1P 3m 4P 5P 6M","minor six pentatonic"],["1P 2M 3m 5P 6M","flat three pentatonic","kumoi"],["1P 2M 3M 5P 6m","flat six pentatonic"],["1P 2m 3M 5P 6M","scriabin"],["1P 3M 5d 6m 7m","whole tone pentatonic"],["1P 3M 4A 5A 7M","lydian #5P pentatonic"],["1P 3M 4A 5P 7m","lydian dominant pentatonic"],["1P 3m 4P 5P 7M","minor #7M pentatonic"],["1P 3m 4d 5d 7m","super locrian pentatonic"],["1P 2M 3m 4P 5P 7M","minor hexatonic"],["1P 2A 3M 5P 5A 7M","augmented"],["1P 2M 4P 5P 6M 7m","piongio"],["1P 2m 3M 4A 6M 7m","prometheus neopolitan"],["1P 2M 3M 4A 6M 7m","prometheus"],["1P 2m 3M 5d 6m 7m","mystery #1"],["1P 2m 3M 4P 5A 6M","six tone symmetric"],["1P 2M 3M 4A 5A 6A","whole tone","messiaen's mode #1"],["1P 2m 4P 4A 5P 7M","messiaen's mode #5"],["1P 2M 3M 4P 5d 6m 7m","locrian major","arabian"],["1P 2m 3M 4A 5P 6m 7M","double harmonic lydian"],["1P 2m 2A 3M 4A 6m 7m","altered","super locrian","diminished whole tone","pomeroy"],["1P 2M 3m 4P 5d 6m 7m","locrian #2","half-diminished","aeolian b5"],["1P 2M 3M 4P 5P 6m 7m","mixolydian b6","melodic minor fifth mode","hindu"],["1P 2M 3M 4A 5P 6M 7m","lydian dominant","lydian b7","overtone"],["1P 2M 3M 4A 5A 6M 7M","lydian augmented"],["1P 2m 3m 4P 5P 6M 7m","dorian b2","phrygian #6","melodic minor second mode"],["1P 2m 3m 4d 5d 6m 7d","ultralocrian","superlocrian bb7","superlocrian diminished"],["1P 2m 3m 4P 5d 6M 7m","locrian 6","locrian natural 6","locrian sharp 6"],["1P 2A 3M 4P 5P 5A 7M","augmented heptatonic"],["1P 2M 3m 4A 5P 6M 7m","dorian #4","ukrainian dorian","romanian minor","altered dorian"],["1P 2M 3m 4A 5P 6M 7M","lydian diminished"],["1P 2M 3M 4A 5A 7m 7M","leading whole tone"],["1P 2M 3M 4A 5P 6m 7m","lydian minor"],["1P 2m 3M 4P 5P 6m 7m","phrygian dominant","spanish","phrygian major"],["1P 2m 3m 4P 5P 6m 7M","balinese"],["1P 2m 3m 4P 5P 6M 7M","neopolitan major"],["1P 2M 3M 4P 5P 6m 7M","harmonic major"],["1P 2m 3M 4P 5P 6m 7M","double harmonic major","gypsy"],["1P 2M 3m 4A 5P 6m 7M","hungarian minor"],["1P 2A 3M 4A 5P 6M 7m","hungarian major"],["1P 2m 3M 4P 5d 6M 7m","oriental"],["1P 2m 3m 3M 4A 5P 7m","flamenco"],["1P 2m 3m 4A 5P 6m 7M","todi raga"],["1P 2m 3M 4P 5d 6m 7M","persian"],["1P 2m 3M 5d 6m 7m 7M","enigmatic"],["1P 2M 3M 4P 5A 6M 7M","major augmented","major #5","ionian augmented","ionian #5"],["1P 2A 3M 4A 5P 6M 7M","lydian #9"],["1P 2m 2M 4P 4A 5P 6m 7M","messiaen's mode #4"],["1P 2m 3M 4P 4A 5P 6m 7M","purvi raga"],["1P 2m 3m 3M 4P 5P 6m 7m","spanish heptatonic"],["1P 2M 3m 3M 4P 5P 6M 7m","bebop minor"],["1P 2M 3M 4P 5P 5A 6M 7M","bebop major"],["1P 2m 3m 4P 5d 5P 6m 7m","bebop locrian"],["1P 2M 3m 4P 5P 6m 7m 7M","minor bebop"],["1P 2M 3M 4P 5d 5P 6M 7M","ichikosucho"],["1P 2M 3m 4P 5P 6m 6M 7M","minor six diminished"],["1P 2m 3m 3M 4A 5P 6M 7m","half-whole diminished","dominant diminished","messiaen's mode #2"],["1P 3m 3M 4P 5P 6M 7m 7M","kafi raga"],["1P 2M 3M 4P 4A 5A 6A 7M","messiaen's mode #6"],["1P 2M 3m 3M 4P 5d 5P 6M 7m","composite blues"],["1P 2M 3m 3M 4A 5P 6m 7m 7M","messiaen's mode #3"],["1P 2m 2M 3m 4P 4A 5P 6m 6M 7M","messiaen's mode #7"],["1P 2m 2M 3m 3M 4P 5d 5P 6m 6M 7m 7M","chromatic"]],Yr=Wr,to={...j,intervals:[],aliases:[]},pt=[],z={};function qt(){return pt.map(t=>t.name)}function J(t){return z[t]||to}var no=P("ScaleDictionary.scaleType","ScaleType.get",J);function _(){return pt.slice()}var eo=P("ScaleDictionary.entries","ScaleType.all",_);function ro(){return Object.keys(z)}function oo(){pt=[],z={}}function Fn(t,n,e=[]){let r={...h(t),name:n,intervals:t,aliases:e};return pt.push(r),z[r.name]=r,z[r.setNum]=r,z[r.chroma]=r,r.aliases.forEach(o=>ao(r,o)),r}function ao(t,n){z[n]=t}Yr.forEach(([t,n,...e])=>Fn(t.split(" "),n,e));var Gt={names:qt,get:J,all:_,add:Fn,removeAll:oo,keys:ro,entries:eo,scaleType:no};var Rn={empty:!0,name:"",symbol:"",root:"",bass:"",rootDegree:0,type:"",tonic:null,setNum:NaN,quality:"Unknown",chroma:"",normalized:"",aliases:[],notes:[],intervals:[]};function tt(t){let[n,e,r,o]=U(t);return n===""?Lt("",t):n==="A"&&o==="ug"?Lt("","aug"):Lt(n+e,r+o)}function Lt(t,n){let e=n.split("/");if(e.length===1)return[t,e[0],""];let[r,o,a,m]=U(e[1]);return r!==""&&a===""&&m===""?[t,e[0],r+o]:[t,n,""]}function R(t){if(Array.isArray(t))return Mt(t[1]||"",t[0],t[2]);if(t==="")return Rn;{let[n,e,r]=tt(t),o=Mt(e,n,r);return o.empty?Mt(t):o}}function Mt(t,n,e){let r=ut(t),o=s(n||""),a=s(e||"");if(r.empty||n&&o.empty||e&&a.empty)return Rn;let m=A(o.pc,a.pc),i=r.intervals.indexOf(m),c=i>=0,f=c?a:s(""),p=i===-1?NaN:i+1,v=a.pc&&a.pc!==o.pc,l=Array.from(r.intervals);if(c)for(let O=1;Ou(o.pc,O));t=r.aliases.indexOf(t)!==-1?t:r.aliases[0];let M=`${o.empty?"":o.pc}${t}${c&&p>1?"/"+f.pc:v?"/"+a.pc:""}`,rt=`${n?o.pc+" ":""}${r.name}${c&&p>1?" over "+f.pc:v?" over "+a.pc:""}`;return{...r,name:rt,symbol:M,tonic:o.pc,type:r.name,root:f.pc,bass:v?a.pc:"",intervals:l,rootDegree:p,notes:b}}var mo=R;function io(t,n){let[e,r,o]=tt(t);if(!e)return t;let a=u(o,n),m=a?"/"+a:"";return u(e,n)+r+m}function so(t){let n=R(t),e=X(n.chroma);return _().filter(r=>e(r.chroma)).map(r=>r.name)}function co(t){let n=R(t),e=X(n.chroma);return D().filter(r=>e(r.chroma)).map(r=>n.tonic+r.aliases[0])}function uo(t){let n=R(t),e=H(n.chroma);return D().filter(r=>e(r.chroma)).map(r=>n.tonic+r.aliases[0])}function lo(t,n){let e=R(t),r=n||e.tonic;return!r||e.empty?[]:e.intervals.map(o=>u(r,o))}function fo(t,n){let e=R(t),r=n||e.tonic,o=F(e.intervals,r);return a=>a?o(a>0?a-1:a):""}function po(t,n){let e=R(t),r=n||e.tonic;return F(e.intervals,r)}var Q={getChord:Mt,get:R,detect:Rt,chordScales:so,extended:co,reduced:uo,tokenize:tt,transpose:io,degrees:fo,steps:po,notes:lo,chord:mo};var Mo=[[.125,"dl",["large","duplex longa","maxima","octuple","octuple whole"]],[.25,"l",["long","longa"]],[.5,"d",["double whole","double","breve"]],[1,"w",["whole","semibreve"]],[2,"h",["half","minim"]],[4,"q",["quarter","crotchet"]],[8,"e",["eighth","quaver"]],[16,"s",["sixteenth","semiquaver"]],[32,"t",["thirty-second","demisemiquaver"]],[64,"sf",["sixty-fourth","hemidemisemiquaver"]],[128,"h",["hundred twenty-eighth"]],[256,"th",["two hundred fifty-sixth"]]],Po=Mo,Pt=[];Po.forEach(([t,n,e])=>No(t,n,e));var ho={empty:!0,name:"",value:0,fraction:[0,0],shorthand:"",dots:"",names:[]};function vo(){return Pt.reduce((t,n)=>(n.names.forEach(e=>t.push(e)),t),[])}function yo(){return Pt.map(t=>t.shorthand)}var bo=/^([^.]+)(\.*)$/;function zt(t){let[n,e,r]=bo.exec(t)||[],o=Pt.find(i=>i.shorthand===e||i.names.includes(e));if(!o)return ho;let a=Io(o.fraction,r.length),m=a[0]/a[1];return{...o,name:t,dots:r,value:m,fraction:a}}var go=t=>zt(t).value,Ao=t=>zt(t).fraction,On={names:vo,shorthands:yo,get:zt,value:go,fraction:Ao};function No(t,n,e){Pt.push({empty:!1,dots:"",name:"",value:1/t,fraction:t<1?[1/t,1]:[1,t],shorthand:n,names:e})}function Io(t,n){let e=Math.pow(2,n),r=t[0]*e,o=t[1]*e,a=r;for(let m=0;m=0&&+t<=127}function Bt(t){if(kn(t))return+t;let n=s(t);return n.empty?null:n.midi}function So(t,n=440){return Math.pow(2,(t-69)/12)*n}var To=Math.log(2),jo=Math.log(440);function ht(t){let n=12*(Math.log(t)-jo)/To+69;return Math.round(n*100)/100}var xo="C C# D D# E F F# G G# A A# B".split(" "),Co="C Db D Eb E F Gb G Ab A Bb B".split(" ");function x(t,n={}){if(isNaN(t)||t===-1/0||t===1/0)return"";t=Math.round(t);let r=(n.sharps===!0?xo:Co)[t%12];if(n.pitchClass)return r;let o=Math.floor(t/12)-1;return r+o}function Ut(t){return t%12}function Eo(t){return t.split("").reduce((n,e,r)=>(r<12&&e==="1"&&n.push(r),n),[])}function Do(t){return t.map(Ut).sort((n,e)=>n-e).filter((n,e,r)=>e===0||n!==r[e-1])}function Ht(t){return Array.isArray(t)?Do(t):Eo(t)}function _o(t){let n=Ht(t);return e=>{let r=Ut(e);for(let o=0;o<12;o++){if(n.includes(r+o))return e+o;if(n.includes(r-o))return e-o}}}function $n(t,n){let e=Ht(t),r=e.length;return o=>{let a=o<0?(r- -o%r)%r:o%r,m=Math.floor(o/r);return e[a]+m*12+n}}function wo(t,n){let e=$n(t,n);return r=>{if(r!==0)return e(r>0?r-1:r)}}var qn={chroma:Ut,freqToMidi:ht,isMidi:kn,midiToFreq:So,midiToNoteName:x,pcsetNearest:_o,pcset:Ht,pcsetDegrees:wo,pcsetSteps:$n,toMidi:Bt};var Vo=["C","D","E","F","G","A","B"],Gn=t=>t.name,Ln=t=>t.map(s).filter(n=>!n.empty);function Fo(t){return t===void 0?Vo.slice():Array.isArray(t)?Ln(t).map(Gn):[]}var N=s,Ro=t=>N(t).name,Oo=t=>N(t).pc,ko=t=>N(t).acc,$o=t=>N(t).oct,qo=t=>N(t).midi,Go=t=>N(t).freq,Lo=t=>N(t).chroma;function Xt(t){return x(t)}function zo(t){return x(ht(t))}function Bo(t){return x(ht(t),{sharps:!0})}function Uo(t){return x(t,{sharps:!0})}var nt=u,Ho=u,zn=t=>n=>nt(n,t),Xo=zn,Bn=t=>n=>nt(t,n),Ko=Bn;function et(t,n){return nt(t,[n,0])}var Jo=et;function Qo(t,n){return nt(t,[0,n])}var Kt=(t,n)=>t.height-n.height,Zo=(t,n)=>n.height-t.height;function Un(t,n){return n=n||Kt,Ln(t).sort(n).map(Gn)}function Jt(t){return Un(t,Kt).filter((n,e,r)=>e===0||n!==r[e-1])}var Wo=t=>{let n=N(t);return n.empty?"":x(n.midi||n.chroma,{sharps:n.alt>0,pitchClass:n.midi===null})};function Qt(t,n){let e=N(t);if(e.empty)return"";let r=N(n||x(e.midi||e.chroma,{sharps:e.alt<0,pitchClass:!0}));if(r.empty||r.chroma!==e.chroma)return"";if(e.oct===void 0)return r.pc;let o=e.chroma-e.alt,a=r.chroma-r.alt,m=o>11||a<0?-1:o<0||a>11?1:0,i=e.oct+m;return r.pc+i}var y={names:Fo,get:N,name:Ro,pitchClass:Oo,accidentals:ko,octave:$o,midi:qo,ascending:Kt,descending:Zo,sortedNames:Un,sortedUniqNames:Jt,fromMidi:Xt,fromMidiSharps:Uo,freq:Go,fromFreq:zo,fromFreqSharps:Bo,chroma:Lo,transpose:nt,tr:Ho,transposeBy:zn,trBy:Xo,transposeFrom:Bn,trFrom:Ko,transposeFifths:et,transposeOctaves:Qo,trFifths:Jo,simplify:Wo,enharmonic:Qt};var Xn={empty:!0,name:"",chordType:""},Hn={};function I(t){return typeof t=="string"?Hn[t]||(Hn[t]=aa(t)):typeof t=="number"?I(vt[t]||""):T(t)?na(t):it(t)?I(t.name):Xn}var Yo=P("RomanNumeral.romanNumeral","RomanNumeral.get",I);function ta(t=!0){return(t?vt:oa).slice()}function na(t){return I(V(t.alt)+vt[t.step])}var ea=/^(#{1,}|b{1,}|x{1,}|)(IV|I{1,3}|VI{0,2}|iv|i{1,3}|vi{0,2})([^IViv]*)$/;function ra(t){return ea.exec(t)||["","","",""]}var Kn="I II III IV V VI VII",vt=Kn.split(" "),oa=Kn.toLowerCase().split(" ");function aa(t){let[n,e,r,o]=ra(t);if(!r)return Xn;let a=r.toUpperCase(),m=vt.indexOf(a),i=q(e),c=1;return{empty:!1,name:n,roman:r,interval:d({step:m,alt:i,dir:c}).name,acc:e,chordType:o,alt:i,step:m,major:r===a,oct:0,dir:c}}var Jn={names:ta,get:I,romanNumeral:Yo};var g=Object.freeze([]),Qn={type:"major",tonic:"",alteration:0,keySignature:""},yt={tonic:"",grades:g,intervals:g,scale:g,triads:g,chords:g,chordsHarmonicFunction:g,chordScales:g},ma={...Qn,...yt,type:"major",minorRelative:"",scale:g,secondaryDominants:g,secondaryDominantsMinorRelative:g,substituteDominants:g,substituteDominantsMinorRelative:g},ia={...Qn,type:"minor",relativeMajor:"",natural:yt,harmonic:yt,melodic:yt},Zt=(t,n,e="")=>n.map((r,o)=>`${t[o]}${e}${r}`);function bt(t,n,e,r,o){return a=>{let m=t.map(c=>I(c).interval||""),i=m.map(c=>u(a,c));return{tonic:a,grades:t,intervals:m,scale:i,triads:Zt(i,n),chords:Zt(i,e),chordsHarmonicFunction:r.slice(),chordScales:Zt(i,o," ")}}}var Zn=(t,n)=>{let e=s(t),r=s(n);return e.empty||r.empty?0:r.coord[0]-e.coord[0]},sa=bt("I II III IV V VI VII".split(" ")," m m m dim".split(" "),"maj7 m7 m7 maj7 7 m7 m7b5".split(" "),"T SD T SD D T D".split(" "),"major,dorian,phrygian,lydian,mixolydian,minor,locrian".split(",")),ca=bt("I II bIII IV V bVI bVII".split(" "),"m dim m m ".split(" "),"m7 m7b5 maj7 m7 m7 maj7 7".split(" "),"T SD T SD D SD SD".split(" "),"minor,locrian,major,dorian,phrygian,lydian,mixolydian".split(",")),ua=bt("I II bIII IV V bVI VII".split(" "),"m dim aug m dim".split(" "),"mMaj7 m7b5 +maj7 m7 7 maj7 o7".split(" "),"T SD T SD D SD D".split(" "),"harmonic minor,locrian 6,major augmented,lydian diminished,phrygian dominant,lydian #9,ultralocrian".split(",")),la=bt("I II bIII IV V VI VII".split(" "),"m m aug dim dim".split(" "),"m6 m7 +maj7 7 7 m7b5 m7b5".split(" "),"T SD T SD D ".split(" "),"melodic minor,dorian b2,lydian augmented,lydian dominant,mixolydian b6,locrian #2,altered".split(","));function fa(t){let n=s(t).pc;if(!n)return ma;let e=sa(n),r=Zn("C",n),o=a=>{let m=I(a);return m.empty?"":u(t,m.interval)+m.chordType};return{...e,type:"major",minorRelative:u(n,"-3m"),alteration:r,keySignature:V(r),secondaryDominants:"- VI7 VII7 I7 II7 III7 -".split(" ").map(o),secondaryDominantsMinorRelative:"- IIIm7b5 IV#m7 Vm7 VIm7 VIIm7b5 -".split(" ").map(o),substituteDominants:"- bIII7 IV7 bV7 bVI7 bVII7 -".split(" ").map(o),substituteDominantsMinorRelative:"- IIIm7 Im7 IIbm7 VIm7 IVm7 -".split(" ").map(o)}}function da(t){let n=s(t).pc;if(!n)return ia;let e=Zn("C",n)-3;return{type:"minor",tonic:n,relativeMajor:u(n,"3m"),alteration:e,keySignature:V(e),natural:ca(n),harmonic:ua(n),melodic:la(n)}}function pa(t){return typeof t=="number"?et("C",t):typeof t=="string"&&/^b+|#+$/.test(t)?et("C",q(t)):null}var Wn={majorKey:fa,majorTonicFromKeySignature:pa,minorKey:da};var Yt=[[0,2773,0,"ionian","","Maj7","major"],[1,2902,2,"dorian","m","m7"],[2,3418,4,"phrygian","m","m7"],[3,2741,-1,"lydian","","Maj7"],[4,2774,1,"mixolydian","","7"],[5,2906,3,"aeolian","m","m7","minor"],[6,3434,5,"locrian","dim","m7b5"]],Yn={...j,name:"",alt:0,modeNum:NaN,triad:"",seventh:"",aliases:[]},tn=Yt.map(va),Wt={};tn.forEach(t=>{Wt[t.name]=t,t.aliases.forEach(n=>{Wt[n]=t})});function B(t){return typeof t=="string"?Wt[t.toLowerCase()]||Yn:t&&t.name?B(t.name):Yn}var Ma=P("Mode.mode","Mode.get",B);function te(){return tn.slice()}var Pa=P("Mode.mode","Mode.all",te);function ha(){return tn.map(t=>t.name)}function va(t){let[n,e,r,o,a,m,i]=t,c=i?[i]:[],f=Number(e).toString(2);return{empty:!1,intervals:J(o).intervals,modeNum:n,chroma:f,normalized:f,name:o,setNum:e,alt:r,triad:a,seventh:m,aliases:c}}function ya(t,n){return B(t).intervals.map(e=>u(n,e))}function ne(t){return(n,e)=>{let r=B(n);if(r.empty)return[];let o=E(r.modeNum,t),a=r.intervals.map(m=>u(e,m));return o.map((m,i)=>a[i]+m)}}var ba=ne(Yt.map(t=>t[4])),ga=ne(Yt.map(t=>t[5]));function ee(t,n){let e=B(n),r=B(t);return e.empty||r.empty?"":Ot($t("1P",r.alt-e.alt))}function Aa(t,n,e){return u(e,ee(t,n))}var re={get:B,names:ha,all:te,distance:ee,relativeTonic:Aa,notes:ya,triads:ba,seventhChords:ga,entries:Pa,mode:Ma};function Na(t,n){return n.map(I).map(r=>u(t,d(r))+r.chordType)}function Ia(t,n){return n.map(e=>{let[r,o]=tt(e),a=A(t,r);return I(d(a)).name+o})}var oe={fromRomanNumerals:Na,toRomanNumerals:Ia};function ae(t){let n=W(t.map(e=>typeof e=="number"?e:Bt(e)));return!t.length||n.length!==t.length?[]:n.reduce((e,r)=>{let o=e[e.length-1];return e.concat(G(o,r).slice(1))},[n[0]])}function Sa(t,n){return ae(t).map(e=>x(e,n))}var gt={numeric:ae,chromatic:Sa};var Ta={empty:!0,name:"",type:"",tonic:null,setNum:NaN,chroma:"",normalized:"",aliases:[],notes:[],intervals:[]};function me(t){if(typeof t!="string")return["",""];let n=t.indexOf(" "),e=s(t.substring(0,n));if(e.empty){let o=s(t);return o.empty?["",t]:[o.name,""]}let r=t.substring(e.name.length+1);return[e.name,r.length?r:""]}var ja=qt;function C(t){let n=Array.isArray(t)?t:me(t),e=s(n[0]).name,r=J(n[1]);if(r.empty)return Ta;let o=r.name,a=e?r.intervals.map(i=>u(e,i)):[],m=e?e+" "+o:o;return{...r,name:m,type:o,tonic:e,notes:a}}var xa=P("Scale.scale","Scale.get",C);function Ca(t,n={}){let e=wt(t),r=s(n.tonic??t[0]??""),o=r.chroma;if(o===void 0)return[];let a=e.split("");a[o]="1";let m=E(o,a).join(""),i=_().find(f=>f.chroma===m),c=[];return i&&c.push(r.name+" "+i.name),n.match==="exact"||ie(m).forEach(f=>{c.push(r.name+" "+f)}),c}function Ea(t){let n=C(t),e=H(n.chroma);return D().filter(r=>e(r.chroma)).map(r=>r.aliases[0])}function ie(t){let n=ct(t)?t:C(t).chroma,e=X(n);return _().filter(r=>e(r.chroma)).map(r=>r.name)}function Da(t){let n=H(C(t).chroma);return _().filter(e=>n(e.chroma)).map(e=>e.name)}function se(t){let n=t.map(o=>s(o).pc).filter(o=>o),e=n[0],r=Jt(n);return E(r.indexOf(e),r)}function _a(t){let n=C(t);if(n.empty)return[];let e=n.tonic?n.notes:n.intervals;return Y(n.chroma).map((r,o)=>{let a=C(r).name;return a?[e[o],a]:["",""]}).filter(r=>r[0])}function wa(t){let n=Array.isArray(t)?se(t):C(t).notes,e=n.map(r=>s(r).chroma);return r=>{let o=typeof r=="number"?s(Xt(r)):s(r),a=o.height;if(a===void 0)return;let m=a%12,i=e.indexOf(m);if(i!==-1)return Qt(o.name,n[i])}}function Va(t){let n=wa(t);return(e,r)=>{let o=s(e).height,a=s(r).height;return o===void 0||a===void 0?[]:G(o,a).map(n).filter(m=>m)}}function Fa(t){let{intervals:n,tonic:e}=C(t),r=F(n,e);return o=>o?r(o>0?o-1:o):""}function Ra(t){let{intervals:n,tonic:e}=C(t);return F(n,e)}var ce={degrees:Fa,detect:Ca,extended:ie,get:C,modeNames:_a,names:ja,rangeOf:Va,reduced:Da,scaleChords:Ea,scaleNotes:se,steps:Ra,tokenize:me,scale:xa};var Oa={empty:!0,name:"",upper:void 0,lower:void 0,type:void 0,additive:[]},ka=["4/4","3/4","2/4","2/2","12/8","9/8","6/8","3/8"];function $a(){return ka.slice()}var qa=/^(\d*\d(?:\+\d)*)\/(\d+)$/,ue=new Map;function Ga(t){let n=JSON.stringify(t),e=ue.get(n);if(e)return e;let r=za(nn(t));return ue.set(n,r),r}function nn(t){if(typeof t=="string"){let[a,m,i]=qa.exec(t)||[];return nn([m,i])}let[n,e]=t,r=+e;if(typeof n=="number")return[n,r];let o=n.split("+").map(a=>+a);return o.length===1?[o[0],r]:[o,r]}var le={names:$a,parse:nn,get:Ga},La=t=>Math.log(t)/Math.log(2)%1===0;function za([t,n]){let e=Array.isArray(t)?t.reduce((i,c)=>i+c,0):t,r=n;if(e===0||r===0)return Oa;let o=Array.isArray(t)?`${t.join("+")}/${n}`:`${t}/${n}`,a=Array.isArray(t)?t:[],m=r===4||r===2?"simple":r===8&&e%3===0?"compound":La(r)?"irregular":"irrational";return{empty:!1,name:o,type:m,upper:e,lower:r,additive:a}}var Ba=(t,n)=>{if(!n||!n.length)return t[0];let e=o=>y.midi(o[o.length-1])||0,r=o=>Math.abs(e(n)-e(o));return t.sort((o,a)=>r(o)-r(a))[0]},At={topNoteDiff:Ba};var Ua={M:["1P 3M 5P","3M 5P 8P","5P 8P 10M"],m:["1P 3m 5P","3m 5P 8P","5P 8P 10m"],o:["1P 3m 5d","3m 5d 8P","5d 8P 10m"],aug:["1P 3m 5A","3m 5A 8P","5A 8P 10m"]},fe={m7:["3m 5P 7m 9M","7m 9M 10m 12P"],7:["3M 6M 7m 9M","7m 9M 10M 13M"],"^7":["3M 5P 7M 9M","7M 9M 10M 12P"],69:["3M 5P 6A 9M"],m7b5:["3m 5d 7m 8P","7m 8P 10m 12d"],"7b9":["3M 6m 7m 9m","7m 9m 10M 13m"],"7b13":["3M 6m 7m 9m","7m 9m 10M 13m"],o7:["1P 3m 5d 6M","5d 6M 8P 10m"],"7#11":["7m 9M 11A 13A"],"7#9":["3M 7m 9A"],mM7:["3m 5P 7M 9M","7M 9M 10m 12P"],m6:["3m 5P 6M 9M","6M 9M 10m 12P"]},Ha={M:["1P 3M 5P","3M 5P 8P","5P 8P 10M"],m:["1P 3m 5P","3m 5P 8P","5P 8P 10m"],o:["1P 3m 5d","3m 5d 8P","5d 8P 10m"],aug:["1P 3m 5A","3m 5A 8P","5A 8P 10m"],m7:["3m 5P 7m 9M","7m 9M 10m 12P"],7:["3M 6M 7m 9M","7m 9M 10M 13M"],"^7":["3M 5P 7M 9M","7M 9M 10M 12P"],69:["3M 5P 6A 9M"],m7b5:["3m 5d 7m 8P","7m 8P 10m 12d"],"7b9":["3M 6m 7m 9m","7m 9m 10M 13m"],"7b13":["3M 6m 7m 9m","7m 9m 10M 13m"],o7:["1P 3m 5d 6M","5d 6M 8P 10m"],"7#11":["7m 9M 11A 13A"],"7#9":["3M 7m 9A"],mM7:["3m 5P 7M 9M","7M 9M 10m 12P"],m6:["3m 5P 6M 9M","6M 9M 10m 12P"]},de=fe;function Xa(t,n=de){if(n[t])return n[t];let{aliases:e}=Q.get("C"+t),r=Object.keys(n).find(o=>e.includes(o))||"";if(r!==void 0)return n[r]}var Z={lookup:Xa,lefthand:fe,triads:Ua,all:Ha,defaultDictionary:de};var en=["C3","C5"],pe=Z.all,Me=At.topNoteDiff;function Pe(t,n=en,e=pe,r=Me,o){let a=he(t,n,e);return!o||!o.length?a[0]:r(a,o)}function he(t,n=en,e=Z.triads){let[r,o]=Q.tokenize(t),a=Z.lookup(o,e);if(!a)return[];let m=a.map(c=>c.split(" ")),i=gt.chromatic(n);return m.reduce((c,f)=>{let p=f.map(M=>dt.subtract(M,f[0])||""),v=y.transpose(r,f[0]),b=i.filter(M=>y.chroma(M)===y.chroma(v)).filter(M=>(y.midi(y.transpose(M,p[p.length-1]))||0)<=(y.midi(n[1])||0)).map(M=>y.enharmonic(M,v)).map(M=>p.map(rt=>y.transpose(M,rt)));return c.concat(b)},[])}function Ka(t,n=en,e=pe,r=Me,o){let{voicings:a}=t.reduce(({voicings:m,lastVoicing:i},c)=>{let f=Pe(c,n,e,r,i);return i=f,m.push(f),{voicings:m,lastVoicing:i}},{voicings:[],lastVoicing:o});return a}var ve={get:Pe,search:he,sequence:Ka};var Ja=st,Qa=Vt,Za=Ft,Wa=Gt;return Te(Ya);})(); //# sourceMappingURL=tonal.min.js.map diff --git a/packages/tonal/browser/tonal.min.js.map b/packages/tonal/browser/tonal.min.js.map index a984cdd4..7ed88682 100644 --- a/packages/tonal/browser/tonal.min.js.map +++ b/packages/tonal/browser/tonal.min.js.map @@ -1,7 +1,7 @@ { "version": 3, - "sources": ["../index.ts", "../../pitch/index.ts", "../../pitch-interval/index.ts", "../../pitch-note/index.ts", "../../pitch-distance/index.ts", "../../abc-notation/node_modules/@tonaljs/pitch-note/index.ts", "../../abc-notation/index.ts", "../../array/node_modules/@tonaljs/pitch-note/index.ts", "../../array/index.ts", "../../core/index.ts", "../../collection/index.ts", "../../pcset/index.ts", "../../chord-type/index.ts", "../../chord-type/data.ts", "../../chord-detect/index.ts", "../../interval/index.ts", "../../scale-type/index.ts", "../../scale-type/data.ts", "../../chord/index.ts", "../../duration-value/data.ts", "../../duration-value/index.ts", "../../midi/index.ts", "../../note/index.ts", "../../roman-numeral/index.ts", "../../key/index.ts", "../../mode/index.ts", "../../progression/index.ts", "../../range/index.ts", "../../scale/index.ts", "../../time-signature/index.ts", "../../voice-leading/index.ts", "../../voicing-dictionary/index.ts", "../../voicing-dictionary/data.ts", "../../voicing/index.ts"], - "sourcesContent": ["import AbcNotation from \"@tonaljs/abc-notation\";\nimport * as Array from \"@tonaljs/array\";\nimport Chord from \"@tonaljs/chord\";\nimport ChordType from \"@tonaljs/chord-type\";\nimport Collection from \"@tonaljs/collection\";\nimport * as Core from \"@tonaljs/core\";\nimport DurationValue from \"@tonaljs/duration-value\";\nimport Interval from \"@tonaljs/interval\";\nimport Key from \"@tonaljs/key\";\nimport Midi from \"@tonaljs/midi\";\nimport Mode from \"@tonaljs/mode\";\nimport Note from \"@tonaljs/note\";\nimport Pcset from \"@tonaljs/pcset\";\nimport Progression from \"@tonaljs/progression\";\nimport Range from \"@tonaljs/range\";\nimport RomanNumeral from \"@tonaljs/roman-numeral\";\nimport Scale from \"@tonaljs/scale\";\nimport ScaleType from \"@tonaljs/scale-type\";\nimport TimeSignature from \"@tonaljs/time-signature\";\nimport VoiceLeading from \"@tonaljs/voice-leading\";\nimport Voicing from \"@tonaljs/voicing\";\nimport VoicingDictionary from \"@tonaljs/voicing-dictionary\";\n\nexport * from \"@tonaljs/core\";\n\n// deprecated (backwards compatibility)\nconst Tonal = Core;\nconst PcSet = Pcset;\nconst ChordDictionary = ChordType;\nconst ScaleDictionary = ScaleType;\n\nexport {\n AbcNotation,\n Array,\n Chord,\n ChordDictionary,\n ChordType,\n Collection,\n Core,\n DurationValue,\n Interval,\n Key,\n Midi,\n Mode,\n Note,\n PcSet,\n Pcset,\n Progression,\n Range,\n RomanNumeral,\n Scale,\n ScaleDictionary,\n ScaleType,\n TimeSignature,\n Tonal,\n VoiceLeading,\n Voicing,\n VoicingDictionary,\n};\n", "export interface NamedPitch {\n readonly name: string;\n}\n\n/*** @deprecated use NamedPitch */\nexport interface Named {\n readonly name: string;\n}\n\nexport interface NotFound extends NamedPitch {\n readonly empty: true;\n readonly name: \"\";\n}\n\nexport function isNamedPitch(src: unknown): src is NamedPitch {\n return src !== null &&\n typeof src === \"object\" &&\n \"name\" in src &&\n typeof src.name === \"string\"\n ? true\n : false;\n}\n\ntype Fifths = number;\ntype Octaves = number;\nexport type Direction = 1 | -1;\n\nexport type PitchClassCoordinates = [Fifths];\nexport type NoteCoordinates = [Fifths, Octaves];\nexport type IntervalCoordinates = [Fifths, Octaves, Direction];\nexport type PitchCoordinates =\n | PitchClassCoordinates\n | NoteCoordinates\n | IntervalCoordinates;\n\n/**\n * Pitch properties\n *\n * - {number} step - The step number: 0 = C, 1 = D, ... 6 = B\n * - {number} alt - Number of alterations: -2 = 'bb', -1 = 'b', 0 = '', 1 = '#', ...\n * - {number} [oct] = The octave (undefined when is a coord class)\n * - {number} [dir] = Interval direction (undefined when is not an interval)\n */\nexport interface Pitch {\n readonly step: number;\n readonly alt: number;\n readonly oct?: number; // undefined for pitch classes\n readonly dir?: Direction; // undefined for notes\n}\n\nconst SIZES = [0, 2, 4, 5, 7, 9, 11];\nexport const chroma = ({ step, alt }: Pitch) => (SIZES[step] + alt + 120) % 12;\n\nexport const height = ({ step, alt, oct, dir = 1 }: Pitch) =>\n dir * (SIZES[step] + alt + 12 * (oct === undefined ? -100 : oct));\n\nexport const midi = (pitch: Pitch) => {\n const h = height(pitch);\n return pitch.oct !== undefined && h >= -12 && h <= 115 ? h + 12 : null;\n};\n\nexport function isPitch(pitch: unknown): pitch is Pitch {\n return pitch !== null &&\n typeof pitch === \"object\" &&\n \"step\" in pitch &&\n typeof pitch.step === \"number\" &&\n \"alt\" in pitch &&\n typeof pitch.alt === \"number\" &&\n !isNaN(pitch.step) &&\n !isNaN(pitch.alt)\n ? true\n : false;\n}\n\n// The number of fifths of [C, D, E, F, G, A, B]\nconst FIFTHS = [0, 2, 4, -1, 1, 3, 5];\n// The number of octaves it span each step\nconst STEPS_TO_OCTS = FIFTHS.map((fifths: number) =>\n Math.floor((fifths * 7) / 12),\n);\n\n/**\n * Get coordinates from pitch object\n */\nexport function coordinates(pitch: Pitch): PitchCoordinates {\n const { step, alt, oct, dir = 1 } = pitch;\n const f = FIFTHS[step] + 7 * alt;\n if (oct === undefined) {\n return [dir * f];\n }\n const o = oct - STEPS_TO_OCTS[step] - 4 * alt;\n return [dir * f, dir * o];\n}\n\n// We need to get the steps from fifths\n// Fifths for CDEFGAB are [ 0, 2, 4, -1, 1, 3, 5 ]\n// We add 1 to fifths to avoid negative numbers, so:\n// for [\"F\", \"C\", \"G\", \"D\", \"A\", \"E\", \"B\"] we have:\nconst FIFTHS_TO_STEPS = [3, 0, 4, 1, 5, 2, 6];\n\n/**\n * Get pitch from coordinate objects\n */\nexport function pitch(coord: PitchCoordinates): Pitch {\n const [f, o, dir] = coord;\n const step = FIFTHS_TO_STEPS[unaltered(f)];\n const alt = Math.floor((f + 1) / 7);\n if (o === undefined) {\n return { step, alt, dir };\n }\n const oct = o + 4 * alt + STEPS_TO_OCTS[step];\n return { step, alt, oct, dir };\n}\n\n// Return the number of fifths as if it were unaltered\nfunction unaltered(f: number): number {\n const i = (f + 1) % 7;\n return i < 0 ? 7 + i : i;\n}\n", "import {\n coordinates,\n Direction,\n IntervalCoordinates,\n isNamedPitch,\n isPitch,\n NamedPitch,\n Pitch,\n pitch,\n PitchCoordinates,\n} from \"@tonaljs/pitch\";\n\nconst fillStr = (s: string, n: number) => Array(Math.abs(n) + 1).join(s);\n\nexport type IntervalName = string;\nexport type IntervalLiteral = IntervalName | Pitch | NamedPitch;\n\ntype Quality =\n | \"dddd\"\n | \"ddd\"\n | \"dd\"\n | \"d\"\n | \"m\"\n | \"M\"\n | \"P\"\n | \"A\"\n | \"AA\"\n | \"AAA\"\n | \"AAAA\";\ntype Type = \"perfectable\" | \"majorable\";\n\nexport interface Interval extends Pitch, NamedPitch {\n readonly empty: boolean;\n readonly name: IntervalName;\n readonly num: number;\n readonly q: Quality;\n readonly type: Type;\n readonly step: number;\n readonly alt: number;\n readonly dir: Direction;\n readonly simple: number;\n readonly semitones: number;\n readonly chroma: number;\n readonly coord: IntervalCoordinates;\n readonly oct: number;\n}\n\nconst NoInterval: Interval = Object.freeze({\n empty: true,\n name: \"\",\n num: NaN,\n q: \"\" as Quality,\n type: \"\" as Type,\n step: NaN,\n alt: NaN,\n dir: NaN as Direction,\n simple: NaN,\n semitones: NaN,\n chroma: NaN,\n coord: [] as unknown as IntervalCoordinates,\n oct: NaN,\n});\n\n// shorthand tonal notation (with quality after number)\nconst INTERVAL_TONAL_REGEX = \"([-+]?\\\\d+)(d{1,4}|m|M|P|A{1,4})\";\n// standard shorthand notation (with quality before number)\nconst INTERVAL_SHORTHAND_REGEX = \"(AA|A|P|M|m|d|dd)([-+]?\\\\d+)\";\nconst REGEX = new RegExp(\n \"^\" + INTERVAL_TONAL_REGEX + \"|\" + INTERVAL_SHORTHAND_REGEX + \"$\",\n);\n\ntype IntervalTokens = [string, string];\n\n/**\n * @private\n */\nexport function tokenizeInterval(str?: IntervalName): IntervalTokens {\n const m = REGEX.exec(`${str}`);\n if (m === null) {\n return [\"\", \"\"];\n }\n return m[1] ? [m[1], m[2]] : [m[4], m[3]];\n}\n\nconst cache: { [key in string]: Interval } = {};\n\n/**\n * Get interval properties. It returns an object with:\n *\n * - name: the interval name\n * - num: the interval number\n * - type: 'perfectable' or 'majorable'\n * - q: the interval quality (d, m, M, A)\n * - dir: interval direction (1 ascending, -1 descending)\n * - simple: the simplified number\n * - semitones: the size in semitones\n * - chroma: the interval chroma\n *\n * @param {string} interval - the interval name\n * @return {Object} the interval properties\n *\n * @example\n * import { interval } from '@tonaljs/core'\n * interval('P5').semitones // => 7\n * interval('m3').type // => 'majorable'\n */\nexport function interval(src: IntervalLiteral): Interval {\n return typeof src === \"string\"\n ? cache[src] || (cache[src] = parse(src))\n : isPitch(src)\n ? interval(pitchName(src))\n : isNamedPitch(src)\n ? interval(src.name)\n : NoInterval;\n}\n\nconst SIZES = [0, 2, 4, 5, 7, 9, 11];\nconst TYPES = \"PMMPPMM\";\nfunction parse(str?: string): Interval {\n const tokens = tokenizeInterval(str);\n if (tokens[0] === \"\") {\n return NoInterval;\n }\n const num = +tokens[0];\n const q = tokens[1] as Quality;\n const step = (Math.abs(num) - 1) % 7;\n const t = TYPES[step];\n if (t === \"M\" && q === \"P\") {\n return NoInterval;\n }\n const type = t === \"M\" ? \"majorable\" : \"perfectable\";\n\n const name = \"\" + num + q;\n const dir = num < 0 ? -1 : 1;\n const simple = num === 8 || num === -8 ? num : dir * (step + 1);\n const alt = qToAlt(type, q);\n const oct = Math.floor((Math.abs(num) - 1) / 7);\n const semitones = dir * (SIZES[step] + alt + 12 * oct);\n const chroma = (((dir * (SIZES[step] + alt)) % 12) + 12) % 12;\n const coord = coordinates({ step, alt, oct, dir }) as IntervalCoordinates;\n return {\n empty: false,\n name,\n num,\n q,\n step,\n alt,\n dir,\n type,\n simple,\n semitones,\n chroma,\n coord,\n oct,\n };\n}\n\n/**\n * @private\n *\n * forceDescending is used in the case of unison (#243)\n */\nexport function coordToInterval(\n coord: PitchCoordinates,\n forceDescending?: boolean,\n): Interval {\n const [f, o = 0] = coord;\n const isDescending = f * 7 + o * 12 < 0;\n const ivl: IntervalCoordinates =\n forceDescending || isDescending ? [-f, -o, -1] : [f, o, 1];\n return interval(pitch(ivl)) as Interval;\n}\n\nfunction qToAlt(type: Type, q: string): number {\n return (q === \"M\" && type === \"majorable\") ||\n (q === \"P\" && type === \"perfectable\")\n ? 0\n : q === \"m\" && type === \"majorable\"\n ? -1\n : /^A+$/.test(q)\n ? q.length\n : /^d+$/.test(q)\n ? -1 * (type === \"perfectable\" ? q.length : q.length + 1)\n : 0;\n}\n\n// return the interval name of a pitch\nfunction pitchName(props: Pitch): string {\n const { step, alt, oct = 0, dir } = props;\n if (!dir) {\n return \"\";\n }\n const calcNum = step + 1 + 7 * oct;\n // this is an edge case: descending pitch class unison (see #243)\n const num = calcNum === 0 ? step + 1 : calcNum;\n const d = dir < 0 ? \"-\" : \"\";\n const type = TYPES[step] === \"M\" ? \"majorable\" : \"perfectable\";\n const name = d + num + altToQ(type, alt);\n return name;\n}\n\nfunction altToQ(type: Type, alt: number): Quality {\n if (alt === 0) {\n return type === \"majorable\" ? \"M\" : \"P\";\n } else if (alt === -1 && type === \"majorable\") {\n return \"m\";\n } else if (alt > 0) {\n return fillStr(\"A\", alt) as Quality;\n } else {\n return fillStr(\"d\", type === \"perfectable\" ? alt : alt + 1) as Quality;\n }\n}\n", "import {\n coordinates,\n isNamedPitch,\n isPitch,\n NamedPitch,\n Pitch,\n pitch,\n PitchCoordinates,\n} from \"@tonaljs/pitch\";\n\nconst fillStr = (s: string, n: number) => Array(Math.abs(n) + 1).join(s);\n\nexport type NoteWithOctave = string;\nexport type PcName = string;\nexport type NoteName = NoteWithOctave | PcName;\nexport type NoteLiteral = NoteName | Pitch | NamedPitch;\n\nexport interface Note extends Pitch, NamedPitch {\n readonly empty: boolean;\n readonly name: NoteName;\n readonly letter: string;\n readonly acc: string;\n readonly pc: PcName;\n readonly chroma: number;\n readonly height: number;\n readonly coord: PitchCoordinates;\n readonly midi: number | null;\n readonly freq: number | null;\n}\n\nconst NoNote: Note = Object.freeze({\n empty: true,\n name: \"\",\n letter: \"\",\n acc: \"\",\n pc: \"\",\n step: NaN,\n alt: NaN,\n chroma: NaN,\n height: NaN,\n coord: [] as unknown as PitchCoordinates,\n midi: null,\n freq: null,\n});\n\nconst cache: Map = new Map();\n\nexport const stepToLetter = (step: number) => \"CDEFGAB\".charAt(step);\nexport const altToAcc = (alt: number): string =>\n alt < 0 ? fillStr(\"b\", -alt) : fillStr(\"#\", alt);\nexport const accToAlt = (acc: string): number =>\n acc[0] === \"b\" ? -acc.length : acc.length;\n\n/**\n * Given a note literal (a note name or a note object), returns the Note object\n * @example\n * note('Bb4') // => { name: \"Bb4\", midi: 70, chroma: 10, ... }\n */\nexport function note(src: NoteLiteral): Note {\n const stringSrc = JSON.stringify(src);\n\n const cached = cache.get(stringSrc);\n if (cached) {\n return cached;\n }\n\n const value =\n typeof src === \"string\"\n ? parse(src)\n : isPitch(src)\n ? note(pitchName(src))\n : isNamedPitch(src)\n ? note(src.name)\n : NoNote;\n cache.set(stringSrc, value);\n return value;\n}\n\ntype NoteTokens = [string, string, string, string];\n\nconst REGEX = /^([a-gA-G]?)(#{1,}|b{1,}|x{1,}|)(-?\\d*)\\s*(.*)$/;\n\n/**\n * @private\n */\nexport function tokenizeNote(str: string): NoteTokens {\n const m = REGEX.exec(str) as string[];\n return m\n ? [m[1].toUpperCase(), m[2].replace(/x/g, \"##\"), m[3], m[4]]\n : [\"\", \"\", \"\", \"\"];\n}\n\n/**\n * @private\n */\nexport function coordToNote(noteCoord: PitchCoordinates): Note {\n return note(pitch(noteCoord)) as Note;\n}\n\nconst mod = (n: number, m: number) => ((n % m) + m) % m;\n\nconst SEMI = [0, 2, 4, 5, 7, 9, 11];\nfunction parse(noteName: NoteName): Note {\n const tokens = tokenizeNote(noteName);\n if (tokens[0] === \"\" || tokens[3] !== \"\") {\n return NoNote;\n }\n\n const letter = tokens[0];\n const acc = tokens[1];\n const octStr = tokens[2];\n\n const step = (letter.charCodeAt(0) + 3) % 7;\n const alt = accToAlt(acc);\n const oct = octStr.length ? +octStr : undefined;\n const coord = coordinates({ step, alt, oct });\n\n const name = letter + acc + octStr;\n const pc = letter + acc;\n const chroma = (SEMI[step] + alt + 120) % 12;\n const height =\n oct === undefined\n ? mod(SEMI[step] + alt, 12) - 12 * 99\n : SEMI[step] + alt + 12 * (oct + 1);\n const midi = height >= 0 && height <= 127 ? height : null;\n const freq = oct === undefined ? null : Math.pow(2, (height - 69) / 12) * 440;\n\n return {\n empty: false,\n acc,\n alt,\n chroma,\n coord,\n freq,\n height,\n letter,\n midi,\n name,\n oct,\n pc,\n step,\n };\n}\n\nfunction pitchName(props: Pitch): NoteName {\n const { step, alt, oct } = props;\n const letter = stepToLetter(step);\n if (!letter) {\n return \"\";\n }\n\n const pc = letter + altToAcc(alt);\n return oct || oct === 0 ? pc + oct : pc;\n}\n", "import { PitchCoordinates } from \"@tonaljs/pitch\";\nimport {\n IntervalLiteral,\n IntervalName,\n interval as asInterval,\n coordToInterval,\n} from \"@tonaljs/pitch-interval\";\nimport {\n NoteLiteral,\n NoteName,\n note as asNote,\n coordToNote,\n} from \"@tonaljs/pitch-note\";\n\n/**\n * Transpose a note by an interval.\n *\n * @param {string} note - the note or note name\n * @param {string} interval - the interval or interval name\n * @return {string} the transposed note name or empty string if not valid notes\n * @example\n * import { transpose } from \"@tonaljs/core\"\n * transpose(\"d3\", \"3M\") // => \"F#3\"\n * transpose(\"D\", \"3M\") // => \"F#\"\n * [\"C\", \"D\", \"E\", \"F\", \"G\"].map(pc => transpose(pc, \"M3)) // => [\"E\", \"F#\", \"G#\", \"A\", \"B\"]\n */\nexport function transpose(\n noteName: NoteLiteral,\n intervalName: IntervalLiteral | [number, number],\n): NoteName {\n const note = asNote(noteName);\n const intervalCoord = Array.isArray(intervalName)\n ? intervalName\n : asInterval(intervalName).coord;\n if (note.empty || !intervalCoord || intervalCoord.length < 2) {\n return \"\";\n }\n const noteCoord = note.coord;\n const tr: PitchCoordinates =\n noteCoord.length === 1\n ? [noteCoord[0] + intervalCoord[0]]\n : [noteCoord[0] + intervalCoord[0], noteCoord[1] + intervalCoord[1]];\n return coordToNote(tr).name;\n}\n\n// Private\nexport function tonicIntervalsTransposer(\n intervals: string[],\n tonic: string | undefined | null,\n) {\n const len = intervals.length;\n return (normalized: number) => {\n if (!tonic) return \"\";\n const index =\n normalized < 0 ? (len - (-normalized % len)) % len : normalized % len;\n const octaves = Math.floor(normalized / len);\n const root = transpose(tonic, [0, octaves]);\n return transpose(root, intervals[index]);\n };\n}\n\n/**\n * Find the interval distance between two notes or coord classes.\n *\n * To find distance between coord classes, both notes must be coord classes and\n * the interval is always ascending\n *\n * @param {Note|string} from - the note or note name to calculate distance from\n * @param {Note|string} to - the note or note name to calculate distance to\n * @return {string} the interval name or empty string if not valid notes\n *\n */\nexport function distance(\n fromNote: NoteLiteral,\n toNote: NoteLiteral,\n): IntervalName {\n const from = asNote(fromNote);\n const to = asNote(toNote);\n if (from.empty || to.empty) {\n return \"\";\n }\n\n const fcoord = from.coord;\n const tcoord = to.coord;\n const fifths = tcoord[0] - fcoord[0];\n const octs =\n fcoord.length === 2 && tcoord.length === 2\n ? tcoord[1] - fcoord[1]\n : -Math.floor((fifths * 7) / 12);\n\n // If it's unison and not pitch class, it can be descending interval (#243)\n const forceDescending =\n to.height === from.height &&\n to.midi !== null &&\n from.midi !== null &&\n from.step > to.step;\n return coordToInterval([fifths, octs], forceDescending).name;\n}\n", "import {\n coordinates,\n isNamedPitch,\n isPitch,\n NamedPitch,\n Pitch,\n pitch,\n PitchCoordinates,\n} from \"@tonaljs/pitch\";\n\nconst fillStr = (s: string, n: number) => Array(Math.abs(n) + 1).join(s);\n\nexport type NoteWithOctave = string;\nexport type PcName = string;\nexport type NoteName = NoteWithOctave | PcName;\nexport type NoteLiteral = NoteName | Pitch | NamedPitch;\n\nexport interface Note extends Pitch, NamedPitch {\n readonly empty: boolean;\n readonly name: NoteName;\n readonly letter: string;\n readonly acc: string;\n readonly pc: PcName;\n readonly chroma: number;\n readonly height: number;\n readonly coord: PitchCoordinates;\n readonly midi: number | null;\n readonly freq: number | null;\n}\n\nexport interface NoNote extends Partial {\n empty: true;\n name: \"\";\n pc: \"\";\n acc: \"\";\n}\nconst NoNote: NoNote = { empty: true, name: \"\", pc: \"\", acc: \"\" };\n\nconst cache: Map = new Map();\n\nexport const stepToLetter = (step: number) => \"CDEFGAB\".charAt(step);\nexport const altToAcc = (alt: number): string =>\n alt < 0 ? fillStr(\"b\", -alt) : fillStr(\"#\", alt);\nexport const accToAlt = (acc: string): number =>\n acc[0] === \"b\" ? -acc.length : acc.length;\n\n/**\n * Given a note literal (a note name or a note object), returns the Note object\n * @example\n * note('Bb4') // => { name: \"Bb4\", midi: 70, chroma: 10, ... }\n */\nexport function note(src: NoteLiteral): Note | NoNote {\n const stringSrc = JSON.stringify(src);\n\n const cached = cache.get(stringSrc);\n if (cached) {\n return cached;\n }\n\n const value =\n typeof src === \"string\"\n ? parse(src)\n : isPitch(src)\n ? note(pitchName(src))\n : isNamedPitch(src)\n ? note(src.name)\n : NoNote;\n cache.set(stringSrc, value);\n return value;\n}\n\ntype NoteTokens = [string, string, string, string];\n\nconst REGEX = /^([a-gA-G]?)(#{1,}|b{1,}|x{1,}|)(-?\\d*)\\s*(.*)$/;\n\n/**\n * @private\n */\nexport function tokenizeNote(str: string): NoteTokens {\n const m = REGEX.exec(str) as string[];\n return [m[1].toUpperCase(), m[2].replace(/x/g, \"##\"), m[3], m[4]];\n}\n\n/**\n * @private\n */\nexport function coordToNote(noteCoord: PitchCoordinates): Note {\n return note(pitch(noteCoord)) as Note;\n}\n\nconst mod = (n: number, m: number) => ((n % m) + m) % m;\n\nconst SEMI = [0, 2, 4, 5, 7, 9, 11];\nfunction parse(noteName: NoteName): Note | NoNote {\n const tokens = tokenizeNote(noteName);\n if (tokens[0] === \"\" || tokens[3] !== \"\") {\n return NoNote;\n }\n\n const letter = tokens[0];\n const acc = tokens[1];\n const octStr = tokens[2];\n\n const step = (letter.charCodeAt(0) + 3) % 7;\n const alt = accToAlt(acc);\n const oct = octStr.length ? +octStr : undefined;\n const coord = coordinates({ step, alt, oct });\n\n const name = letter + acc + octStr;\n const pc = letter + acc;\n const chroma = (SEMI[step] + alt + 120) % 12;\n const height =\n oct === undefined\n ? mod(SEMI[step] + alt, 12) - 12 * 99\n : SEMI[step] + alt + 12 * (oct + 1);\n const midi = height >= 0 && height <= 127 ? height : null;\n const freq = oct === undefined ? null : Math.pow(2, (height - 69) / 12) * 440;\n\n return {\n empty: false,\n acc,\n alt,\n chroma,\n coord,\n freq,\n height,\n letter,\n midi,\n name,\n oct,\n pc,\n step,\n };\n}\n\nfunction pitchName(props: Pitch): NoteName {\n const { step, alt, oct } = props;\n const letter = stepToLetter(step);\n if (!letter) {\n return \"\";\n }\n\n const pc = letter + altToAcc(alt);\n return oct || oct === 0 ? pc + oct : pc;\n}\n", "import { distance as dist, transpose as tr } from \"@tonaljs/pitch-distance\";\nimport { note } from \"@tonaljs/pitch-note\";\n\nconst fillStr = (character: string, times: number) =>\n Array(times + 1).join(character);\n\nconst REGEX = /^(_{1,}|=|\\^{1,}|)([abcdefgABCDEFG])([,']*)$/;\n\ntype AbcTokens = [string, string, string];\n\nexport function tokenize(str: string): AbcTokens {\n const m = REGEX.exec(str);\n if (!m) {\n return [\"\", \"\", \"\"];\n }\n return [m[1], m[2], m[3]];\n}\n\n/**\n * Convert a (string) note in ABC notation into a (string) note in scientific notation\n *\n * @example\n * abcToScientificNotation(\"c\") // => \"C5\"\n */\nexport function abcToScientificNotation(str: string): string {\n const [acc, letter, oct] = tokenize(str);\n if (letter === \"\") {\n return \"\";\n }\n let o = 4;\n for (let i = 0; i < oct.length; i++) {\n o += oct.charAt(i) === \",\" ? -1 : 1;\n }\n const a =\n acc[0] === \"_\"\n ? acc.replace(/_/g, \"b\")\n : acc[0] === \"^\"\n ? acc.replace(/\\^/g, \"#\")\n : \"\";\n return letter.charCodeAt(0) > 96\n ? letter.toUpperCase() + a + (o + 1)\n : letter + a + o;\n}\n\n/**\n * Convert a (string) note in scientific notation into a (string) note in ABC notation\n *\n * @example\n * scientificToAbcNotation(\"C#4\") // => \"^C\"\n */\nexport function scientificToAbcNotation(str: string): string {\n const n = note(str);\n if (n.empty || (!n.oct && n.oct !== 0)) {\n return \"\";\n }\n const { letter, acc, oct } = n;\n const a = acc[0] === \"b\" ? acc.replace(/b/g, \"_\") : acc.replace(/#/g, \"^\");\n const l = oct > 4 ? letter.toLowerCase() : letter;\n const o =\n oct === 5 ? \"\" : oct > 4 ? fillStr(\"'\", oct - 5) : fillStr(\",\", 4 - oct);\n return a + l + o;\n}\n\nexport function transpose(note: string, interval: string): string {\n return scientificToAbcNotation(tr(abcToScientificNotation(note), interval));\n}\n\nexport function distance(from: string, to: string): string {\n return dist(abcToScientificNotation(from), abcToScientificNotation(to));\n}\n\nexport default {\n abcToScientificNotation,\n scientificToAbcNotation,\n tokenize,\n transpose,\n distance,\n};\n", "import {\n coordinates,\n isNamedPitch,\n isPitch,\n NamedPitch,\n Pitch,\n pitch,\n PitchCoordinates,\n} from \"@tonaljs/pitch\";\n\nconst fillStr = (s: string, n: number) => Array(Math.abs(n) + 1).join(s);\n\nexport type NoteWithOctave = string;\nexport type PcName = string;\nexport type NoteName = NoteWithOctave | PcName;\nexport type NoteLiteral = NoteName | Pitch | NamedPitch;\n\nexport interface Note extends Pitch, NamedPitch {\n readonly empty: boolean;\n readonly name: NoteName;\n readonly letter: string;\n readonly acc: string;\n readonly pc: PcName;\n readonly chroma: number;\n readonly height: number;\n readonly coord: PitchCoordinates;\n readonly midi: number | null;\n readonly freq: number | null;\n}\n\nexport interface NoNote extends Partial {\n empty: true;\n name: \"\";\n pc: \"\";\n acc: \"\";\n}\nconst NoNote: NoNote = { empty: true, name: \"\", pc: \"\", acc: \"\" };\n\nconst cache: Map = new Map();\n\nexport const stepToLetter = (step: number) => \"CDEFGAB\".charAt(step);\nexport const altToAcc = (alt: number): string =>\n alt < 0 ? fillStr(\"b\", -alt) : fillStr(\"#\", alt);\nexport const accToAlt = (acc: string): number =>\n acc[0] === \"b\" ? -acc.length : acc.length;\n\n/**\n * Given a note literal (a note name or a note object), returns the Note object\n * @example\n * note('Bb4') // => { name: \"Bb4\", midi: 70, chroma: 10, ... }\n */\nexport function note(src: NoteLiteral): Note | NoNote {\n const stringSrc = JSON.stringify(src);\n\n const cached = cache.get(stringSrc);\n if (cached) {\n return cached;\n }\n\n const value =\n typeof src === \"string\"\n ? parse(src)\n : isPitch(src)\n ? note(pitchName(src))\n : isNamedPitch(src)\n ? note(src.name)\n : NoNote;\n cache.set(stringSrc, value);\n return value;\n}\n\ntype NoteTokens = [string, string, string, string];\n\nconst REGEX = /^([a-gA-G]?)(#{1,}|b{1,}|x{1,}|)(-?\\d*)\\s*(.*)$/;\n\n/**\n * @private\n */\nexport function tokenizeNote(str: string): NoteTokens {\n const m = REGEX.exec(str) as string[];\n return [m[1].toUpperCase(), m[2].replace(/x/g, \"##\"), m[3], m[4]];\n}\n\n/**\n * @private\n */\nexport function coordToNote(noteCoord: PitchCoordinates): Note {\n return note(pitch(noteCoord)) as Note;\n}\n\nconst mod = (n: number, m: number) => ((n % m) + m) % m;\n\nconst SEMI = [0, 2, 4, 5, 7, 9, 11];\nfunction parse(noteName: NoteName): Note | NoNote {\n const tokens = tokenizeNote(noteName);\n if (tokens[0] === \"\" || tokens[3] !== \"\") {\n return NoNote;\n }\n\n const letter = tokens[0];\n const acc = tokens[1];\n const octStr = tokens[2];\n\n const step = (letter.charCodeAt(0) + 3) % 7;\n const alt = accToAlt(acc);\n const oct = octStr.length ? +octStr : undefined;\n const coord = coordinates({ step, alt, oct });\n\n const name = letter + acc + octStr;\n const pc = letter + acc;\n const chroma = (SEMI[step] + alt + 120) % 12;\n const height =\n oct === undefined\n ? mod(SEMI[step] + alt, 12) - 12 * 99\n : SEMI[step] + alt + 12 * (oct + 1);\n const midi = height >= 0 && height <= 127 ? height : null;\n const freq = oct === undefined ? null : Math.pow(2, (height - 69) / 12) * 440;\n\n return {\n empty: false,\n acc,\n alt,\n chroma,\n coord,\n freq,\n height,\n letter,\n midi,\n name,\n oct,\n pc,\n step,\n };\n}\n\nfunction pitchName(props: Pitch): NoteName {\n const { step, alt, oct } = props;\n const letter = stepToLetter(step);\n if (!letter) {\n return \"\";\n }\n\n const pc = letter + altToAcc(alt);\n return oct || oct === 0 ? pc + oct : pc;\n}\n", "/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { note, Note } from \"@tonaljs/pitch-note\";\n\n// ascending range\nfunction ascR(b: number, n: number) {\n const a = [];\n // tslint:disable-next-line:curly\n for (; n--; a[n] = n + b);\n return a;\n}\n// descending range\nfunction descR(b: number, n: number) {\n const a = [];\n // tslint:disable-next-line:curly\n for (; n--; a[n] = b - n);\n return a;\n}\n\n/**\n * Creates a numeric range\n *\n * @param {number} from\n * @param {number} to\n * @return {Array}\n *\n * @example\n * range(-2, 2) // => [-2, -1, 0, 1, 2]\n * range(2, -2) // => [2, 1, 0, -1, -2]\n */\nexport function range(from: number, to: number): number[] {\n return from < to ? ascR(from, to - from + 1) : descR(from, from - to + 1);\n}\n\n/**\n * Rotates a list a number of times. It\"s completly agnostic about the\n * contents of the list.\n *\n * @param {Integer} times - the number of rotations\n * @param {Array} array\n * @return {Array} the rotated array\n *\n * @example\n * rotate(1, [1, 2, 3]) // => [2, 3, 1]\n */\nexport function rotate(times: number, arr: T[]): T[] {\n const len = arr.length;\n const n = ((times % len) + len) % len;\n return arr.slice(n, len).concat(arr.slice(0, n));\n}\n\n/**\n * Return a copy of the array with the null values removed\n * @function\n * @param {Array} array\n * @return {Array}\n *\n * @example\n * compact([\"a\", \"b\", null, \"c\"]) // => [\"a\", \"b\", \"c\"]\n */\nexport function compact(arr: any[]): any[] {\n return arr.filter((n) => n === 0 || n);\n}\n\n/**\n * Sort an array of notes in ascending order. Pitch classes are listed\n * before notes. Any string that is not a note is removed.\n *\n * @param {string[]} notes\n * @return {string[]} sorted array of notes\n *\n * @example\n * sortedNoteNames(['c2', 'c5', 'c1', 'c0', 'c6', 'c'])\n * // => ['C', 'C0', 'C1', 'C2', 'C5', 'C6']\n * sortedNoteNames(['c', 'F', 'G', 'a', 'b', 'h', 'J'])\n * // => ['C', 'F', 'G', 'A', 'B']\n */\nexport function sortedNoteNames(notes: string[]): string[] {\n const valid = notes.map((n) => note(n)).filter((n) => !n.empty) as Note[];\n return valid.sort((a, b) => a.height - b.height).map((n) => n.name);\n}\n\n/**\n * Get sorted notes with duplicates removed. Pitch classes are listed\n * before notes.\n *\n * @function\n * @param {string[]} array\n * @return {string[]} unique sorted notes\n *\n * @example\n * Array.sortedUniqNoteNames(['a', 'b', 'c2', '1p', 'p2', 'c2', 'b', 'c', 'c3' ])\n * // => [ 'C', 'A', 'B', 'C2', 'C3' ]\n */\nexport function sortedUniqNoteNames(arr: string[]): string[] {\n return sortedNoteNames(arr).filter((n, i, a) => i === 0 || n !== a[i - 1]);\n}\n\n/**\n * Randomizes the order of the specified array in-place, using the Fisher–Yates shuffle.\n *\n * @function\n * @param {Array} array\n * @return {Array} the array shuffled\n *\n * @example\n * shuffle([\"C\", \"D\", \"E\", \"F\"]) // => [...]\n */\nexport function shuffle(arr: any[], rnd = Math.random): any[] {\n let i: number;\n let t: any;\n let m: number = arr.length;\n while (m) {\n i = Math.floor(rnd() * m--);\n t = arr[m];\n arr[m] = arr[i];\n arr[i] = t;\n }\n return arr;\n}\n\n/**\n * Get all permutations of an array\n *\n * @param {Array} array - the array\n * @return {Array} an array with all the permutations\n * @example\n * permutations([\"a\", \"b\", \"c\"])) // =>\n * [\n * [\"a\", \"b\", \"c\"],\n * [\"b\", \"a\", \"c\"],\n * [\"b\", \"c\", \"a\"],\n * [\"a\", \"c\", \"b\"],\n * [\"c\", \"a\", \"b\"],\n * [\"c\", \"b\", \"a\"]\n * ]\n */\nexport function permutations(arr: any[]): any[] {\n if (arr.length === 0) {\n return [[]];\n }\n return permutations(arr.slice(1)).reduce((acc, perm) => {\n return acc.concat(\n arr.map((e, pos) => {\n const newPerm = perm.slice();\n newPerm.splice(pos, 0, arr[0]);\n return newPerm;\n }),\n );\n }, []);\n}\n", "import { isNamedPitch } from \"@tonaljs/pitch\";\n\nexport * from \"@tonaljs/pitch\";\nexport * from \"@tonaljs/pitch-distance\";\nexport * from \"@tonaljs/pitch-interval\";\nexport * from \"@tonaljs/pitch-note\";\n\nexport const fillStr = (s: string, n: number) => Array(Math.abs(n) + 1).join(s);\n\nexport function deprecate<\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ResultFn extends (this: any, ...newArgs: any[]) => ReturnType,\n>(original: string, alternative: string, fn: ResultFn) {\n return function (this: unknown, ...args: unknown[]): ReturnType {\n // tslint:disable-next-line\n console.warn(`${original} is deprecated. Use ${alternative}.`);\n return fn.apply(this, args);\n };\n}\n\nexport const isNamed = deprecate(\"isNamed\", \"isNamedPitch\", isNamedPitch);\n", "/* eslint-disable @typescript-eslint/no-explicit-any */\n// ascending range\nfunction ascR(b: number, n: number) {\n const a = [];\n // tslint:disable-next-line:curly\n for (; n--; a[n] = n + b);\n return a;\n}\n// descending range\nfunction descR(b: number, n: number) {\n const a = [];\n // tslint:disable-next-line:curly\n for (; n--; a[n] = b - n);\n return a;\n}\n\n/**\n * Creates a numeric range\n *\n * @param {number} from\n * @param {number} to\n * @return {Array}\n *\n * @example\n * range(-2, 2) // => [-2, -1, 0, 1, 2]\n * range(2, -2) // => [2, 1, 0, -1, -2]\n */\nexport function range(from: number, to: number): number[] {\n return from < to ? ascR(from, to - from + 1) : descR(from, from - to + 1);\n}\n\n/**\n * Rotates a list a number of times. It\"s completly agnostic about the\n * contents of the list.\n *\n * @param {Integer} times - the number of rotations\n * @param {Array} collection\n * @return {Array} the rotated collection\n *\n * @example\n * rotate(1, [1, 2, 3]) // => [2, 3, 1]\n */\nexport function rotate(times: number, arr: T[]): T[] {\n const len = arr.length;\n const n = ((times % len) + len) % len;\n return arr.slice(n, len).concat(arr.slice(0, n));\n}\n\n/**\n * Return a copy of the collection with the null values removed\n * @function\n * @param {Array} collection\n * @return {Array}\n *\n * @example\n * compact([\"a\", \"b\", null, \"c\"]) // => [\"a\", \"b\", \"c\"]\n */\nexport function compact(arr: any[]): any[] {\n return arr.filter((n) => n === 0 || n);\n}\n\n/**\n * Randomizes the order of the specified collection in-place, using the Fisher–Yates shuffle.\n *\n * @function\n * @param {Array} collection\n * @return {Array} the collection shuffled\n *\n * @example\n * shuffle([\"C\", \"D\", \"E\", \"F\"]) // => [...]\n */\nexport function shuffle(arr: any[], rnd = Math.random): any[] {\n let i: number;\n let t: any;\n let m: number = arr.length;\n while (m) {\n i = Math.floor(rnd() * m--);\n t = arr[m];\n arr[m] = arr[i];\n arr[i] = t;\n }\n return arr;\n}\n\n/**\n * Get all permutations of an collection\n *\n * @param {Array} collection - the collection\n * @return {Array} an collection with all the permutations\n * @example\n * permutations([\"a\", \"b\", \"c\"])) // =>\n * [\n * [\"a\", \"b\", \"c\"],\n * [\"b\", \"a\", \"c\"],\n * [\"b\", \"c\", \"a\"],\n * [\"a\", \"c\", \"b\"],\n * [\"c\", \"a\", \"b\"],\n * [\"c\", \"b\", \"a\"]\n * ]\n */\nexport function permutations(arr: any[]): any[] {\n if (arr.length === 0) {\n return [[]];\n }\n return permutations(arr.slice(1)).reduce((acc, perm) => {\n return acc.concat(\n arr.map((e, pos) => {\n const newPerm = perm.slice();\n newPerm.splice(pos, 0, arr[0]);\n return newPerm;\n }),\n );\n }, []);\n}\n\nexport default {\n compact,\n permutations,\n range,\n rotate,\n shuffle,\n};\n", "import { compact, range, rotate } from \"@tonaljs/collection\";\nimport {\n Interval,\n IntervalName,\n NotFound,\n Note,\n NoteName,\n deprecate,\n interval,\n note,\n transpose,\n} from \"@tonaljs/core\";\n\n/**\n * The properties of a pitch class set\n * @param {number} num - a number between 1 and 4095 (both included) that\n * uniquely identifies the set. It's the decimal number of the chrom.\n * @param {string} chroma - a string representation of the set: a 12-char string\n * with either \"1\" or \"0\" as characters, representing a pitch class or not\n * for the given position in the octave. For example, a \"1\" at index 0 means 'C',\n * a \"1\" at index 2 means 'D', and so on...\n * @param {string} normalized - the chroma but shifted to the first 1\n * @param {number} length - the number of notes of the pitch class set\n * @param {IntervalName[]} intervals - the intervals of the pitch class set\n * *starting from C*\n */\nexport interface Pcset {\n readonly name: string;\n readonly empty: boolean;\n readonly setNum: number;\n readonly chroma: PcsetChroma;\n readonly normalized: PcsetChroma;\n readonly intervals: IntervalName[];\n}\n\nexport const EmptyPcset: Pcset = {\n empty: true,\n name: \"\",\n setNum: 0,\n chroma: \"000000000000\",\n normalized: \"000000000000\",\n intervals: [],\n};\n\nexport type PcsetChroma = string;\nexport type PcsetNum = number;\n\n// UTILITIES\nconst setNumToChroma = (num: number): string =>\n Number(num).toString(2).padStart(12, \"0\");\nconst chromaToNumber = (chroma: string): number => parseInt(chroma, 2);\nconst REGEX = /^[01]{12}$/;\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function isChroma(set: any): set is PcsetChroma {\n return REGEX.test(set);\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nconst isPcsetNum = (set: any): set is PcsetNum =>\n typeof set === \"number\" && set >= 0 && set <= 4095;\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nconst isPcset = (set: any): set is Pcset => set && isChroma(set.chroma);\n\nconst cache: { [key in string]: Pcset } = { [EmptyPcset.chroma]: EmptyPcset };\n\n/**\n * A definition of a pitch class set. It could be:\n * - The pitch class set chroma (a 12-length string with only 1s or 0s)\n * - The pitch class set number (an integer between 1 and 4095)\n * - An array of note names\n * - An array of interval names\n */\nexport type Set =\n | Partial\n | PcsetChroma\n | PcsetNum\n | NoteName[]\n | IntervalName[];\n\n/**\n * Get the pitch class set of a collection of notes or set number or chroma\n */\nexport function get(src: Set): Pcset {\n const chroma: PcsetChroma = isChroma(src)\n ? src\n : isPcsetNum(src)\n ? setNumToChroma(src)\n : Array.isArray(src)\n ? listToChroma(src)\n : isPcset(src)\n ? src.chroma\n : EmptyPcset.chroma;\n\n return (cache[chroma] = cache[chroma] || chromaToPcset(chroma));\n}\n\n/**\n * Use Pcset.properties\n * @function\n * @deprecated\n */\nexport const pcset = deprecate(\"Pcset.pcset\", \"Pcset.get\", get);\n\n/**\n * Get pitch class set chroma\n * @function\n * @example\n * Pcset.chroma([\"c\", \"d\", \"e\"]); //=> \"101010000000\"\n */\nexport const chroma = (set: Set) => get(set).chroma;\n\n/**\n * Get intervals (from C) of a set\n * @function\n * @example\n * Pcset.intervals([\"c\", \"d\", \"e\"]); //=>\n */\nconst intervals = (set: Set) => get(set).intervals;\n\n/**\n * Get pitch class set number\n * @function\n * @example\n * Pcset.num([\"c\", \"d\", \"e\"]); //=> 2192\n */\nconst num = (set: Set) => get(set).setNum;\n\nconst IVLS = [\n \"1P\",\n \"2m\",\n \"2M\",\n \"3m\",\n \"3M\",\n \"4P\",\n \"5d\",\n \"5P\",\n \"6m\",\n \"6M\",\n \"7m\",\n \"7M\",\n];\n\n/**\n * @private\n * Get the intervals of a pcset *starting from C*\n * @param {Set} set - the pitch class set\n * @return {IntervalName[]} an array of interval names or an empty array\n * if not a valid pitch class set\n */\nexport function chromaToIntervals(chroma: PcsetChroma): IntervalName[] {\n const intervals = [];\n for (let i = 0; i < 12; i++) {\n // tslint:disable-next-line:curly\n if (chroma.charAt(i) === \"1\") intervals.push(IVLS[i]);\n }\n return intervals;\n}\n\nexport function notes(set: Set): NoteName[] {\n return get(set).intervals.map((ivl) => transpose(\"C\", ivl));\n}\n\n/**\n * Get a list of all possible pitch class sets (all possible chromas) *having\n * C as root*. There are 2048 different chromas. If you want them with another\n * note you have to transpose it\n *\n * @see http://allthescales.org/\n * @return {Array} an array of possible chromas from '10000000000' to '11111111111'\n */\nexport function chromas(): PcsetChroma[] {\n return range(2048, 4095).map(setNumToChroma);\n}\n\n/**\n * Given a a list of notes or a pcset chroma, produce the rotations\n * of the chroma discarding the ones that starts with \"0\"\n *\n * This is used, for example, to get all the modes of a scale.\n *\n * @param {Array|string} set - the list of notes or pitchChr of the set\n * @param {boolean} normalize - (Optional, true by default) remove all\n * the rotations that starts with \"0\"\n * @return {Array} an array with all the modes of the chroma\n *\n * @example\n * Pcset.modes([\"C\", \"D\", \"E\"]).map(Pcset.intervals)\n */\nexport function modes(set: Set, normalize = true): PcsetChroma[] {\n const pcs = get(set);\n\n const binary = pcs.chroma.split(\"\");\n return compact(\n binary.map((_, i) => {\n const r = rotate(i, binary);\n return normalize && r[0] === \"0\" ? null : r.join(\"\");\n }),\n );\n}\n\n/**\n * Test if two pitch class sets are numentical\n *\n * @param {Array|string} set1 - one of the pitch class sets\n * @param {Array|string} set2 - the other pitch class set\n * @return {boolean} true if they are equal\n * @example\n * Pcset.isEqual([\"c2\", \"d3\"], [\"c5\", \"d2\"]) // => true\n */\nexport function isEqual(s1: Set, s2: Set) {\n return get(s1).setNum === get(s2).setNum;\n}\n\n/**\n * Create a function that test if a collection of notes is a\n * subset of a given set\n *\n * The function is curryfied.\n *\n * @param {PcsetChroma|NoteName[]} set - the superset to test against (chroma or\n * list of notes)\n * @return{function(PcsetChroma|NoteNames[]): boolean} a function accepting a set\n * to test against (chroma or list of notes)\n * @example\n * const inCMajor = Pcset.isSubsetOf([\"C\", \"E\", \"G\"])\n * inCMajor([\"e6\", \"c4\"]) // => true\n * inCMajor([\"e6\", \"c4\", \"d3\"]) // => false\n */\nexport function isSubsetOf(set: Set) {\n const s = get(set).setNum;\n\n return (notes: Set | Pcset) => {\n const o = get(notes).setNum;\n // tslint:disable-next-line: no-bitwise\n return s && s !== o && (o & s) === o;\n };\n}\n\n/**\n * Create a function that test if a collection of notes is a\n * superset of a given set (it contains all notes and at least one more)\n *\n * @param {Set} set - an array of notes or a chroma set string to test against\n * @return {(subset: Set): boolean} a function that given a set\n * returns true if is a subset of the first one\n * @example\n * const extendsCMajor = Pcset.isSupersetOf([\"C\", \"E\", \"G\"])\n * extendsCMajor([\"e6\", \"a\", \"c4\", \"g2\"]) // => true\n * extendsCMajor([\"c6\", \"e4\", \"g3\"]) // => false\n */\nexport function isSupersetOf(set: Set) {\n const s = get(set).setNum;\n return (notes: Set) => {\n const o = get(notes).setNum;\n // tslint:disable-next-line: no-bitwise\n return s && s !== o && (o | s) === o;\n };\n}\n\n/**\n * Test if a given pitch class set includes a note\n *\n * @param {Array} set - the base set to test against\n * @param {string} note - the note to test\n * @return {boolean} true if the note is included in the pcset\n *\n * Can be partially applied\n *\n * @example\n * const isNoteInCMajor = isNoteIncludedIn(['C', 'E', 'G'])\n * isNoteInCMajor('C4') // => true\n * isNoteInCMajor('C#4') // => false\n */\nexport function isNoteIncludedIn(set: Set) {\n const s = get(set);\n\n return (noteName: NoteName): boolean => {\n const n = note(noteName);\n return s && !n.empty && s.chroma.charAt(n.chroma) === \"1\";\n };\n}\n\n/** @deprecated use: isNoteIncludedIn */\nexport const includes = isNoteIncludedIn;\n\n/**\n * Filter a list with a pitch class set\n *\n * @param {Array|string} set - the pitch class set notes\n * @param {Array|string} notes - the note list to be filtered\n * @return {Array} the filtered notes\n *\n * @example\n * Pcset.filter([\"C\", \"D\", \"E\"], [\"c2\", \"c#2\", \"d2\", \"c3\", \"c#3\", \"d3\"]) // => [ \"c2\", \"d2\", \"c3\", \"d3\" ])\n * Pcset.filter([\"C2\"], [\"c2\", \"c#2\", \"d2\", \"c3\", \"c#3\", \"d3\"]) // => [ \"c2\", \"c3\" ])\n */\nexport function filter(set: Set) {\n const isIncluded = isNoteIncludedIn(set);\n return (notes: NoteName[]) => {\n return notes.filter(isIncluded);\n };\n}\n\nexport default {\n get,\n chroma,\n num,\n intervals,\n chromas,\n isSupersetOf,\n isSubsetOf,\n isNoteIncludedIn,\n isEqual,\n filter,\n modes,\n notes,\n // deprecated\n pcset,\n};\n\n//// PRIVATE ////\n\nfunction chromaRotations(chroma: string): string[] {\n const binary = chroma.split(\"\");\n return binary.map((_, i) => rotate(i, binary).join(\"\"));\n}\n\nfunction chromaToPcset(chroma: PcsetChroma): Pcset {\n const setNum = chromaToNumber(chroma);\n const normalizedNum = chromaRotations(chroma)\n .map(chromaToNumber)\n .filter((n) => n >= 2048)\n .sort()[0];\n const normalized = setNumToChroma(normalizedNum);\n\n const intervals = chromaToIntervals(chroma);\n\n return {\n empty: false,\n name: \"\",\n setNum,\n chroma,\n normalized,\n intervals,\n };\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nfunction listToChroma(set: any[]): PcsetChroma {\n if (set.length === 0) {\n return EmptyPcset.chroma;\n }\n\n let pitch: Note | Interval | NotFound;\n const binary = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];\n // tslint:disable-next-line:prefer-for-of\n for (let i = 0; i < set.length; i++) {\n pitch = note(set[i]);\n // tslint:disable-next-line: curly\n if (pitch.empty) pitch = interval(set[i]);\n // tslint:disable-next-line: curly\n if (!pitch.empty) binary[pitch.chroma] = 1;\n }\n return binary.join(\"\");\n}\n", "import { deprecate } from \"@tonaljs/core\";\nimport {\n EmptyPcset,\n get as pcset,\n Pcset,\n PcsetChroma,\n PcsetNum,\n} from \"@tonaljs/pcset\";\nimport data from \"./data\";\n\nexport type ChordQuality =\n | \"Major\"\n | \"Minor\"\n | \"Augmented\"\n | \"Diminished\"\n | \"Unknown\";\n\nexport interface ChordType extends Pcset {\n name: string;\n quality: ChordQuality;\n aliases: string[];\n}\nconst NoChordType: ChordType = {\n ...EmptyPcset,\n name: \"\",\n quality: \"Unknown\",\n intervals: [],\n aliases: [],\n};\n\ntype ChordTypeName = string | PcsetChroma | PcsetNum;\n\nlet dictionary: ChordType[] = [];\nlet index: Record = {};\n\n/**\n * Given a chord name or chroma, return the chord properties\n * @param {string} source - chord name or pitch class set chroma\n * @example\n * import { get } from 'tonaljs/chord-type'\n * get('major') // => { name: 'major', ... }\n */\nexport function get(type: ChordTypeName): ChordType {\n return index[type] || NoChordType;\n}\n\nexport const chordType = deprecate(\"ChordType.chordType\", \"ChordType.get\", get);\n\n/**\n * Get all chord (long) names\n */\nexport function names() {\n return dictionary.map((chord) => chord.name).filter((x) => x);\n}\n\n/**\n * Get all chord symbols\n */\nexport function symbols() {\n return dictionary.map((chord) => chord.aliases[0]).filter((x) => x);\n}\n\n/**\n * Keys used to reference chord types\n */\nexport function keys() {\n return Object.keys(index);\n}\n\n/**\n * Return a list of all chord types\n */\nexport function all(): ChordType[] {\n return dictionary.slice();\n}\n\nexport const entries = deprecate(\"ChordType.entries\", \"ChordType.all\", all);\n\n/**\n * Clear the dictionary\n */\nexport function removeAll() {\n dictionary = [];\n index = {};\n}\n\n/**\n * Add a chord to the dictionary.\n * @param intervals\n * @param aliases\n * @param [fullName]\n */\nexport function add(intervals: string[], aliases: string[], fullName?: string) {\n const quality = getQuality(intervals);\n const chord = {\n ...pcset(intervals),\n name: fullName || \"\",\n quality,\n intervals,\n aliases,\n };\n dictionary.push(chord);\n if (chord.name) {\n index[chord.name] = chord;\n }\n index[chord.setNum] = chord;\n index[chord.chroma] = chord;\n chord.aliases.forEach((alias) => addAlias(chord, alias));\n}\n\nexport function addAlias(chord: ChordType, alias: string) {\n index[alias] = chord;\n}\n\nfunction getQuality(intervals: string[]): ChordQuality {\n const has = (interval: string) => intervals.indexOf(interval) !== -1;\n return has(\"5A\")\n ? \"Augmented\"\n : has(\"3M\")\n ? \"Major\"\n : has(\"5d\")\n ? \"Diminished\"\n : has(\"3m\")\n ? \"Minor\"\n : \"Unknown\";\n}\n\ndata.forEach(([ivls, fullName, names]: string[]) =>\n add(ivls.split(\" \"), names.split(\" \"), fullName),\n);\ndictionary.sort((a, b) => a.setNum - b.setNum);\n\nexport default {\n names,\n symbols,\n get,\n all,\n add,\n removeAll,\n keys,\n // deprecated\n entries,\n chordType,\n};\n", "/**\n * @private\n * Chord List\n * Source: https://en.wikibooks.org/wiki/Music_Theory/Complete_List_of_Chord_Patterns\n * Format: [\"intervals\", \"full name\", \"abrv1 abrv2\"]\n */\nconst CHORDS: string[][] = [\n // ==Major==\n [\"1P 3M 5P\", \"major\", \"M ^ maj\"],\n [\"1P 3M 5P 7M\", \"major seventh\", \"maj7 Δ ma7 M7 Maj7 ^7\"],\n [\"1P 3M 5P 7M 9M\", \"major ninth\", \"maj9 Δ9 ^9\"],\n [\"1P 3M 5P 7M 9M 13M\", \"major thirteenth\", \"maj13 Maj13 ^13\"],\n [\"1P 3M 5P 6M\", \"sixth\", \"6 add6 add13 M6\"],\n [\"1P 3M 5P 6M 9M\", \"sixth added ninth\", \"6add9 6/9 69 M69\"],\n [\"1P 3M 6m 7M\", \"major seventh flat sixth\", \"M7b6 ^7b6\"],\n [\n \"1P 3M 5P 7M 11A\",\n \"major seventh sharp eleventh\",\n \"maj#4 Δ#4 Δ#11 M7#11 ^7#11 maj7#11\",\n ],\n // ==Minor==\n // '''Normal'''\n [\"1P 3m 5P\", \"minor\", \"m min -\"],\n [\"1P 3m 5P 7m\", \"minor seventh\", \"m7 min7 mi7 -7\"],\n [\n \"1P 3m 5P 7M\",\n \"minor/major seventh\",\n \"m/ma7 m/maj7 mM7 mMaj7 m/M7 -Δ7 mΔ -^7 -maj7\",\n ],\n [\"1P 3m 5P 6M\", \"minor sixth\", \"m6 -6\"],\n [\"1P 3m 5P 7m 9M\", \"minor ninth\", \"m9 -9\"],\n [\"1P 3m 5P 7M 9M\", \"minor/major ninth\", \"mM9 mMaj9 -^9\"],\n [\"1P 3m 5P 7m 9M 11P\", \"minor eleventh\", \"m11 -11\"],\n [\"1P 3m 5P 7m 9M 13M\", \"minor thirteenth\", \"m13 -13\"],\n // '''Diminished'''\n [\"1P 3m 5d\", \"diminished\", \"dim ° o\"],\n [\"1P 3m 5d 7d\", \"diminished seventh\", \"dim7 °7 o7\"],\n [\"1P 3m 5d 7m\", \"half-diminished\", \"m7b5 ø -7b5 h7 h\"],\n // ==Dominant/Seventh==\n // '''Normal'''\n [\"1P 3M 5P 7m\", \"dominant seventh\", \"7 dom\"],\n [\"1P 3M 5P 7m 9M\", \"dominant ninth\", \"9\"],\n [\"1P 3M 5P 7m 9M 13M\", \"dominant thirteenth\", \"13\"],\n [\"1P 3M 5P 7m 11A\", \"lydian dominant seventh\", \"7#11 7#4\"],\n // '''Altered'''\n [\"1P 3M 5P 7m 9m\", \"dominant flat ninth\", \"7b9\"],\n [\"1P 3M 5P 7m 9A\", \"dominant sharp ninth\", \"7#9\"],\n [\"1P 3M 7m 9m\", \"altered\", \"alt7\"],\n // '''Suspended'''\n [\"1P 4P 5P\", \"suspended fourth\", \"sus4 sus\"],\n [\"1P 2M 5P\", \"suspended second\", \"sus2\"],\n [\"1P 4P 5P 7m\", \"suspended fourth seventh\", \"7sus4 7sus\"],\n [\"1P 5P 7m 9M 11P\", \"eleventh\", \"11\"],\n [\n \"1P 4P 5P 7m 9m\",\n \"suspended fourth flat ninth\",\n \"b9sus phryg 7b9sus 7b9sus4\",\n ],\n // ==Other==\n [\"1P 5P\", \"fifth\", \"5\"],\n [\"1P 3M 5A\", \"augmented\", \"aug + +5 ^#5\"],\n [\"1P 3m 5A\", \"minor augmented\", \"m#5 -#5 m+\"],\n [\"1P 3M 5A 7M\", \"augmented seventh\", \"maj7#5 maj7+5 +maj7 ^7#5\"],\n [\n \"1P 3M 5P 7M 9M 11A\",\n \"major sharp eleventh (lydian)\",\n \"maj9#11 Δ9#11 ^9#11\",\n ],\n // ==Legacy==\n [\"1P 2M 4P 5P\", \"\", \"sus24 sus4add9\"],\n [\"1P 3M 5A 7M 9M\", \"\", \"maj9#5 Maj9#5\"],\n [\"1P 3M 5A 7m\", \"\", \"7#5 +7 7+ 7aug aug7\"],\n [\"1P 3M 5A 7m 9A\", \"\", \"7#5#9 7#9#5 7alt\"],\n [\"1P 3M 5A 7m 9M\", \"\", \"9#5 9+\"],\n [\"1P 3M 5A 7m 9M 11A\", \"\", \"9#5#11\"],\n [\"1P 3M 5A 7m 9m\", \"\", \"7#5b9 7b9#5\"],\n [\"1P 3M 5A 7m 9m 11A\", \"\", \"7#5b9#11\"],\n [\"1P 3M 5A 9A\", \"\", \"+add#9\"],\n [\"1P 3M 5A 9M\", \"\", \"M#5add9 +add9\"],\n [\"1P 3M 5P 6M 11A\", \"\", \"M6#11 M6b5 6#11 6b5\"],\n [\"1P 3M 5P 6M 7M 9M\", \"\", \"M7add13\"],\n [\"1P 3M 5P 6M 9M 11A\", \"\", \"69#11\"],\n [\"1P 3m 5P 6M 9M\", \"\", \"m69 -69\"],\n [\"1P 3M 5P 6m 7m\", \"\", \"7b6\"],\n [\"1P 3M 5P 7M 9A 11A\", \"\", \"maj7#9#11\"],\n [\"1P 3M 5P 7M 9M 11A 13M\", \"\", \"M13#11 maj13#11 M13+4 M13#4\"],\n [\"1P 3M 5P 7M 9m\", \"\", \"M7b9\"],\n [\"1P 3M 5P 7m 11A 13m\", \"\", \"7#11b13 7b5b13\"],\n [\"1P 3M 5P 7m 13M\", \"\", \"7add6 67 7add13\"],\n [\"1P 3M 5P 7m 9A 11A\", \"\", \"7#9#11 7b5#9 7#9b5\"],\n [\"1P 3M 5P 7m 9A 11A 13M\", \"\", \"13#9#11\"],\n [\"1P 3M 5P 7m 9A 11A 13m\", \"\", \"7#9#11b13\"],\n [\"1P 3M 5P 7m 9A 13M\", \"\", \"13#9\"],\n [\"1P 3M 5P 7m 9A 13m\", \"\", \"7#9b13\"],\n [\"1P 3M 5P 7m 9M 11A\", \"\", \"9#11 9+4 9#4\"],\n [\"1P 3M 5P 7m 9M 11A 13M\", \"\", \"13#11 13+4 13#4\"],\n [\"1P 3M 5P 7m 9M 11A 13m\", \"\", \"9#11b13 9b5b13\"],\n [\"1P 3M 5P 7m 9m 11A\", \"\", \"7b9#11 7b5b9 7b9b5\"],\n [\"1P 3M 5P 7m 9m 11A 13M\", \"\", \"13b9#11\"],\n [\"1P 3M 5P 7m 9m 11A 13m\", \"\", \"7b9b13#11 7b9#11b13 7b5b9b13\"],\n [\"1P 3M 5P 7m 9m 13M\", \"\", \"13b9\"],\n [\"1P 3M 5P 7m 9m 13m\", \"\", \"7b9b13\"],\n [\"1P 3M 5P 7m 9m 9A\", \"\", \"7b9#9\"],\n [\"1P 3M 5P 9M\", \"\", \"Madd9 2 add9 add2\"],\n [\"1P 3M 5P 9m\", \"\", \"Maddb9\"],\n [\"1P 3M 5d\", \"\", \"Mb5\"],\n [\"1P 3M 5d 6M 7m 9M\", \"\", \"13b5\"],\n [\"1P 3M 5d 7M\", \"\", \"M7b5\"],\n [\"1P 3M 5d 7M 9M\", \"\", \"M9b5\"],\n [\"1P 3M 5d 7m\", \"\", \"7b5\"],\n [\"1P 3M 5d 7m 9M\", \"\", \"9b5\"],\n [\"1P 3M 7m\", \"\", \"7no5\"],\n [\"1P 3M 7m 13m\", \"\", \"7b13\"],\n [\"1P 3M 7m 9M\", \"\", \"9no5\"],\n [\"1P 3M 7m 9M 13M\", \"\", \"13no5\"],\n [\"1P 3M 7m 9M 13m\", \"\", \"9b13\"],\n [\"1P 3m 4P 5P\", \"\", \"madd4\"],\n [\"1P 3m 5P 6m 7M\", \"\", \"mMaj7b6\"],\n [\"1P 3m 5P 6m 7M 9M\", \"\", \"mMaj9b6\"],\n [\"1P 3m 5P 7m 11P\", \"\", \"m7add11 m7add4\"],\n [\"1P 3m 5P 9M\", \"\", \"madd9\"],\n [\"1P 3m 5d 6M 7M\", \"\", \"o7M7\"],\n [\"1P 3m 5d 7M\", \"\", \"oM7\"],\n [\"1P 3m 6m 7M\", \"\", \"mb6M7\"],\n [\"1P 3m 6m 7m\", \"\", \"m7#5\"],\n [\"1P 3m 6m 7m 9M\", \"\", \"m9#5\"],\n [\"1P 3m 5A 7m 9M 11P\", \"\", \"m11A\"],\n [\"1P 3m 6m 9m\", \"\", \"mb6b9\"],\n [\"1P 2M 3m 5d 7m\", \"\", \"m9b5\"],\n [\"1P 4P 5A 7M\", \"\", \"M7#5sus4\"],\n [\"1P 4P 5A 7M 9M\", \"\", \"M9#5sus4\"],\n [\"1P 4P 5A 7m\", \"\", \"7#5sus4\"],\n [\"1P 4P 5P 7M\", \"\", \"M7sus4\"],\n [\"1P 4P 5P 7M 9M\", \"\", \"M9sus4\"],\n [\"1P 4P 5P 7m 9M\", \"\", \"9sus4 9sus\"],\n [\"1P 4P 5P 7m 9M 13M\", \"\", \"13sus4 13sus\"],\n [\"1P 4P 5P 7m 9m 13m\", \"\", \"7sus4b9b13 7b9b13sus4\"],\n [\"1P 4P 7m 10m\", \"\", \"4 quartal\"],\n [\"1P 5P 7m 9m 11P\", \"\", \"11b9\"],\n];\n\nexport default CHORDS;\n", "import { all, ChordType } from \"@tonaljs/chord-type\";\nimport { note } from \"@tonaljs/core\";\nimport { modes } from \"@tonaljs/pcset\";\n\ninterface FoundChord {\n readonly weight: number;\n readonly name: string;\n}\n\nconst namedSet = (notes: string[]) => {\n const pcToName = notes.reduce>((record, n) => {\n const chroma = note(n).chroma;\n if (chroma !== undefined) {\n record[chroma] = record[chroma] || note(n).name;\n }\n return record;\n }, {});\n\n return (chroma: number) => pcToName[chroma];\n};\n\ntype DetectOptions = {\n assumePerfectFifth: boolean;\n};\nexport function detect(\n source: string[],\n options: Partial = {},\n): string[] {\n const notes = source.map((n) => note(n).pc).filter((x) => x);\n if (note.length === 0) {\n return [];\n }\n\n const found: FoundChord[] = findMatches(notes, 1, options);\n\n return found\n .filter((chord) => chord.weight)\n .sort((a, b) => b.weight - a.weight)\n .map((chord) => chord.name);\n}\n\n/* tslint:disable:no-bitwise */\nconst BITMASK = {\n // 3m 000100000000\n // 3M 000010000000\n anyThirds: 384,\n // 5P 000000010000\n perfectFifth: 16,\n // 5d 000000100000\n // 5A 000000001000\n nonPerfectFifths: 40,\n anySeventh: 3,\n};\n\nconst testChromaNumber = (bitmask: number) => (chromaNumber: number) =>\n Boolean(chromaNumber & bitmask);\nconst hasAnyThird = testChromaNumber(BITMASK.anyThirds);\nconst hasPerfectFifth = testChromaNumber(BITMASK.perfectFifth);\nconst hasAnySeventh = testChromaNumber(BITMASK.anySeventh);\nconst hasNonPerfectFifth = testChromaNumber(BITMASK.nonPerfectFifths);\n\nfunction hasAnyThirdAndPerfectFifthAndAnySeventh(chordType: ChordType) {\n const chromaNumber = parseInt(chordType.chroma, 2);\n return (\n hasAnyThird(chromaNumber) &&\n hasPerfectFifth(chromaNumber) &&\n hasAnySeventh(chromaNumber)\n );\n}\n\nfunction withPerfectFifth(chroma: string): string {\n const chromaNumber = parseInt(chroma, 2);\n return hasNonPerfectFifth(chromaNumber)\n ? chroma\n : (chromaNumber | 16).toString(2);\n}\n\n/* tslint:enable:no-bitwise */\n\ntype FindMatchesOptions = {\n assumePerfectFifth: boolean;\n};\nfunction findMatches(\n notes: string[],\n weight: number,\n options: Partial,\n): FoundChord[] {\n const tonic = notes[0];\n const tonicChroma = note(tonic).chroma;\n const noteName = namedSet(notes);\n // we need to test all chromas to get the correct baseNote\n const allModes = modes(notes, false);\n\n const found: FoundChord[] = [];\n allModes.forEach((mode, index) => {\n const modeWithPerfectFifth =\n options.assumePerfectFifth && withPerfectFifth(mode);\n // some chords could have the same chroma but different interval spelling\n const chordTypes = all().filter((chordType) => {\n if (\n options.assumePerfectFifth &&\n hasAnyThirdAndPerfectFifthAndAnySeventh(chordType)\n ) {\n return chordType.chroma === modeWithPerfectFifth;\n }\n return chordType.chroma === mode;\n });\n\n chordTypes.forEach((chordType) => {\n const chordName = chordType.aliases[0];\n const baseNote = noteName(index);\n const isInversion = index !== tonicChroma;\n if (isInversion) {\n found.push({\n weight: 0.5 * weight,\n name: `${baseNote}${chordName}/${tonic}`,\n });\n } else {\n found.push({ weight: 1 * weight, name: `${baseNote}${chordName}` });\n }\n });\n });\n\n return found;\n}\n\nexport default { detect };\n", "import { IntervalCoordinates, NoteCoordinates } from \"@tonaljs/pitch\";\nimport { distance as dist } from \"@tonaljs/pitch-distance\";\nimport {\n IntervalName,\n coordToInterval,\n interval as props,\n} from \"@tonaljs/pitch-interval\";\n\n/**\n * Get the natural list of names\n */\nexport function names(): IntervalName[] {\n return \"1P 2M 3M 4P 5P 6m 7m\".split(\" \");\n}\n\n/**\n * Get properties of an interval\n *\n * @function\n * @example\n * Interval.get('P4') // => {\"alt\": 0, \"dir\": 1, \"name\": \"4P\", \"num\": 4, \"oct\": 0, \"q\": \"P\", \"semitones\": 5, \"simple\": 4, \"step\": 3, \"type\": \"perfectable\"}\n */\nexport const get = props;\n\n/**\n * Get name of an interval\n *\n * @function\n * @example\n * Interval.name('4P') // => \"4P\"\n * Interval.name('P4') // => \"4P\"\n * Interval.name('C4') // => \"\"\n */\nexport const name = (name: string) => props(name).name;\n\n/**\n * Get semitones of an interval\n * @function\n * @example\n * Interval.semitones('P4') // => 5\n */\nexport const semitones = (name: string) => props(name).semitones;\n\n/**\n * Get quality of an interval\n * @function\n * @example\n * Interval.quality('P4') // => \"P\"\n */\nexport const quality = (name: string) => props(name).q;\n\n/**\n * Get number of an interval\n * @function\n * @example\n * Interval.num('P4') // => 4\n */\nexport const num = (name: string) => props(name).num;\n\n/**\n * Get the simplified version of an interval.\n *\n * @function\n * @param {string} interval - the interval to simplify\n * @return {string} the simplified interval\n *\n * @example\n * Interval.simplify(\"9M\") // => \"2M\"\n * Interval.simplify(\"2M\") // => \"2M\"\n * Interval.simplify(\"-2M\") // => \"7m\"\n * [\"8P\", \"9M\", \"10M\", \"11P\", \"12P\", \"13M\", \"14M\", \"15P\"].map(Interval.simplify)\n * // => [ \"8P\", \"2M\", \"3M\", \"4P\", \"5P\", \"6M\", \"7M\", \"8P\" ]\n */\nexport function simplify(name: IntervalName): IntervalName {\n const i = props(name);\n return i.empty ? \"\" : i.simple + i.q;\n}\n\n/**\n * Get the inversion (https://en.wikipedia.org/wiki/Inversion_(music)#Intervals)\n * of an interval.\n *\n * @function\n * @param {string} interval - the interval to invert in interval shorthand\n * notation or interval array notation\n * @return {string} the inverted interval\n *\n * @example\n * Interval.invert(\"3m\") // => \"6M\"\n * Interval.invert(\"2M\") // => \"7m\"\n */\nexport function invert(name: IntervalName): IntervalName {\n const i = props(name);\n if (i.empty) {\n return \"\";\n }\n const step = (7 - i.step) % 7;\n const alt = i.type === \"perfectable\" ? -i.alt : -(i.alt + 1);\n return props({ step, alt, oct: i.oct, dir: i.dir }).name;\n}\n\n// interval numbers\nconst IN = [1, 2, 2, 3, 3, 4, 5, 5, 6, 6, 7, 7];\n// interval qualities\nconst IQ = \"P m M m M P d P m M m M\".split(\" \");\n\n/**\n * Get interval name from semitones number. Since there are several interval\n * names for the same number, the name it's arbitrary, but deterministic.\n *\n * @param {Integer} num - the number of semitones (can be negative)\n * @return {string} the interval name\n * @example\n * Interval.fromSemitones(7) // => \"5P\"\n * Interval.fromSemitones(-7) // => \"-5P\"\n */\nexport function fromSemitones(semitones: number): IntervalName {\n const d = semitones < 0 ? -1 : 1;\n const n = Math.abs(semitones);\n const c = n % 12;\n const o = Math.floor(n / 12);\n return d * (IN[c] + 7 * o) + IQ[c];\n}\n\n/**\n * Find interval between two notes\n *\n * @example\n * Interval.distance(\"C4\", \"G4\"); // => \"5P\"\n */\nexport const distance = dist;\n\n/**\n * Adds two intervals\n *\n * @function\n * @param {string} interval1\n * @param {string} interval2\n * @return {string} the added interval name\n * @example\n * Interval.add(\"3m\", \"5P\") // => \"7m\"\n */\nexport const add = combinator((a, b) => [a[0] + b[0], a[1] + b[1]]);\n\n/**\n * Returns a function that adds an interval\n *\n * @function\n * @example\n * ['1P', '2M', '3M'].map(Interval.addTo('5P')) // => [\"5P\", \"6M\", \"7M\"]\n */\nexport const addTo = (interval: string) => (other: string) =>\n add(interval, other);\n\n/**\n * Subtracts two intervals\n *\n * @function\n * @param {string} minuendInterval\n * @param {string} subtrahendInterval\n * @return {string} the subtracted interval name\n * @example\n * Interval.subtract('5P', '3M') // => '3m'\n * Interval.subtract('3M', '5P') // => '-3m'\n */\nexport const subtract = combinator((a, b) => [a[0] - b[0], a[1] - b[1]]);\n\nexport function transposeFifths(\n interval: IntervalName,\n fifths: number,\n): IntervalName {\n const ivl = get(interval);\n if (ivl.empty) return \"\";\n\n const [nFifths, nOcts, dir] = ivl.coord;\n return coordToInterval([nFifths + fifths, nOcts, dir]).name;\n}\n\nexport default {\n names,\n get,\n name,\n num,\n semitones,\n quality,\n fromSemitones,\n distance,\n invert,\n simplify,\n add,\n addTo,\n subtract,\n transposeFifths,\n};\n\n//// PRIVATE ////\n\ntype Operation = (\n a: IntervalCoordinates,\n b: IntervalCoordinates,\n) => NoteCoordinates;\n\nfunction combinator(fn: Operation) {\n return (a: IntervalName, b: IntervalName): IntervalName | undefined => {\n const coordA = props(a).coord;\n const coordB = props(b).coord;\n if (coordA && coordB) {\n const coord = fn(coordA, coordB);\n return coordToInterval(coord).name;\n }\n };\n}\n", "import { deprecate } from \"@tonaljs/core\";\nimport {\n EmptyPcset,\n get as pcset,\n Pcset,\n PcsetChroma,\n PcsetNum,\n} from \"@tonaljs/pcset\";\nimport data from \"./data\";\n\n/**\n * Properties for a scale in the scale dictionary. It's a pitch class set\n * properties with the following additional information:\n * - name: the scale name\n * - aliases: alternative list of names\n * - intervals: an array of interval names\n */\nexport interface ScaleType extends Pcset {\n readonly name: string;\n readonly aliases: string[];\n}\n\nexport const NoScaleType: ScaleType = {\n ...EmptyPcset,\n intervals: [],\n aliases: [],\n};\n\ntype ScaleTypeName = string | PcsetChroma | PcsetNum;\n\nlet dictionary: ScaleType[] = [];\nlet index: Record = {};\n\nexport function names() {\n return dictionary.map((scale) => scale.name);\n}\n\n/**\n * Given a scale name or chroma, return the scale properties\n *\n * @param {string} type - scale name or pitch class set chroma\n * @example\n * import { get } from 'tonaljs/scale-type'\n * get('major') // => { name: 'major', ... }\n */\nexport function get(type: ScaleTypeName): ScaleType {\n return index[type] || NoScaleType;\n}\n\nexport const scaleType = deprecate(\n \"ScaleDictionary.scaleType\",\n \"ScaleType.get\",\n get,\n);\n\n/**\n * Return a list of all scale types\n */\nexport function all() {\n return dictionary.slice();\n}\n\nexport const entries = deprecate(\n \"ScaleDictionary.entries\",\n \"ScaleType.all\",\n all,\n);\n\n/**\n * Keys used to reference scale types\n */\nexport function keys() {\n return Object.keys(index);\n}\n\n/**\n * Clear the dictionary\n */\nexport function removeAll() {\n dictionary = [];\n index = {};\n}\n\n/**\n * Add a scale into dictionary\n * @param intervals\n * @param name\n * @param aliases\n */\nexport function add(\n intervals: string[],\n name: string,\n aliases: string[] = [],\n): ScaleType {\n const scale = { ...pcset(intervals), name, intervals, aliases };\n dictionary.push(scale);\n index[scale.name] = scale;\n index[scale.setNum] = scale;\n index[scale.chroma] = scale;\n scale.aliases.forEach((alias) => addAlias(scale, alias));\n return scale;\n}\n\nexport function addAlias(scale: ScaleType, alias: string) {\n index[alias] = scale;\n}\n\ndata.forEach(([ivls, name, ...aliases]: string[]) =>\n add(ivls.split(\" \"), name, aliases),\n);\n\nexport default {\n names,\n get,\n all,\n add,\n removeAll,\n keys,\n\n // deprecated\n entries,\n scaleType,\n};\n", "// SCALES\n// Format: [\"intervals\", \"name\", \"alias1\", \"alias2\", ...]\nconst SCALES: string[][] = [\n // Basic scales\n [\"1P 2M 3M 5P 6M\", \"major pentatonic\", \"pentatonic\"],\n [\"1P 2M 3M 4P 5P 6M 7M\", \"major\", \"ionian\"],\n [\"1P 2M 3m 4P 5P 6m 7m\", \"minor\", \"aeolian\"],\n\n // Jazz common scales\n [\"1P 2M 3m 3M 5P 6M\", \"major blues\"],\n [\"1P 3m 4P 5d 5P 7m\", \"minor blues\", \"blues\"],\n [\"1P 2M 3m 4P 5P 6M 7M\", \"melodic minor\"],\n [\"1P 2M 3m 4P 5P 6m 7M\", \"harmonic minor\"],\n [\"1P 2M 3M 4P 5P 6M 7m 7M\", \"bebop\"],\n [\"1P 2M 3m 4P 5d 6m 6M 7M\", \"diminished\", \"whole-half diminished\"],\n\n // Modes\n [\"1P 2M 3m 4P 5P 6M 7m\", \"dorian\"],\n [\"1P 2M 3M 4A 5P 6M 7M\", \"lydian\"],\n [\"1P 2M 3M 4P 5P 6M 7m\", \"mixolydian\", \"dominant\"],\n [\"1P 2m 3m 4P 5P 6m 7m\", \"phrygian\"],\n [\"1P 2m 3m 4P 5d 6m 7m\", \"locrian\"],\n\n // 5-note scales\n [\"1P 3M 4P 5P 7M\", \"ionian pentatonic\"],\n [\"1P 3M 4P 5P 7m\", \"mixolydian pentatonic\", \"indian\"],\n [\"1P 2M 4P 5P 6M\", \"ritusen\"],\n [\"1P 2M 4P 5P 7m\", \"egyptian\"],\n [\"1P 3M 4P 5d 7m\", \"neopolitan major pentatonic\"],\n [\"1P 3m 4P 5P 6m\", \"vietnamese 1\"],\n [\"1P 2m 3m 5P 6m\", \"pelog\"],\n [\"1P 2m 4P 5P 6m\", \"kumoijoshi\"],\n [\"1P 2M 3m 5P 6m\", \"hirajoshi\"],\n [\"1P 2m 4P 5d 7m\", \"iwato\"],\n [\"1P 2m 4P 5P 7m\", \"in-sen\"],\n [\"1P 3M 4A 5P 7M\", \"lydian pentatonic\", \"chinese\"],\n [\"1P 3m 4P 6m 7m\", \"malkos raga\"],\n [\"1P 3m 4P 5d 7m\", \"locrian pentatonic\", \"minor seven flat five pentatonic\"],\n [\"1P 3m 4P 5P 7m\", \"minor pentatonic\", \"vietnamese 2\"],\n [\"1P 3m 4P 5P 6M\", \"minor six pentatonic\"],\n [\"1P 2M 3m 5P 6M\", \"flat three pentatonic\", \"kumoi\"],\n [\"1P 2M 3M 5P 6m\", \"flat six pentatonic\"],\n [\"1P 2m 3M 5P 6M\", \"scriabin\"],\n [\"1P 3M 5d 6m 7m\", \"whole tone pentatonic\"],\n [\"1P 3M 4A 5A 7M\", \"lydian #5P pentatonic\"],\n [\"1P 3M 4A 5P 7m\", \"lydian dominant pentatonic\"],\n [\"1P 3m 4P 5P 7M\", \"minor #7M pentatonic\"],\n [\"1P 3m 4d 5d 7m\", \"super locrian pentatonic\"],\n\n // 6-note scales\n [\"1P 2M 3m 4P 5P 7M\", \"minor hexatonic\"],\n [\"1P 2A 3M 5P 5A 7M\", \"augmented\"],\n [\"1P 2M 4P 5P 6M 7m\", \"piongio\"],\n [\"1P 2m 3M 4A 6M 7m\", \"prometheus neopolitan\"],\n [\"1P 2M 3M 4A 6M 7m\", \"prometheus\"],\n [\"1P 2m 3M 5d 6m 7m\", \"mystery #1\"],\n [\"1P 2m 3M 4P 5A 6M\", \"six tone symmetric\"],\n [\"1P 2M 3M 4A 5A 6A\", \"whole tone\", \"messiaen's mode #1\"],\n [\"1P 2m 4P 4A 5P 7M\", \"messiaen's mode #5\"],\n\n // 7-note scales\n [\"1P 2M 3M 4P 5d 6m 7m\", \"locrian major\", \"arabian\"],\n [\"1P 2m 3M 4A 5P 6m 7M\", \"double harmonic lydian\"],\n [\n \"1P 2m 2A 3M 4A 6m 7m\",\n \"altered\",\n \"super locrian\",\n \"diminished whole tone\",\n \"pomeroy\",\n ],\n [\"1P 2M 3m 4P 5d 6m 7m\", \"locrian #2\", \"half-diminished\", \"aeolian b5\"],\n [\n \"1P 2M 3M 4P 5P 6m 7m\",\n \"mixolydian b6\",\n \"melodic minor fifth mode\",\n \"hindu\",\n ],\n [\"1P 2M 3M 4A 5P 6M 7m\", \"lydian dominant\", \"lydian b7\", \"overtone\"],\n [\"1P 2M 3M 4A 5A 6M 7M\", \"lydian augmented\"],\n [\n \"1P 2m 3m 4P 5P 6M 7m\",\n \"dorian b2\",\n \"phrygian #6\",\n \"melodic minor second mode\",\n ],\n [\n \"1P 2m 3m 4d 5d 6m 7d\",\n \"ultralocrian\",\n \"superlocrian bb7\",\n \"superlocrian diminished\",\n ],\n [\"1P 2m 3m 4P 5d 6M 7m\", \"locrian 6\", \"locrian natural 6\", \"locrian sharp 6\"],\n [\"1P 2A 3M 4P 5P 5A 7M\", \"augmented heptatonic\"],\n // Source https://en.wikipedia.org/wiki/Ukrainian_Dorian_scale\n [\n \"1P 2M 3m 4A 5P 6M 7m\",\n \"dorian #4\",\n \"ukrainian dorian\",\n \"romanian minor\",\n \"altered dorian\",\n ],\n [\"1P 2M 3m 4A 5P 6M 7M\", \"lydian diminished\"],\n [\"1P 2M 3M 4A 5A 7m 7M\", \"leading whole tone\"],\n [\"1P 2M 3M 4A 5P 6m 7m\", \"lydian minor\"],\n [\"1P 2m 3M 4P 5P 6m 7m\", \"phrygian dominant\", \"spanish\", \"phrygian major\"],\n [\"1P 2m 3m 4P 5P 6m 7M\", \"balinese\"],\n [\"1P 2m 3m 4P 5P 6M 7M\", \"neopolitan major\"],\n [\"1P 2M 3M 4P 5P 6m 7M\", \"harmonic major\"],\n [\"1P 2m 3M 4P 5P 6m 7M\", \"double harmonic major\", \"gypsy\"],\n [\"1P 2M 3m 4A 5P 6m 7M\", \"hungarian minor\"],\n [\"1P 2A 3M 4A 5P 6M 7m\", \"hungarian major\"],\n [\"1P 2m 3M 4P 5d 6M 7m\", \"oriental\"],\n [\"1P 2m 3m 3M 4A 5P 7m\", \"flamenco\"],\n [\"1P 2m 3m 4A 5P 6m 7M\", \"todi raga\"],\n [\"1P 2m 3M 4P 5d 6m 7M\", \"persian\"],\n [\"1P 2m 3M 5d 6m 7m 7M\", \"enigmatic\"],\n [\n \"1P 2M 3M 4P 5A 6M 7M\",\n \"major augmented\",\n \"major #5\",\n \"ionian augmented\",\n \"ionian #5\",\n ],\n [\"1P 2A 3M 4A 5P 6M 7M\", \"lydian #9\"],\n\n // 8-note scales\n [\"1P 2m 2M 4P 4A 5P 6m 7M\", \"messiaen's mode #4\"],\n [\"1P 2m 3M 4P 4A 5P 6m 7M\", \"purvi raga\"],\n [\"1P 2m 3m 3M 4P 5P 6m 7m\", \"spanish heptatonic\"],\n [\"1P 2M 3m 3M 4P 5P 6M 7m\", \"bebop minor\"],\n [\"1P 2M 3M 4P 5P 5A 6M 7M\", \"bebop major\"],\n [\"1P 2m 3m 4P 5d 5P 6m 7m\", \"bebop locrian\"],\n [\"1P 2M 3m 4P 5P 6m 7m 7M\", \"minor bebop\"],\n [\"1P 2M 3M 4P 5d 5P 6M 7M\", \"ichikosucho\"],\n [\"1P 2M 3m 4P 5P 6m 6M 7M\", \"minor six diminished\"],\n [\n \"1P 2m 3m 3M 4A 5P 6M 7m\",\n \"half-whole diminished\",\n \"dominant diminished\",\n \"messiaen's mode #2\",\n ],\n [\"1P 3m 3M 4P 5P 6M 7m 7M\", \"kafi raga\"],\n [\"1P 2M 3M 4P 4A 5A 6A 7M\", \"messiaen's mode #6\"],\n\n // 9-note scales\n [\"1P 2M 3m 3M 4P 5d 5P 6M 7m\", \"composite blues\"],\n [\"1P 2M 3m 3M 4A 5P 6m 7m 7M\", \"messiaen's mode #3\"],\n\n // 10-note scales\n [\"1P 2m 2M 3m 4P 4A 5P 6m 6M 7M\", \"messiaen's mode #7\"],\n\n // 12-note scales\n [\"1P 2m 2M 3m 3M 4P 5d 5P 6m 6M 7m 7M\", \"chromatic\"],\n];\n\nexport default SCALES;\n", "import { detect } from \"@tonaljs/chord-detect\";\nimport {\n ChordType,\n all as chordTypes,\n get as getChordType,\n} from \"@tonaljs/chord-type\";\nimport { subtract } from \"@tonaljs/interval\";\nimport { isSubsetOf, isSupersetOf } from \"@tonaljs/pcset\";\nimport {\n distance,\n tonicIntervalsTransposer,\n transpose as transposeNote,\n} from \"@tonaljs/pitch-distance\";\nimport { NoteName, note, tokenizeNote } from \"@tonaljs/pitch-note\";\nimport { all as scaleTypes } from \"@tonaljs/scale-type\";\n\nexport { detect } from \"@tonaljs/chord-detect\";\n\ntype ChordNameOrTokens =\n | string // full name to be parsed\n | [string] // only the name\n | [string, string] // tonic, name\n | [string, string, string]; // tonic, name, bass\ntype ChordNameTokens = [string, string, string]; // [TONIC, SCALE TYPE, BASS]\n\nexport interface Chord extends ChordType {\n tonic: string | null;\n type: string;\n root: string;\n bass: string;\n rootDegree: number;\n symbol: string;\n notes: NoteName[];\n}\n\nconst NoChord: Chord = {\n empty: true,\n name: \"\",\n symbol: \"\",\n root: \"\",\n bass: \"\",\n rootDegree: 0,\n type: \"\",\n tonic: null,\n setNum: NaN,\n quality: \"Unknown\",\n chroma: \"\",\n normalized: \"\",\n aliases: [],\n notes: [],\n intervals: [],\n};\n\n// 6, 64, 7, 9, 11 and 13 are consider part of the chord\n// (see https://github.com/danigb/tonal/issues/55)\n//const NUM_TYPES = /^(6|64|7|9|11|13)$/;\n/**\n * Tokenize a chord name. It returns an array with the tonic, chord type and bass\n * If not tonic is found, all the name is considered the chord name.\n *\n * This function does NOT check if the chord type exists or not. It only tries\n * to split the tonic and chord type.\n *\n * This function does NOT check if the bass is part of the chord or not but it\n * only accepts a pitch class as bass\n *\n * @function\n * @param {string} name - the chord name\n * @return {Array} an array with [tonic, type, bass]\n * @example\n * tokenize(\"Cmaj7\") // => [ \"C\", \"maj7\" ]\n * tokenize(\"C7\") // => [ \"C\", \"7\" ]\n * tokenize(\"mMaj7\") // => [ null, \"mMaj7\" ]\n * tokenize(\"Cnonsense\") // => [ null, \"nonsense\" ]\n */\nexport function tokenize(name: string): ChordNameTokens {\n const [letter, acc, oct, type] = tokenizeNote(name);\n if (letter === \"\") {\n return tokenizeBass(\"\", name);\n } else if (letter === \"A\" && type === \"ug\") {\n return tokenizeBass(\"\", \"aug\");\n } else {\n return tokenizeBass(letter + acc, oct + type);\n }\n}\n\nfunction tokenizeBass(note: string, chord: string): ChordNameTokens {\n const split = chord.split(\"/\");\n if (split.length === 1) {\n return [note, split[0], \"\"];\n }\n const [letter, acc, oct, type] = tokenizeNote(split[1]);\n // Only a pitch class is accepted as bass note\n if (letter !== \"\" && oct === \"\" && type === \"\") {\n return [note, split[0], letter + acc];\n } else {\n return [note, chord, \"\"];\n }\n}\n\n/**\n * Get a Chord from a chord name.\n */\nexport function get(src: ChordNameOrTokens): Chord {\n if (Array.isArray(src)) {\n return getChord(src[1] || \"\", src[0], src[2]);\n } else if (src === \"\") {\n return NoChord;\n } else {\n const [tonic, type, bass] = tokenize(src);\n const chord = getChord(type, tonic, bass);\n return chord.empty ? getChord(src) : chord;\n }\n}\n\n/**\n * Get chord properties\n *\n * @param typeName - the chord type name\n * @param [tonic] - Optional tonic\n * @param [root] - Optional root (requires a tonic)\n */\nexport function getChord(\n typeName: string,\n optionalTonic?: string,\n optionalBass?: string,\n): Chord {\n const type = getChordType(typeName);\n const tonic = note(optionalTonic || \"\");\n const bass = note(optionalBass || \"\");\n\n if (\n type.empty ||\n (optionalTonic && tonic.empty) ||\n (optionalBass && bass.empty)\n ) {\n return NoChord;\n }\n\n const bassInterval = distance(tonic.pc, bass.pc);\n const bassIndex = type.intervals.indexOf(bassInterval);\n const hasRoot = bassIndex >= 0;\n const root = hasRoot ? bass : note(\"\");\n const rootDegree = bassIndex === -1 ? NaN : bassIndex + 1;\n const hasBass = bass.pc && bass.pc !== tonic.pc;\n\n const intervals = Array.from(type.intervals);\n\n if (hasRoot) {\n for (let i = 1; i < rootDegree; i++) {\n const num = intervals[0][0];\n const quality = intervals[0][1];\n const newNum = parseInt(num, 10) + 7;\n intervals.push(`${newNum}${quality}`);\n intervals.shift();\n }\n } else if (hasBass) {\n const ivl = subtract(distance(tonic.pc, bass.pc), \"8P\");\n if (ivl) intervals.unshift(ivl);\n }\n\n const notes = tonic.empty\n ? []\n : intervals.map((i) => transposeNote(tonic.pc, i));\n\n typeName = type.aliases.indexOf(typeName) !== -1 ? typeName : type.aliases[0];\n const symbol = `${tonic.empty ? \"\" : tonic.pc}${typeName}${\n hasRoot && rootDegree > 1 ? \"/\" + root.pc : hasBass ? \"/\" + bass.pc : \"\"\n }`;\n const name = `${optionalTonic ? tonic.pc + \" \" : \"\"}${type.name}${\n hasRoot && rootDegree > 1\n ? \" over \" + root.pc\n : hasBass\n ? \" over \" + bass.pc\n : \"\"\n }`;\n return {\n ...type,\n name,\n symbol,\n tonic: tonic.pc,\n type: type.name,\n root: root.pc,\n bass: hasBass ? bass.pc : \"\",\n intervals,\n rootDegree,\n notes,\n };\n}\n\nexport const chord = get;\n\n/**\n * Transpose a chord name\n *\n * @param {string} chordName - the chord name\n * @return {string} the transposed chord\n *\n * @example\n * transpose('Dm7', 'P4') // => 'Gm7\n */\nexport function transpose(chordName: string, interval: string): string {\n const [tonic, type, bass] = tokenize(chordName);\n if (!tonic) {\n return chordName;\n }\n const tr = transposeNote(bass, interval);\n const slash = tr ? \"/\" + tr : \"\";\n return transposeNote(tonic, interval) + type + slash;\n}\n\n/**\n * Get all scales where the given chord fits\n *\n * @example\n * chordScales('C7b9')\n * // => [\"phrygian dominant\", \"flamenco\", \"spanish heptatonic\", \"half-whole diminished\", \"chromatic\"]\n */\nexport function chordScales(name: string): string[] {\n const s = get(name);\n const isChordIncluded = isSupersetOf(s.chroma);\n return scaleTypes()\n .filter((scale) => isChordIncluded(scale.chroma))\n .map((scale) => scale.name);\n}\n/**\n * Get all chords names that are a superset of the given one\n * (has the same notes and at least one more)\n *\n * @function\n * @example\n * extended(\"CMaj7\")\n * // => [ 'Cmaj#4', 'Cmaj7#9#11', 'Cmaj9', 'CM7add13', 'Cmaj13', 'Cmaj9#11', 'CM13#11', 'CM7b9' ]\n */\nexport function extended(chordName: string): string[] {\n const s = get(chordName);\n const isSuperset = isSupersetOf(s.chroma);\n return chordTypes()\n .filter((chord) => isSuperset(chord.chroma))\n .map((chord) => s.tonic + chord.aliases[0]);\n}\n\n/**\n * Find all chords names that are a subset of the given one\n * (has less notes but all from the given chord)\n *\n * @example\n */\nexport function reduced(chordName: string): string[] {\n const s = get(chordName);\n const isSubset = isSubsetOf(s.chroma);\n return chordTypes()\n .filter((chord) => isSubset(chord.chroma))\n .map((chord) => s.tonic + chord.aliases[0]);\n}\n\n/**\n * Return the chord notes\n */\nexport function notes(chordName: ChordNameOrTokens, tonic?: string): string[] {\n const chord = get(chordName);\n const note = tonic || chord.tonic;\n if (!note || chord.empty) return [];\n return chord.intervals.map((ivl) => transposeNote(note, ivl));\n}\n\n/**\n * Returns a function to get a note name from the scale degree.\n *\n * @example\n * [1, 2, 3, 4].map(Chord.degrees(\"C\")) => [\"C\", \"E\", \"G\", \"C\"]\n * [1, 2, 3, 4].map(Chord.degrees(\"C4\")) => [\"C4\", \"E4\", \"G4\", \"C5\"]\n */\nexport function degrees(chordName: ChordNameOrTokens, tonic?: string) {\n const chord = get(chordName);\n const note = tonic || chord.tonic;\n const transpose = tonicIntervalsTransposer(chord.intervals, note);\n return (degree: number) =>\n degree ? transpose(degree > 0 ? degree - 1 : degree) : \"\";\n}\n\n/**\n * Sames as `degree` but with 0-based index\n */\nexport function steps(chordName: ChordNameOrTokens, tonic?: string) {\n const chord = get(chordName);\n const note = tonic || chord.tonic;\n return tonicIntervalsTransposer(chord.intervals, note);\n}\n\nexport default {\n getChord,\n get,\n detect,\n chordScales,\n extended,\n reduced,\n tokenize,\n transpose,\n degrees,\n steps,\n notes,\n chord,\n};\n", "// source: https://en.wikipedia.org/wiki/Note_value\nconst DATA: [number, string, string[]][] = [\n [\n 0.125,\n \"dl\",\n [\"large\", \"duplex longa\", \"maxima\", \"octuple\", \"octuple whole\"],\n ],\n [0.25, \"l\", [\"long\", \"longa\"]],\n [0.5, \"d\", [\"double whole\", \"double\", \"breve\"]],\n [1, \"w\", [\"whole\", \"semibreve\"]],\n [2, \"h\", [\"half\", \"minim\"]],\n [4, \"q\", [\"quarter\", \"crotchet\"]],\n [8, \"e\", [\"eighth\", \"quaver\"]],\n [16, \"s\", [\"sixteenth\", \"semiquaver\"]],\n [32, \"t\", [\"thirty-second\", \"demisemiquaver\"]],\n [64, \"sf\", [\"sixty-fourth\", \"hemidemisemiquaver\"]],\n [128, \"h\", [\"hundred twenty-eighth\"]],\n [256, \"th\", [\"two hundred fifty-sixth\"]],\n];\n\nexport default DATA;\n", "import DATA from \"./data\";\n\ntype Fraction = [number, number];\n\nconst VALUES: DurationValue[] = [];\n\nDATA.forEach(([denominator, shorthand, names]) =>\n add(denominator, shorthand, names),\n);\n\nexport interface DurationValue {\n empty: boolean;\n value: number;\n name: string;\n fraction: Fraction;\n shorthand: string;\n dots: string;\n names: string[];\n}\n\nconst NoDuration: DurationValue = {\n empty: true,\n name: \"\",\n value: 0,\n fraction: [0, 0],\n shorthand: \"\",\n dots: \"\",\n names: [],\n};\n\nexport function names(): string[] {\n return VALUES.reduce((names, duration) => {\n duration.names.forEach((name) => names.push(name));\n return names;\n }, [] as string[]);\n}\n\nexport function shorthands(): string[] {\n return VALUES.map((dur) => dur.shorthand);\n}\n\nconst REGEX = /^([^.]+)(\\.*)$/;\n\nexport function get(name: string): DurationValue {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const [_, simple, dots] = REGEX.exec(name) || [];\n const base = VALUES.find(\n (dur) => dur.shorthand === simple || dur.names.includes(simple),\n );\n if (!base) {\n return NoDuration;\n }\n\n const fraction = calcDots(base.fraction, dots.length);\n const value = fraction[0] / fraction[1];\n\n return { ...base, name, dots, value, fraction };\n}\n\nexport const value = (name: string) => get(name).value;\nexport const fraction = (name: string) => get(name).fraction;\n\nexport default { names, shorthands, get, value, fraction };\n\n//// PRIVATE ////\n\nfunction add(denominator: number, shorthand: string, names: string[]) {\n VALUES.push({\n empty: false,\n dots: \"\",\n name: \"\",\n value: 1 / denominator,\n fraction: denominator < 1 ? [1 / denominator, 1] : [1, denominator],\n shorthand,\n names,\n });\n}\n\nfunction calcDots(fraction: Fraction, dots: number): Fraction {\n const pow = Math.pow(2, dots);\n\n let numerator = fraction[0] * pow;\n let denominator = fraction[1] * pow;\n const base = numerator;\n\n // add fractions\n for (let i = 0; i < dots; i++) {\n numerator += base / Math.pow(2, i + 1);\n }\n\n // simplify\n while (numerator % 2 === 0 && denominator % 2 === 0) {\n numerator /= 2;\n denominator /= 2;\n }\n return [numerator, denominator];\n}\n", "import { NoteName, note as props } from \"@tonaljs/core\";\n\ntype Midi = number;\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function isMidi(arg: any): arg is Midi {\n return +arg >= 0 && +arg <= 127;\n}\n\n/**\n * Get the note midi number (a number between 0 and 127)\n *\n * It returns undefined if not valid note name\n *\n * @function\n * @param {string|number} note - the note name or midi number\n * @return {Integer} the midi number or undefined if not valid note\n * @example\n * import { toMidi } from '@tonaljs/midi'\n * toMidi(\"C4\") // => 60\n * toMidi(60) // => 60\n * toMidi('60') // => 60\n */\nexport function toMidi(note: NoteName | number): number | null {\n if (isMidi(note)) {\n return +note;\n }\n const n = props(note);\n return n.empty ? null : n.midi;\n}\n\n/**\n * Get the frequency in hertzs from midi number\n *\n * @param {number} midi - the note midi number\n * @param {number} [tuning = 440] - A4 tuning frequency in Hz (440 by default)\n * @return {number} the frequency or null if not valid note midi\n * @example\n * import { midiToFreq} from '@tonaljs/midi'\n * midiToFreq(69) // => 440\n */\nexport function midiToFreq(midi: number, tuning = 440): number {\n return Math.pow(2, (midi - 69) / 12) * tuning;\n}\n\nconst L2 = Math.log(2);\nconst L440 = Math.log(440);\n\n/**\n * Get the midi number from a frequency in hertz. The midi number can\n * contain decimals (with two digits precision)\n *\n * @param {number} frequency\n * @return {number}\n * @example\n * import { freqToMidi} from '@tonaljs/midi'\n * freqToMidi(220)); //=> 57\n * freqToMidi(261.62)); //=> 60\n * freqToMidi(261)); //=> 59.96\n */\nexport function freqToMidi(freq: number): number {\n const v = (12 * (Math.log(freq) - L440)) / L2 + 69;\n return Math.round(v * 100) / 100;\n}\n\nexport interface ToNoteNameOptions {\n pitchClass?: boolean;\n sharps?: boolean;\n}\n\nconst SHARPS = \"C C# D D# E F F# G G# A A# B\".split(\" \");\nconst FLATS = \"C Db D Eb E F Gb G Ab A Bb B\".split(\" \");\n/**\n * Given a midi number, returns a note name. The altered notes will have\n * flats unless explicitly set with the optional `useSharps` parameter.\n *\n * @function\n * @param {number} midi - the midi note number\n * @param {Object} options = default: `{ sharps: false, pitchClass: false }`\n * @param {boolean} useSharps - (Optional) set to true to use sharps instead of flats\n * @return {string} the note name\n * @example\n * import { midiToNoteName } from '@tonaljs/midi'\n * midiToNoteName(61) // => \"Db4\"\n * midiToNoteName(61, { pitchClass: true }) // => \"Db\"\n * midiToNoteName(61, { sharps: true }) // => \"C#4\"\n * midiToNoteName(61, { pitchClass: true, sharps: true }) // => \"C#\"\n * // it rounds to nearest note\n * midiToNoteName(61.7) // => \"D4\"\n */\nexport function midiToNoteName(midi: number, options: ToNoteNameOptions = {}) {\n if (isNaN(midi) || midi === -Infinity || midi === Infinity) return \"\";\n midi = Math.round(midi);\n const pcs = options.sharps === true ? SHARPS : FLATS;\n const pc = pcs[midi % 12];\n if (options.pitchClass) {\n return pc;\n }\n const o = Math.floor(midi / 12) - 1;\n return pc + o;\n}\n\nexport function chroma(midi: number): number {\n return midi % 12;\n}\n\nfunction pcsetFromChroma(chroma: string): number[] {\n return chroma.split(\"\").reduce((pcset, val, index) => {\n if (index < 12 && val === \"1\") pcset.push(index);\n return pcset;\n }, [] as number[]);\n}\n\nfunction pcsetFromMidi(midi: number[]): number[] {\n return midi\n .map(chroma)\n .sort((a, b) => a - b)\n .filter((n, i, a) => i === 0 || n !== a[i - 1]);\n}\n\n/**\n * Given a list of midi numbers, returns the pitch class set (unique chroma numbers)\n * @param midi\n * @example\n *\n */\nexport function pcset(notes: number[] | string): number[] {\n return Array.isArray(notes) ? pcsetFromMidi(notes) : pcsetFromChroma(notes);\n}\n\nexport function pcsetNearest(notes: number[] | string) {\n const set = pcset(notes);\n return (midi: number): number | undefined => {\n const ch = chroma(midi);\n for (let i = 0; i < 12; i++) {\n if (set.includes(ch + i)) return midi + i;\n if (set.includes(ch - i)) return midi - i;\n }\n return undefined;\n };\n}\n\nexport function pcsetSteps(notes: number[] | string, tonic: number) {\n const set = pcset(notes);\n const len = set.length;\n return (step: number): number => {\n const index = step < 0 ? (len - (-step % len)) % len : step % len;\n const octaves = Math.floor(step / len);\n return set[index] + octaves * 12 + tonic;\n };\n}\n\nexport function pcsetDegrees(notes: number[] | string, tonic: number) {\n const steps = pcsetSteps(notes, tonic);\n return (degree: number): number | undefined => {\n if (degree === 0) return undefined;\n return steps(degree > 0 ? degree - 1 : degree);\n };\n}\n\nexport default {\n chroma,\n freqToMidi,\n isMidi,\n midiToFreq,\n midiToNoteName,\n pcsetNearest,\n pcset,\n pcsetDegrees,\n pcsetSteps,\n toMidi,\n};\n", "/* eslint-disable @typescript-eslint/no-explicit-any */\nimport {\n IntervalName,\n Note,\n NoteLiteral,\n NoteName,\n Pitch,\n transpose as _tr,\n note as props,\n} from \"@tonaljs/core\";\nimport { freqToMidi, midiToNoteName } from \"@tonaljs/midi\";\n\nconst NAMES = [\"C\", \"D\", \"E\", \"F\", \"G\", \"A\", \"B\"];\n\nconst toName = (n: Note) => n.name;\nconst onlyNotes = (array: any[]) =>\n array.map(props).filter((n) => !n.empty) as Note[];\n\n/**\n * Return the natural note names without octave\n * @function\n * @example\n * Note.names(); // => [\"C\", \"D\", \"E\", \"F\", \"G\", \"A\", \"B\"]\n */\nexport function names(array?: any[]): string[] {\n if (array === undefined) {\n return NAMES.slice();\n } else if (!Array.isArray(array)) {\n return [];\n } else {\n return onlyNotes(array).map(toName);\n }\n}\n\n/**\n * Get a note from a note name\n *\n * @function\n * @example\n * Note.get('Bb4') // => { name: \"Bb4\", midi: 70, chroma: 10, ... }\n */\nexport const get = props;\n\n/**\n * Get the note name\n * @function\n */\nexport const name = (note: NoteLiteral) => get(note).name;\n\n/**\n * Get the note pitch class name\n * @function\n */\nexport const pitchClass = (note: NoteLiteral) => get(note).pc;\n\n/**\n * Get the note accidentals\n * @function\n */\nexport const accidentals = (note: NoteLiteral) => get(note).acc;\n\n/**\n * Get the note octave\n * @function\n */\nexport const octave = (note: NoteLiteral) => get(note).oct;\n\n/**\n * Get the note midi\n * @function\n */\nexport const midi = (note: NoteLiteral) => get(note).midi;\n\n/**\n * Get the note midi\n * @function\n */\nexport const freq = (note: NoteLiteral) => get(note).freq;\n\n/**\n * Get the note chroma\n * @function\n */\nexport const chroma = (note: NoteLiteral) => get(note).chroma;\n\n/**\n * Given a midi number, returns a note name. Uses flats for altered notes.\n *\n * @function\n * @param {number} midi - the midi note number\n * @return {string} the note name\n * @example\n * Note.fromMidi(61) // => \"Db4\"\n * Note.fromMidi(61.7) // => \"D4\"\n */\nexport function fromMidi(midi: number) {\n return midiToNoteName(midi);\n}\n\n/**\n * Given a midi number, returns a note name. Uses flats for altered notes.\n */\nexport function fromFreq(freq: number) {\n return midiToNoteName(freqToMidi(freq));\n}\n/**\n * Given a midi number, returns a note name. Uses flats for altered notes.\n */\nexport function fromFreqSharps(freq: number) {\n return midiToNoteName(freqToMidi(freq), { sharps: true });\n}\n\n/**\n * Given a midi number, returns a note name. Uses flats for altered notes.\n *\n * @function\n * @param {number} midi - the midi note number\n * @return {string} the note name\n * @example\n * Note.fromMidiSharps(61) // => \"C#4\"\n */\n\nexport function fromMidiSharps(midi: number) {\n return midiToNoteName(midi, { sharps: true });\n}\n\n/**\n * Transpose a note by an interval\n */\nexport const transpose = _tr;\nexport const tr = _tr;\n\n/**\n * Transpose by an interval.\n * @function\n * @param {string} interval\n * @return {function} a function that transposes by the given interval\n * @example\n * [\"C\", \"D\", \"E\"].map(Note.transposeBy(\"5P\"));\n * // => [\"G\", \"A\", \"B\"]\n */\nexport const transposeBy = (interval: IntervalName) => (note: NoteName) =>\n transpose(note, interval);\nexport const trBy = transposeBy;\n\n/**\n * Transpose from a note\n * @function\n * @param {string} note\n * @return {function} a function that transposes the the note by an interval\n * [\"1P\", \"3M\", \"5P\"].map(Note.transposeFrom(\"C\"));\n * // => [\"C\", \"E\", \"G\"]\n */\nexport const transposeFrom = (note: NoteName) => (interval: IntervalName) =>\n transpose(note, interval);\nexport const trFrom = transposeFrom;\n\n/**\n * Transpose a note by a number of perfect fifths.\n *\n * @function\n * @param {string} note - the note name\n * @param {number} fifhts - the number of fifths\n * @return {string} the transposed note name\n *\n * @example\n * import { transposeFifths } from \"@tonaljs/note\"\n * transposeFifths(\"G4\", 1) // => \"D\"\n * [0, 1, 2, 3, 4].map(fifths => transposeFifths(\"C\", fifths)) // => [\"C\", \"G\", \"D\", \"A\", \"E\"]\n */\nexport function transposeFifths(noteName: NoteName, fifths: number): NoteName {\n return transpose(noteName, [fifths, 0]);\n}\nexport const trFifths = transposeFifths;\n\n// TODO: documentation\nexport function transposeOctaves(\n noteName: NoteName,\n octaves: number,\n): NoteName {\n return transpose(noteName, [0, octaves]);\n}\n\nexport type NoteComparator = (a: Note, b: Note) => number;\n\nexport const ascending: NoteComparator = (a, b) => a.height - b.height;\nexport const descending: NoteComparator = (a, b) => b.height - a.height;\n\nexport function sortedNames(\n notes: any[],\n comparator?: NoteComparator,\n): string[] {\n comparator = comparator || ascending;\n return onlyNotes(notes).sort(comparator).map(toName);\n}\n\nexport function sortedUniqNames(notes: any[]): string[] {\n return sortedNames(notes, ascending).filter(\n (n, i, a) => i === 0 || n !== a[i - 1],\n );\n}\n\n/**\n * Simplify a note\n *\n * @function\n * @param {string} note - the note to be simplified\n * - sameAccType: default true. Use same kind of accidentals that source\n * @return {string} the simplified note or '' if not valid note\n * @example\n * simplify(\"C##\") // => \"D\"\n * simplify(\"C###\") // => \"D#\"\n * simplify(\"C###\")\n * simplify(\"B#4\") // => \"C5\"\n */\nexport const simplify = (noteName: NoteName | Pitch): string => {\n const note = get(noteName);\n if (note.empty) {\n return \"\";\n }\n return midiToNoteName(note.midi || note.chroma, {\n sharps: note.alt > 0,\n pitchClass: note.midi === null,\n });\n};\n/**\n * Get enharmonic of a note\n *\n * @function\n * @param {string} note\n * @param [string] - [optional] Destination pitch class\n * @return {string} the enharmonic note name or '' if not valid note\n * @example\n * Note.enharmonic(\"Db\") // => \"C#\"\n * Note.enharmonic(\"C\") // => \"C\"\n * Note.enharmonic(\"F2\",\"E#\") // => \"E#2\"\n */\nexport function enharmonic(noteName: string, destName?: string) {\n const src = get(noteName);\n if (src.empty) {\n return \"\";\n }\n\n // destination: use given or generate one\n const dest = get(\n destName ||\n midiToNoteName(src.midi || src.chroma, {\n sharps: src.alt < 0,\n pitchClass: true,\n }),\n );\n\n // ensure destination is valid\n if (dest.empty || dest.chroma !== src.chroma) {\n return \"\";\n }\n\n // if src has no octave, no need to calculate anything else\n if (src.oct === undefined) {\n return dest.pc;\n }\n\n // detect any octave overflow\n const srcChroma = src.chroma - src.alt;\n const destChroma = dest.chroma - dest.alt;\n const destOctOffset =\n srcChroma > 11 || destChroma < 0\n ? -1\n : srcChroma < 0 || destChroma > 11\n ? +1\n : 0;\n // calculate the new octave\n const destOct = src.oct + destOctOffset;\n return dest.pc + destOct;\n}\n\nexport default {\n names,\n get,\n name,\n pitchClass,\n accidentals,\n octave,\n midi,\n ascending,\n descending,\n sortedNames,\n sortedUniqNames,\n fromMidi,\n fromMidiSharps,\n freq,\n fromFreq,\n fromFreqSharps,\n chroma,\n transpose,\n tr,\n transposeBy,\n trBy,\n transposeFrom,\n trFrom,\n transposeFifths,\n transposeOctaves,\n trFifths,\n simplify,\n enharmonic,\n};\n", "import {\n accToAlt,\n altToAcc,\n deprecate,\n interval,\n isNamed,\n isPitch,\n Pitch,\n} from \"@tonaljs/core\";\n\nexport interface RomanNumeral extends Pitch {\n readonly name: string;\n readonly empty: boolean;\n readonly roman: string;\n readonly interval: string;\n readonly acc: string;\n readonly chordType: string;\n readonly major: boolean;\n readonly dir: 1;\n}\n\nexport interface NoRomanNumeral extends Partial {\n readonly empty: true;\n readonly name: \"\";\n readonly chordType: \"\";\n}\nconst NoRomanNumeral: NoRomanNumeral = { empty: true, name: \"\", chordType: \"\" };\n\nconst cache: Record = {};\n\n/**\n * Get properties of a roman numeral string\n *\n * @function\n * @param {string} - the roman numeral string (can have type, like: Imaj7)\n * @return {Object} - the roman numeral properties\n * @param {string} name - the roman numeral (tonic)\n * @param {string} type - the chord type\n * @param {string} num - the number (1 = I, 2 = II...)\n * @param {boolean} major - major or not\n *\n * @example\n * romanNumeral(\"VIIb5\") // => { name: \"VII\", type: \"b5\", num: 7, major: true }\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function get(src: any): RomanNumeral | NoRomanNumeral {\n return typeof src === \"string\"\n ? cache[src] || (cache[src] = parse(src))\n : typeof src === \"number\"\n ? get(NAMES[src] || \"\")\n : isPitch(src)\n ? fromPitch(src)\n : isNamed(src)\n ? get(src.name)\n : NoRomanNumeral;\n}\n\nconst romanNumeral = deprecate(\n \"RomanNumeral.romanNumeral\",\n \"RomanNumeral.get\",\n get,\n);\n\n/**\n * Get roman numeral names\n *\n * @function\n * @param {boolean} [isMajor=true]\n * @return {Array}\n *\n * @example\n * names() // => [\"I\", \"II\", \"III\", \"IV\", \"V\", \"VI\", \"VII\"]\n */\nexport function names(major = true) {\n return (major ? NAMES : NAMES_MINOR).slice();\n}\n\nfunction fromPitch(pitch: Pitch): RomanNumeral | NoRomanNumeral {\n return get(altToAcc(pitch.alt) + NAMES[pitch.step]);\n}\n\nconst REGEX =\n /^(#{1,}|b{1,}|x{1,}|)(IV|I{1,3}|VI{0,2}|iv|i{1,3}|vi{0,2})([^IViv]*)$/;\n\n// [name, accidentals, romanNumeral, chordType]\ntype RomanNumeralTokens = [string, string, string, string];\nexport function tokenize(str: string): RomanNumeralTokens {\n return (REGEX.exec(str) || [\"\", \"\", \"\", \"\"]) as RomanNumeralTokens;\n}\n\nconst ROMANS = \"I II III IV V VI VII\";\nconst NAMES = ROMANS.split(\" \");\nconst NAMES_MINOR = ROMANS.toLowerCase().split(\" \");\n\nfunction parse(src: string): RomanNumeral | NoRomanNumeral {\n const [name, acc, roman, chordType] = tokenize(src);\n if (!roman) {\n return NoRomanNumeral;\n }\n\n const upperRoman = roman.toUpperCase();\n const step = NAMES.indexOf(upperRoman);\n const alt = accToAlt(acc);\n const dir = 1;\n return {\n empty: false,\n name,\n roman,\n interval: interval({ step, alt, dir }).name,\n acc,\n chordType,\n alt,\n step,\n major: roman === upperRoman,\n oct: 0,\n dir,\n };\n}\n\nexport default {\n names,\n get,\n // deprecated\n romanNumeral,\n};\n", "import { accToAlt, altToAcc, note, transpose } from \"@tonaljs/core\";\nimport { transposeFifths } from \"@tonaljs/note\";\nimport { get as roman } from \"@tonaljs/roman-numeral\";\n\nconst Empty: readonly string[] = Object.freeze([] as string[]);\n\nexport interface Key {\n readonly type: \"major\" | \"minor\";\n readonly tonic: string;\n readonly alteration: number;\n readonly keySignature: string;\n}\n\nconst NoKey: Key = {\n type: \"major\",\n tonic: \"\",\n alteration: 0,\n keySignature: \"\",\n};\n\nexport interface KeyScale {\n readonly tonic: string;\n readonly grades: readonly string[];\n readonly intervals: readonly string[];\n readonly scale: readonly string[];\n readonly triads: readonly string[];\n readonly chords: readonly string[];\n readonly chordsHarmonicFunction: readonly string[];\n readonly chordScales: readonly string[];\n}\n\nconst NoKeyScale: KeyScale = {\n tonic: \"\",\n grades: Empty,\n intervals: Empty,\n scale: Empty,\n triads: Empty,\n chords: Empty,\n chordsHarmonicFunction: Empty,\n chordScales: Empty,\n};\n\nexport interface MajorKey extends Key, KeyScale {\n readonly type: \"major\";\n readonly minorRelative: string;\n readonly scale: readonly string[];\n readonly secondaryDominants: readonly string[];\n readonly secondaryDominantsMinorRelative: readonly string[];\n readonly substituteDominants: readonly string[];\n readonly substituteDominantsMinorRelative: readonly string[];\n}\n\nconst NoMajorKey: MajorKey = {\n ...NoKey,\n ...NoKeyScale,\n type: \"major\",\n minorRelative: \"\",\n scale: Empty,\n secondaryDominants: Empty,\n secondaryDominantsMinorRelative: Empty,\n substituteDominants: Empty,\n substituteDominantsMinorRelative: Empty,\n};\n\nexport interface MinorKey extends Key {\n readonly type: \"minor\";\n readonly relativeMajor: string;\n readonly natural: KeyScale;\n readonly harmonic: KeyScale;\n readonly melodic: KeyScale;\n}\n\nconst NoMinorKey: MinorKey = {\n ...NoKey,\n type: \"minor\",\n relativeMajor: \"\",\n natural: NoKeyScale,\n harmonic: NoKeyScale,\n melodic: NoKeyScale,\n};\n\nconst mapScaleToType = (scale: string[], list: string[], sep = \"\") =>\n list.map((type, i) => `${scale[i]}${sep}${type}`);\n\nfunction keyScale(\n grades: string[],\n triads: string[],\n chords: string[],\n harmonicFunctions: string[],\n chordScales: string[],\n) {\n return (tonic: string): KeyScale => {\n const intervals = grades.map((gr) => roman(gr).interval || \"\");\n const scale = intervals.map((interval) => transpose(tonic, interval));\n\n return {\n tonic,\n grades,\n intervals,\n scale,\n triads: mapScaleToType(scale, triads),\n chords: mapScaleToType(scale, chords),\n chordsHarmonicFunction: harmonicFunctions.slice(),\n chordScales: mapScaleToType(scale, chordScales, \" \"),\n };\n };\n}\n\nconst distInFifths = (from: string, to: string) => {\n const f = note(from);\n const t = note(to);\n return f.empty || t.empty ? 0 : t.coord[0] - f.coord[0];\n};\n\nconst MajorScale = keyScale(\n \"I II III IV V VI VII\".split(\" \"),\n \" m m m dim\".split(\" \"),\n \"maj7 m7 m7 maj7 7 m7 m7b5\".split(\" \"),\n \"T SD T SD D T D\".split(\" \"),\n \"major,dorian,phrygian,lydian,mixolydian,minor,locrian\".split(\",\"),\n);\nconst NaturalScale = keyScale(\n \"I II bIII IV V bVI bVII\".split(\" \"),\n \"m dim m m \".split(\" \"),\n \"m7 m7b5 maj7 m7 m7 maj7 7\".split(\" \"),\n \"T SD T SD D SD SD\".split(\" \"),\n \"minor,locrian,major,dorian,phrygian,lydian,mixolydian\".split(\",\"),\n);\nconst HarmonicScale = keyScale(\n \"I II bIII IV V bVI VII\".split(\" \"),\n \"m dim aug m dim\".split(\" \"),\n \"mMaj7 m7b5 +maj7 m7 7 maj7 o7\".split(\" \"),\n \"T SD T SD D SD D\".split(\" \"),\n \"harmonic minor,locrian 6,major augmented,lydian diminished,phrygian dominant,lydian #9,ultralocrian\".split(\n \",\",\n ),\n);\nconst MelodicScale = keyScale(\n \"I II bIII IV V VI VII\".split(\" \"),\n \"m m aug dim dim\".split(\" \"),\n \"m6 m7 +maj7 7 7 m7b5 m7b5\".split(\" \"),\n \"T SD T SD D \".split(\" \"),\n \"melodic minor,dorian b2,lydian augmented,lydian dominant,mixolydian b6,locrian #2,altered\".split(\n \",\",\n ),\n);\n\n/**\n * Get a major key properties in a given tonic\n * @param tonic\n */\nexport function majorKey(tonic: string): MajorKey {\n const pc = note(tonic).pc;\n if (!pc) return NoMajorKey;\n\n const keyScale = MajorScale(pc);\n const alteration = distInFifths(\"C\", pc);\n const romanInTonic = (src: string) => {\n const r = roman(src);\n if (r.empty) return \"\";\n\n return transpose(tonic, r.interval) + r.chordType;\n };\n\n return {\n ...keyScale,\n type: \"major\",\n minorRelative: transpose(pc, \"-3m\"),\n alteration,\n keySignature: altToAcc(alteration),\n secondaryDominants: \"- VI7 VII7 I7 II7 III7 -\".split(\" \").map(romanInTonic),\n secondaryDominantsMinorRelative: \"- IIIm7b5 IV#m7 Vm7 VIm7 VIIm7b5 -\"\n .split(\" \")\n .map(romanInTonic),\n substituteDominants: \"- bIII7 IV7 bV7 bVI7 bVII7 -\"\n .split(\" \")\n .map(romanInTonic),\n substituteDominantsMinorRelative: \"- IIIm7 Im7 IIbm7 VIm7 IVm7 -\"\n .split(\" \")\n .map(romanInTonic),\n };\n}\n\n/**\n * Get minor key properties in a given tonic\n * @param tonic\n */\nexport function minorKey(tnc: string): MinorKey {\n const pc = note(tnc).pc;\n if (!pc) return NoMinorKey;\n\n const alteration = distInFifths(\"C\", pc) - 3;\n return {\n type: \"minor\",\n tonic: pc,\n relativeMajor: transpose(pc, \"3m\"),\n alteration,\n keySignature: altToAcc(alteration),\n natural: NaturalScale(pc),\n harmonic: HarmonicScale(pc),\n melodic: MelodicScale(pc),\n };\n}\n\n/**\n * Given a key signature, returns the tonic of the major key\n * @param sigature\n * @example\n * majorTonicFromKeySignature('###') // => 'A'\n */\nexport function majorTonicFromKeySignature(\n sig: string | number,\n): string | null {\n if (typeof sig === \"number\") {\n return transposeFifths(\"C\", sig);\n } else if (typeof sig === \"string\" && /^b+|#+$/.test(sig)) {\n return transposeFifths(\"C\", accToAlt(sig));\n }\n return null;\n}\n\nexport default { majorKey, majorTonicFromKeySignature, minorKey };\n", "import { rotate } from \"@tonaljs/collection\";\nimport { deprecate, NamedPitch, NoteName, transpose } from \"@tonaljs/core\";\nimport { simplify, transposeFifths } from \"@tonaljs/interval\";\nimport { EmptyPcset, Pcset } from \"@tonaljs/pcset\";\nimport { get as getType } from \"@tonaljs/scale-type\";\n\nconst MODES = [\n [0, 2773, 0, \"ionian\", \"\", \"Maj7\", \"major\"],\n [1, 2902, 2, \"dorian\", \"m\", \"m7\"],\n [2, 3418, 4, \"phrygian\", \"m\", \"m7\"],\n [3, 2741, -1, \"lydian\", \"\", \"Maj7\"],\n [4, 2774, 1, \"mixolydian\", \"\", \"7\"],\n [5, 2906, 3, \"aeolian\", \"m\", \"m7\", \"minor\"],\n [6, 3434, 5, \"locrian\", \"dim\", \"m7b5\"],\n] as const;\n\ntype ModeDatum = (typeof MODES)[number];\n\nexport interface Mode extends Pcset {\n readonly name: string;\n readonly modeNum: number;\n readonly alt: number; // number of alterations === number of fiths\n readonly triad: string;\n readonly seventh: string;\n readonly aliases: string[];\n}\n\nconst NoMode: Mode = {\n ...EmptyPcset,\n name: \"\",\n alt: 0,\n modeNum: NaN,\n triad: \"\",\n seventh: \"\",\n aliases: [],\n};\n\nconst modes: Mode[] = MODES.map(toMode);\nconst index: Record = {};\nmodes.forEach((mode) => {\n index[mode.name] = mode;\n mode.aliases.forEach((alias) => {\n index[alias] = mode;\n });\n});\n\ntype ModeLiteral = string | NamedPitch;\n\n/**\n * Get a Mode by it's name\n *\n * @example\n * get('dorian')\n * // =>\n * // {\n * // intervals: [ '1P', '2M', '3m', '4P', '5P', '6M', '7m' ],\n * // modeNum: 1,\n * // chroma: '101101010110',\n * // normalized: '101101010110',\n * // name: 'dorian',\n * // setNum: 2902,\n * // alt: 2,\n * // triad: 'm',\n * // seventh: 'm7',\n * // aliases: []\n * // }\n */\nexport function get(name: ModeLiteral): Mode {\n return typeof name === \"string\"\n ? index[name.toLowerCase()] || NoMode\n : name && name.name\n ? get(name.name)\n : NoMode;\n}\n\nexport const mode = deprecate(\"Mode.mode\", \"Mode.get\", get);\n\n/**\n * Get a list of all modes\n */\nexport function all() {\n return modes.slice();\n}\nexport const entries = deprecate(\"Mode.mode\", \"Mode.all\", all);\n\n/**\n * Get a list of all mode names\n */\nexport function names() {\n return modes.map((mode) => mode.name);\n}\n\nfunction toMode(mode: ModeDatum): Mode {\n const [modeNum, setNum, alt, name, triad, seventh, alias] = mode;\n const aliases = alias ? [alias] : [];\n const chroma = Number(setNum).toString(2);\n const intervals = getType(name).intervals;\n return {\n empty: false,\n intervals,\n modeNum,\n chroma,\n normalized: chroma,\n name,\n setNum,\n alt,\n triad,\n seventh,\n aliases,\n };\n}\n\nexport function notes(modeName: ModeLiteral, tonic: NoteName) {\n return get(modeName).intervals.map((ivl) => transpose(tonic, ivl));\n}\n\nfunction chords(chords: string[]) {\n return (modeName: ModeLiteral, tonic: NoteName) => {\n const mode = get(modeName);\n if (mode.empty) return [];\n const triads = rotate(mode.modeNum, chords);\n const tonics = mode.intervals.map((i) => transpose(tonic, i));\n return triads.map((triad, i) => tonics[i] + triad);\n };\n}\n\nexport const triads = chords(MODES.map((x) => x[4]));\nexport const seventhChords = chords(MODES.map((x) => x[5]));\n\nexport function distance(destination: ModeLiteral, source: ModeLiteral) {\n const from = get(source);\n const to = get(destination);\n if (from.empty || to.empty) return \"\";\n return simplify(transposeFifths(\"1P\", to.alt - from.alt));\n}\n\nexport function relativeTonic(\n destination: ModeLiteral,\n source: ModeLiteral,\n tonic: NoteName,\n) {\n return transpose(tonic, distance(destination, source));\n}\n\nexport default {\n get,\n names,\n all,\n distance,\n relativeTonic,\n notes,\n triads,\n seventhChords,\n // deprecated\n entries,\n mode,\n};\n", "import { tokenize } from \"@tonaljs/chord\";\nimport { distance, interval, NoteLiteral, transpose } from \"@tonaljs/core\";\nimport { get as romanNumeral } from \"@tonaljs/roman-numeral\";\n\n/**\n * Given a tonic and a chord list expressed with roman numeral notation\n * returns the progression expressed with leadsheet chords symbols notation\n * @example\n * fromRomanNumerals(\"C\", [\"I\", \"IIm7\", \"V7\"]);\n * // => [\"C\", \"Dm7\", \"G7\"]\n */\nexport function fromRomanNumerals(\n tonic: NoteLiteral,\n chords: string[],\n): string[] {\n const romanNumerals = chords.map(romanNumeral);\n return romanNumerals.map(\n (rn) => transpose(tonic, interval(rn)) + rn.chordType,\n );\n}\n\n/**\n * Given a tonic and a chord list with leadsheet symbols notation,\n * return the chord list with roman numeral notation\n * @example\n * toRomanNumerals(\"C\", [\"CMaj7\", \"Dm7\", \"G7\"]);\n * // => [\"IMaj7\", \"IIm7\", \"V7\"]\n */\nexport function toRomanNumerals(\n tonic: NoteLiteral,\n chords: string[],\n): string[] {\n return chords.map((chord) => {\n const [note, chordType] = tokenize(chord);\n const intervalName = distance(tonic, note);\n const roman = romanNumeral(interval(intervalName));\n return roman.name + chordType;\n });\n}\n\nexport default { fromRomanNumerals, toRomanNumerals };\n", "import { compact, range } from \"@tonaljs/collection\";\nimport { midiToNoteName, toMidi, ToNoteNameOptions } from \"@tonaljs/midi\";\n\n/**\n * Create a numeric range. You supply a list of notes or numbers and it will\n * be connected to create complex ranges.\n *\n * @param {Array} notes - the list of notes or midi numbers used\n * @return {Array} an array of numbers or empty array if not valid parameters\n *\n * @example\n * numeric([\"C5\", \"C4\"]) // => [ 72, 71, 70, 69, 68, 67, 66, 65, 64, 63, 62, 61, 60 ]\n * // it works midi notes\n * numeric([10, 5]) // => [ 10, 9, 8, 7, 6, 5 ]\n * // complex range\n * numeric([\"C4\", \"E4\", \"Bb3\"]) // => [60, 61, 62, 63, 64, 63, 62, 61, 60, 59, 58]\n */\nexport function numeric(notes: (string | number)[]): number[] {\n const midi: number[] = compact(\n notes.map((note) => (typeof note === \"number\" ? note : toMidi(note))),\n );\n if (!notes.length || midi.length !== notes.length) {\n // there is no valid notes\n return [];\n }\n\n return midi.reduce(\n (result, note) => {\n const last: number = result[result.length - 1];\n return result.concat(range(last, note).slice(1));\n },\n [midi[0]],\n );\n}\n\n/**\n * Create a range of chromatic notes. The altered notes will use flats.\n *\n * @function\n * @param {Array} notes - the list of notes or midi note numbers to create a range from\n * @param {Object} options - The same as `midiToNoteName` (`{ sharps: boolean, pitchClass: boolean }`)\n * @return {Array} an array of note names\n *\n * @example\n * Range.chromatic([\"C2, \"E2\", \"D2\"]) // => [\"C2\", \"Db2\", \"D2\", \"Eb2\", \"E2\", \"Eb2\", \"D2\"]\n * // with sharps\n * Range.chromatic([\"C2\", \"C3\"], { sharps: true }) // => [ \"C2\", \"C#2\", \"D2\", \"D#2\", \"E2\", \"F2\", \"F#2\", \"G2\", \"G#2\", \"A2\", \"A#2\", \"B2\", \"C3\" ]\n */\nexport function chromatic(\n notes: (string | number)[],\n options?: ToNoteNameOptions,\n): string[] {\n return numeric(notes).map((midi) => midiToNoteName(midi, options));\n}\n\nexport default { numeric, chromatic };\n", "/**\n * References:\n * - https://www.researchgate.net/publication/327567188_An_Algorithm_for_Spelling_the_Pitches_of_Any_Musical_Scale\n * @module scale\n */\nimport { all as chordTypes } from \"@tonaljs/chord-type\";\nimport { range as nums, rotate } from \"@tonaljs/collection\";\nimport {\n deprecate,\n note,\n NoteName,\n tonicIntervalsTransposer,\n transpose,\n} from \"@tonaljs/core\";\nimport { enharmonic, fromMidi, sortedUniqNames } from \"@tonaljs/note\";\nimport {\n chroma,\n isChroma,\n isSubsetOf,\n isSupersetOf,\n modes,\n} from \"@tonaljs/pcset\";\nimport {\n all,\n all as scaleTypes,\n get as getScaleType,\n names as scaleTypeNames,\n ScaleType,\n} from \"@tonaljs/scale-type\";\n\ntype ScaleName = string;\ntype ScaleNameTokens = [string, string]; // [TONIC, SCALE TYPE]\n\nexport interface Scale extends ScaleType {\n tonic: string | null;\n type: string;\n notes: NoteName[];\n}\n\nconst NoScale: Scale = {\n empty: true,\n name: \"\",\n type: \"\",\n tonic: null,\n setNum: NaN,\n chroma: \"\",\n normalized: \"\",\n aliases: [],\n notes: [],\n intervals: [],\n};\n\n/**\n * Given a string with a scale name and (optionally) a tonic, split\n * that components.\n *\n * It retuns an array with the form [ name, tonic ] where tonic can be a\n * note name or null and name can be any arbitrary string\n * (this function doesn\"t check if that scale name exists)\n *\n * @function\n * @param {string} name - the scale name\n * @return {Array} an array [tonic, name]\n * @example\n * tokenize(\"C mixolydean\") // => [\"C\", \"mixolydean\"]\n * tokenize(\"anything is valid\") // => [\"\", \"anything is valid\"]\n * tokenize() // => [\"\", \"\"]\n */\nexport function tokenize(name: ScaleName): ScaleNameTokens {\n if (typeof name !== \"string\") {\n return [\"\", \"\"];\n }\n const i = name.indexOf(\" \");\n const tonic = note(name.substring(0, i));\n if (tonic.empty) {\n const n = note(name);\n return n.empty ? [\"\", name] : [n.name, \"\"];\n }\n\n const type = name.substring(tonic.name.length + 1);\n return [tonic.name, type.length ? type : \"\"];\n}\n\n/**\n * Get all scale names\n * @function\n */\nexport const names = scaleTypeNames;\n\n/**\n * Get a Scale from a scale name.\n */\nexport function get(src: ScaleName | ScaleNameTokens): Scale {\n const tokens = Array.isArray(src) ? src : tokenize(src);\n const tonic = note(tokens[0]).name;\n const st = getScaleType(tokens[1]);\n if (st.empty) {\n return NoScale;\n }\n\n const type = st.name;\n const notes: string[] = tonic\n ? st.intervals.map((i) => transpose(tonic, i))\n : [];\n\n const name = tonic ? tonic + \" \" + type : type;\n\n return { ...st, name, type, tonic, notes };\n}\n\nexport const scale = deprecate(\"Scale.scale\", \"Scale.get\", get);\n\nexport function detect(\n notes: string[],\n options: { tonic?: string; match?: \"exact\" | \"fit\" } = {},\n): string[] {\n const notesChroma = chroma(notes);\n const tonic = note(options.tonic ?? notes[0] ?? \"\");\n const tonicChroma = tonic.chroma;\n if (tonicChroma === undefined) {\n return [];\n }\n\n const pitchClasses = notesChroma.split(\"\");\n pitchClasses[tonicChroma] = \"1\";\n const scaleChroma = rotate(tonicChroma, pitchClasses).join(\"\");\n const match = all().find((scaleType) => scaleType.chroma === scaleChroma);\n\n const results: string[] = [];\n if (match) {\n results.push(tonic.name + \" \" + match.name);\n }\n if (options.match === \"exact\") {\n return results;\n }\n\n extended(scaleChroma).forEach((scaleName) => {\n results.push(tonic.name + \" \" + scaleName);\n });\n\n return results;\n}\n\n/**\n * Get all chords that fits a given scale\n *\n * @function\n * @param {string} name - the scale name\n * @return {Array} - the chord names\n *\n * @example\n * scaleChords(\"pentatonic\") // => [\"5\", \"64\", \"M\", \"M6\", \"Madd9\", \"Msus2\"]\n */\nexport function scaleChords(name: string): string[] {\n const s = get(name);\n const inScale = isSubsetOf(s.chroma);\n return chordTypes()\n .filter((chord) => inScale(chord.chroma))\n .map((chord) => chord.aliases[0]);\n}\n/**\n * Get all scales names that are a superset of the given one\n * (has the same notes and at least one more)\n *\n * @function\n * @param {string} name\n * @return {Array} a list of scale names\n * @example\n * extended(\"major\") // => [\"bebop\", \"bebop dominant\", \"bebop major\", \"chromatic\", \"ichikosucho\"]\n */\nexport function extended(name: string): string[] {\n const chroma = isChroma(name) ? name : get(name).chroma;\n const isSuperset = isSupersetOf(chroma);\n return scaleTypes()\n .filter((scale) => isSuperset(scale.chroma))\n .map((scale) => scale.name);\n}\n\n/**\n * Find all scales names that are a subset of the given one\n * (has less notes but all from the given scale)\n *\n * @function\n * @param {string} name\n * @return {Array} a list of scale names\n *\n * @example\n * reduced(\"major\") // => [\"ionian pentatonic\", \"major pentatonic\", \"ritusen\"]\n */\nexport function reduced(name: string): string[] {\n const isSubset = isSubsetOf(get(name).chroma);\n return scaleTypes()\n .filter((scale) => isSubset(scale.chroma))\n .map((scale) => scale.name);\n}\n\n/**\n * Given an array of notes, return the scale: a pitch class set starting from\n * the first note of the array\n *\n * @function\n * @param {string[]} notes\n * @return {string[]} pitch classes with same tonic\n * @example\n * scaleNotes(['C4', 'c3', 'C5', 'C4', 'c4']) // => [\"C\"]\n * scaleNotes(['D4', 'c#5', 'A5', 'F#6']) // => [\"D\", \"F#\", \"A\", \"C#\"]\n */\nexport function scaleNotes(notes: NoteName[]) {\n const pcset: string[] = notes.map((n) => note(n).pc).filter((x) => x);\n const tonic = pcset[0];\n const scale = sortedUniqNames(pcset);\n return rotate(scale.indexOf(tonic), scale);\n}\n\ntype ScaleMode = [string, string];\n/**\n * Find mode names of a scale\n *\n * @function\n * @param {string} name - scale name\n * @example\n * modeNames(\"C pentatonic\") // => [\n * [\"C\", \"major pentatonic\"],\n * [\"D\", \"egyptian\"],\n * [\"E\", \"malkos raga\"],\n * [\"G\", \"ritusen\"],\n * [\"A\", \"minor pentatonic\"]\n * ]\n */\nexport function modeNames(name: string): ScaleMode[] {\n const s = get(name);\n if (s.empty) {\n return [];\n }\n\n const tonics = s.tonic ? s.notes : s.intervals;\n return modes(s.chroma)\n .map((chroma: string, i: number): ScaleMode => {\n const modeName = get(chroma).name;\n return modeName ? [tonics[i], modeName] : [\"\", \"\"];\n })\n .filter((x) => x[0]);\n}\n\nfunction getNoteNameOf(scale: string | string[]) {\n const names = Array.isArray(scale) ? scaleNotes(scale) : get(scale).notes;\n const chromas = names.map((name) => note(name).chroma);\n\n return (noteOrMidi: string | number): string | undefined => {\n const currNote =\n typeof noteOrMidi === \"number\"\n ? note(fromMidi(noteOrMidi))\n : note(noteOrMidi);\n const height = currNote.height;\n\n if (height === undefined) return undefined;\n const chroma = height % 12;\n const position = chromas.indexOf(chroma);\n if (position === -1) return undefined;\n return enharmonic(currNote.name, names[position]);\n };\n}\n\nexport function rangeOf(scale: string | string[]) {\n const getName = getNoteNameOf(scale);\n return (fromNote: string, toNote: string) => {\n const from = note(fromNote).height;\n const to = note(toNote).height;\n if (from === undefined || to === undefined) return [];\n\n return nums(from, to)\n .map(getName)\n .filter((x) => x);\n };\n}\n\n/**\n * Returns a function to get a note name from the scale degree.\n *\n * @example\n * [1, 2, 3].map(Scale.degrees(\"C major\")) => [\"C\", \"D\", \"E\"]\n * [1, 2, 3].map(Scale.degrees(\"C4 major\")) => [\"C4\", \"D4\", \"E4\"]\n */\nexport function degrees(scaleName: string | ScaleNameTokens) {\n const { intervals, tonic } = get(scaleName);\n const transpose = tonicIntervalsTransposer(intervals, tonic);\n return (degree: number) =>\n degree ? transpose(degree > 0 ? degree - 1 : degree) : \"\";\n}\n\n/**\n * Sames as `degree` but with 0-based index\n */\nexport function steps(scaleName: string | ScaleNameTokens) {\n const { intervals, tonic } = get(scaleName);\n return tonicIntervalsTransposer(intervals, tonic);\n}\n\nexport default {\n degrees,\n detect,\n extended,\n get,\n modeNames,\n names,\n rangeOf,\n reduced,\n scaleChords,\n scaleNotes,\n steps,\n tokenize,\n\n // deprecated\n scale,\n};\n", "// TYPES: PARSING\nexport type TimeSignatureLiteral = string | [number, number] | [string, string];\ntype ParsedTimeSignature = [number | number[], number];\n\n// TYPES: PROPERTIES\nexport type ValidTimeSignature = {\n readonly empty: false;\n readonly name: string;\n readonly upper: number | number[];\n readonly lower: number;\n readonly type: \"simple\" | \"compound\" | \"irregular\" | \"irrational\";\n readonly additive: number[];\n};\n\nexport type InvalidTimeSignature = {\n readonly empty: true;\n readonly name: \"\";\n readonly upper: undefined;\n readonly lower: undefined;\n readonly type: undefined;\n readonly additive: [];\n};\n\nexport type TimeSignature = ValidTimeSignature | InvalidTimeSignature;\n\n// CONSTANTS\nconst NONE: InvalidTimeSignature = {\n empty: true,\n name: \"\",\n upper: undefined,\n lower: undefined,\n type: undefined,\n additive: [],\n};\n\nconst NAMES = [\"4/4\", \"3/4\", \"2/4\", \"2/2\", \"12/8\", \"9/8\", \"6/8\", \"3/8\"];\n\n// PUBLIC API\n\nexport function names() {\n return NAMES.slice();\n}\n\nconst REGEX = /^(\\d*\\d(?:\\+\\d)*)\\/(\\d+)$/;\nconst CACHE = new Map();\n\nexport function get(literal: TimeSignatureLiteral): TimeSignature {\n const stringifiedLiteral = JSON.stringify(literal);\n const cached = CACHE.get(stringifiedLiteral);\n if (cached) {\n return cached;\n }\n\n const ts = build(parse(literal));\n CACHE.set(stringifiedLiteral, ts);\n return ts;\n}\n\nexport function parse(literal: TimeSignatureLiteral): ParsedTimeSignature {\n if (typeof literal === \"string\") {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const [_, up, low] = REGEX.exec(literal) || [];\n return parse([up, low]);\n }\n\n const [up, down] = literal;\n const denominator = +down;\n if (typeof up === \"number\") {\n return [up, denominator];\n }\n\n const list = up.split(\"+\").map((n) => +n);\n return list.length === 1 ? [list[0], denominator] : [list, denominator];\n}\n\nexport default { names, parse, get };\n\n// PRIVATE\n\nconst isPowerOfTwo = (x: number) => (Math.log(x) / Math.log(2)) % 1 === 0;\n\nfunction build([up, down]: ParsedTimeSignature): TimeSignature {\n const upper = Array.isArray(up) ? up.reduce((a, b) => a + b, 0) : up;\n const lower = down;\n if (upper === 0 || lower === 0) {\n return NONE;\n }\n\n const name = Array.isArray(up) ? `${up.join(\"+\")}/${down}` : `${up}/${down}`;\n const additive = Array.isArray(up) ? up : [];\n const type =\n lower === 4 || lower === 2\n ? \"simple\"\n : lower === 8 && upper % 3 === 0\n ? \"compound\"\n : isPowerOfTwo(lower)\n ? \"irregular\"\n : \"irrational\";\n\n return {\n empty: false,\n name,\n type,\n upper,\n lower,\n additive,\n };\n}\n", "import Note from \"@tonaljs/note\";\n\n// A function that decides which of a set of voicings is picked as a follow up to lastVoicing.\nexport declare type VoiceLeadingFunction = (\n voicings: string[][],\n lastVoicing: string[],\n) => string[];\n\nexport const topNoteDiff: VoiceLeadingFunction = (voicings, lastVoicing) => {\n if (!lastVoicing || !lastVoicing.length) {\n return voicings[0];\n }\n const topNoteMidi = (voicing: string[]) =>\n Note.midi(voicing[voicing.length - 1]) || 0;\n const diff = (voicing: string[]) =>\n Math.abs(topNoteMidi(lastVoicing) - topNoteMidi(voicing));\n return voicings.sort((a, b) => diff(a) - diff(b))[0];\n};\n\nexport default {\n topNoteDiff,\n};\n", "import Chord from \"@tonaljs/chord\";\nimport { lefthand, VoicingDictionary, triads, all } from \"./data\";\n\nconst defaultDictionary: VoicingDictionary = lefthand;\n\nfunction lookup(\n symbol: string,\n dictionary = defaultDictionary,\n): string[] | undefined {\n if (dictionary[symbol]) {\n return dictionary[symbol];\n }\n const { aliases } = Chord.get(\"C\" + symbol);\n // TODO: find other way to get aliases of symbol\n const match =\n Object.keys(dictionary).find((_symbol) => aliases.includes(_symbol)) || \"\";\n if (match !== undefined) {\n return dictionary[match];\n }\n return undefined;\n}\n\nexport default {\n lookup,\n lefthand,\n triads,\n all,\n defaultDictionary,\n};\n", "export type VoicingDictionary = { [symbol: string]: string[] };\n\nexport const triads: VoicingDictionary = {\n M: [\"1P 3M 5P\", \"3M 5P 8P\", \"5P 8P 10M\"],\n m: [\"1P 3m 5P\", \"3m 5P 8P\", \"5P 8P 10m\"],\n o: [\"1P 3m 5d\", \"3m 5d 8P\", \"5d 8P 10m\"],\n aug: [\"1P 3m 5A\", \"3m 5A 8P\", \"5A 8P 10m\"],\n};\nexport const lefthand: VoicingDictionary = {\n m7: [\"3m 5P 7m 9M\", \"7m 9M 10m 12P\"],\n \"7\": [\"3M 6M 7m 9M\", \"7m 9M 10M 13M\"],\n \"^7\": [\"3M 5P 7M 9M\", \"7M 9M 10M 12P\"],\n \"69\": [\"3M 5P 6A 9M\"],\n m7b5: [\"3m 5d 7m 8P\", \"7m 8P 10m 12d\"],\n \"7b9\": [\"3M 6m 7m 9m\", \"7m 9m 10M 13m\"], // b9 / b13\n \"7b13\": [\"3M 6m 7m 9m\", \"7m 9m 10M 13m\"], // b9 / b13\n o7: [\"1P 3m 5d 6M\", \"5d 6M 8P 10m\"],\n \"7#11\": [\"7m 9M 11A 13A\"],\n \"7#9\": [\"3M 7m 9A\"],\n mM7: [\"3m 5P 7M 9M\", \"7M 9M 10m 12P\"],\n m6: [\"3m 5P 6M 9M\", \"6M 9M 10m 12P\"],\n};\nexport const all: VoicingDictionary = {\n M: [\"1P 3M 5P\", \"3M 5P 8P\", \"5P 8P 10M\"],\n m: [\"1P 3m 5P\", \"3m 5P 8P\", \"5P 8P 10m\"],\n o: [\"1P 3m 5d\", \"3m 5d 8P\", \"5d 8P 10m\"],\n aug: [\"1P 3m 5A\", \"3m 5A 8P\", \"5A 8P 10m\"],\n m7: [\"3m 5P 7m 9M\", \"7m 9M 10m 12P\"],\n \"7\": [\"3M 6M 7m 9M\", \"7m 9M 10M 13M\"],\n \"^7\": [\"3M 5P 7M 9M\", \"7M 9M 10M 12P\"],\n \"69\": [\"3M 5P 6A 9M\"],\n m7b5: [\"3m 5d 7m 8P\", \"7m 8P 10m 12d\"],\n \"7b9\": [\"3M 6m 7m 9m\", \"7m 9m 10M 13m\"], // b9 / b13\n \"7b13\": [\"3M 6m 7m 9m\", \"7m 9m 10M 13m\"], // b9 / b13\n o7: [\"1P 3m 5d 6M\", \"5d 6M 8P 10m\"],\n \"7#11\": [\"7m 9M 11A 13A\"],\n \"7#9\": [\"3M 7m 9A\"],\n mM7: [\"3m 5P 7M 9M\", \"7M 9M 10m 12P\"],\n m6: [\"3m 5P 6M 9M\", \"6M 9M 10m 12P\"],\n};\n", "import Chord from \"@tonaljs/chord\";\nimport Interval from \"@tonaljs/interval\";\nimport Note from \"@tonaljs/note\";\nimport Range from \"@tonaljs/range\";\nimport VoiceLeading from \"@tonaljs/voice-leading\";\nimport VoicingDictionary from \"@tonaljs/voicing-dictionary\";\n\nconst defaultRange = [\"C3\", \"C5\"];\nconst defaultDictionary = VoicingDictionary.all;\nconst defaultVoiceLeading = VoiceLeading.topNoteDiff;\n\nfunction get(\n chord: string,\n range: string[] = defaultRange,\n dictionary = defaultDictionary,\n voiceLeading = defaultVoiceLeading,\n lastVoicing?: string[],\n) {\n const voicings = search(chord, range, dictionary);\n if (!lastVoicing || !lastVoicing.length) {\n // notes = voicings[Math.ceil(voicings.length / 2)]; // pick middle voicing..\n return voicings[0]; // pick lowest voicing..\n } else {\n // calculates the distance between the last note and the given voicings top note\n // sort voicings with differ\n return voiceLeading(voicings, lastVoicing);\n }\n}\n\nfunction search(\n chord: string,\n range = defaultRange,\n dictionary = VoicingDictionary.triads,\n): string[][] {\n const [tonic, symbol] = Chord.tokenize(chord);\n const sets = VoicingDictionary.lookup(symbol, dictionary);\n // find equivalent symbol that is used as a key in dictionary:\n if (!sets) {\n return [];\n }\n // resolve array of interval arrays for the wanted symbol\n const voicings = sets.map((intervals) => intervals.split(\" \"));\n const notesInRange = Range.chromatic(range); // gives array of notes inside range\n return voicings.reduce((voiced: string[][], voicing: string[]) => {\n // transpose intervals relative to first interval (e.g. 3m 5P > 1P 3M)\n const relativeIntervals = voicing.map(\n (interval) => Interval.subtract(interval, voicing[0]) || \"\",\n );\n // get enharmonic correct pitch class the bottom note\n const bottomPitchClass = Note.transpose(tonic, voicing[0]);\n // get all possible start notes for voicing\n const starts = notesInRange\n // only get the start notes:\n .filter((note) => Note.chroma(note) === Note.chroma(bottomPitchClass))\n // filter out start notes that will overshoot the top end of the range\n .filter(\n (note) =>\n (Note.midi(\n Note.transpose(\n note,\n relativeIntervals[relativeIntervals.length - 1],\n ),\n ) || 0) <= (Note.midi(range[1]) || 0),\n )\n // replace Range.chromatic notes with the correct enharmonic equivalents\n .map((note) => Note.enharmonic(note, bottomPitchClass));\n // render one voicing for each start note\n const notes = starts.map((start) =>\n relativeIntervals.map((interval) => Note.transpose(start, interval)),\n );\n return voiced.concat(notes);\n }, []);\n}\n\nfunction sequence(\n chords: string[],\n range = defaultRange,\n dictionary = defaultDictionary,\n voiceLeading = defaultVoiceLeading,\n lastVoicing?: string[],\n) {\n const { voicings } = chords.reduce<{\n voicings: string[][];\n lastVoicing: string[] | undefined;\n }>(\n ({ voicings, lastVoicing }, chord) => {\n const voicing = get(chord, range, dictionary, voiceLeading, lastVoicing);\n lastVoicing = voicing;\n voicings.push(voicing);\n return { voicings, lastVoicing };\n },\n { voicings: [], lastVoicing },\n );\n return voicings;\n}\n\nexport default {\n get,\n search,\n sequence,\n};\n"], - "mappings": "ucAAA,IAAAA,GAAA,GAAAC,GAAAD,GAAA,iBAAAE,GAAA,UAAAC,GAAA,UAAAC,EAAA,oBAAAC,GAAA,cAAAC,GAAA,eAAAC,GAAA,SAAAJ,GAAA,kBAAAK,GAAA,aAAAC,GAAA,QAAAC,GAAA,SAAAC,GAAA,SAAAC,GAAA,SAAAC,EAAA,UAAAC,GAAA,UAAAC,GAAA,gBAAAC,GAAA,UAAAC,GAAA,iBAAAC,GAAA,UAAAC,GAAA,oBAAAC,GAAA,cAAAC,GAAA,kBAAAC,GAAA,UAAAC,GAAA,iBAAAC,GAAA,YAAAC,GAAA,sBAAAC,EAAA,aAAAC,EAAA,aAAAC,EAAA,WAAAC,GAAA,oBAAAC,EAAA,gBAAAC,GAAA,gBAAAC,EAAA,cAAAC,EAAA,aAAAC,EAAA,YAAAC,GAAA,WAAAC,GAAA,aAAAC,EAAA,YAAAC,GAAA,iBAAAC,EAAA,YAAAC,EAAA,SAAAC,GAAA,SAAAC,EAAA,UAAAC,EAAA,iBAAAC,GAAA,qBAAAC,GAAA,iBAAAC,EAAA,6BAAAC,EAAA,cAAAC,ICcO,SAASC,EAAaC,EAAiC,CAC5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S,OAAO,CAACS,EAAoBC,IAAsB,CAEhE,IAAMC,EAAoBD,EAAQ,IAC/BE,GAAaC,GAAS,SAASD,EAAUF,EAAQ,CAAC,CAAC,GAAK,EAC3D,EAEMI,EAAmBC,EAAK,UAAUb,EAAOQ,EAAQ,CAAC,CAAC,EAkBnDM,EAhBST,EAEZ,OAAQU,GAASF,EAAK,OAAOE,CAAI,IAAMF,EAAK,OAAOD,CAAgB,CAAC,EAEpE,OACEG,IACEF,EAAK,KACJA,EAAK,UACHE,EACAN,EAAkBA,EAAkB,OAAS,CAAC,CAChD,CACF,GAAK,KAAOI,EAAK,KAAKnB,EAAM,CAAC,CAAC,GAAK,EACvC,EAEC,IAAKqB,GAASF,EAAK,WAAWE,EAAMH,CAAgB,CAAC,EAEnC,IAAKI,GACxBP,EAAkB,IAAKC,IAAaG,EAAK,UAAUG,EAAON,EAAQ,CAAC,CACrE,EACA,OAAOH,EAAO,OAAOO,CAAK,CAC5B,EAAG,CAAC,CAAC,CACP,CAEA,SAASG,GACPC,EACAxB,EAAQP,GACRQ,EAAaP,GACbQ,EAAeN,GACfO,EACA,CACA,GAAM,CAAE,SAAAC,CAAS,EAAIoB,EAAO,OAI1B,CAAC,CAAE,SAAApB,EAAU,YAAAD,CAAY,EAAGJ,IAAU,CACpC,IAAMe,EAAUhB,GAAIC,EAAOC,EAAOC,EAAYC,EAAcC,CAAW,EACvEA,OAAAA,EAAcW,EACdV,EAAS,KAAKU,CAAO,EACd,CAAE,SAAAV,EAAU,YAAAD,CAAY,CACjC,EACA,CAAE,SAAU,CAAC,EAAG,YAAAA,CAAY,CAC9B,EACA,OAAOC,CACT,CAEA,IAAOqB,GAAQ,CACb,IAAA3B,GACA,OAAAO,GACA,SAAAkB,EACF,EjC1EA,IAAMG,GAAQC,GACRC,GAAQC,GACRC,GAAkBC,GAClBC,GAAkBC", - "names": ["tonal_exports", "__export", "abc_notation_default", "dist_exports", "chord_default", "ChordDictionary", "chord_type_default", "collection_default", "duration_value_default", "interval_default", "key_default", "midi_default", "mode_default", "note_default", "PcSet", "pcset_default", "progression_default", "range_default", "roman_numeral_default", "scale_default", "ScaleDictionary", "scale_type_default", "time_signature_default", "Tonal", "voice_leading_default", "voicing_default", "voicing_dictionary_default", "accToAlt", "altToAcc", "chroma", "coordToInterval", "coordToNote", "coordinates", "deprecate", "distance", "fillStr", "height", "interval", "isNamed", "isNamedPitch", "isPitch", "midi", "note", "pitch", "stepToLetter", "tokenizeInterval", "tokenizeNote", "tonicIntervalsTransposer", "transpose", "isNamedPitch", "src", "SIZES", "chroma", "step", "alt", "height", "oct", "dir", "midi", "pitch", "h", "isPitch", "FIFTHS", "STEPS_TO_OCTS", "fifths", "coordinates", "f", "o", "FIFTHS_TO_STEPS", "coord", "unaltered", "i", "fillStr", "s", "NoInterval", "INTERVAL_TONAL_REGEX", "INTERVAL_SHORTHAND_REGEX", "REGEX", "tokenizeInterval", "str", "m", "cache", "interval", "src", "parse", "isPitch", "pitchName", "isNamedPitch", "SIZES", "TYPES", "tokens", "num", "q", "step", "t", "type", "name", "dir", "simple", "alt", "qToAlt", "oct", "semitones", "chroma", "coord", "coordinates", "coordToInterval", "forceDescending", "f", "o", "isDescending", "ivl", "pitch", "props", "calcNum", "d", "altToQ", "fillStr", "s", "NoNote", "cache", "stepToLetter", "step", "altToAcc", "alt", "accToAlt", "acc", "note", "src", "stringSrc", "cached", "value", "parse", "isPitch", "pitchName", "isNamedPitch", "REGEX", "tokenizeNote", "str", "m", "coordToNote", "noteCoord", "pitch", "mod", "n", "SEMI", "noteName", "tokens", "letter", "octStr", "oct", "coord", "coordinates", "name", "pc", "chroma", "height", "midi", "freq", "props", "transpose", "noteName", "intervalName", "note", "intervalCoord", "interval", "noteCoord", "tr", "coordToNote", "tonicIntervalsTransposer", "intervals", "tonic", "len", "normalized", "index", "octaves", "root", "distance", "fromNote", "toNote", "from", "to", "fcoord", "tcoord", "fifths", "octs", "forceDescending", "coordToInterval", "fillStr", "s", "NoNote", "cache", "stepToLetter", "step", "altToAcc", "alt", "accToAlt", "acc", "note", "src", "stringSrc", "cached", "value", "parse", "isPitch", "pitchName", "isNamedPitch", "REGEX", "tokenizeNote", "str", "m", "mod", "n", "m", "SEMI", "parse", "noteName", "tokens", "tokenizeNote", "NoNote", "letter", "acc", "octStr", "step", "alt", "accToAlt", "oct", "coord", "coordinates", "name", "pc", "chroma", "height", "midi", "freq", "pitchName", "props", "stepToLetter", "altToAcc", "fillStr", "character", "times", "REGEX", "tokenize", "str", "m", "abcToScientificNotation", "acc", "letter", "oct", "scientificToAbcNotation", "note", "l", "o", "transpose", "interval", "distance", "from", "to", "abc_notation_default", "fillStr", "s", "NoNote", "cache", "stepToLetter", "step", "altToAcc", "alt", "accToAlt", "acc", "note", "src", "stringSrc", "cached", "value", "parse", "isPitch", "pitchName", "isNamedPitch", "REGEX", "tokenizeNote", "str", "m", "mod", "n", "m", "SEMI", "parse", "noteName", "tokens", "tokenizeNote", "NoNote", "letter", "acc", "octStr", "step", "alt", "accToAlt", "oct", "coord", "coordinates", "name", "pc", "chroma", "height", "midi", "freq", "pitchName", "props", "stepToLetter", "altToAcc", "ascR", "b", "a", "descR", "range", "from", "to", "rotate", "times", "arr", "len", "n", "compact", "sortedNoteNames", "notes", "note", "sortedUniqNoteNames", "i", "shuffle", "rnd", "t", "m", "permutations", "acc", "perm", "e", "pos", "newPerm", "fillStr", "s", "deprecate", "original", "alternative", "fn", "args", "isNamed", "isNamedPitch", "ascR", "b", "a", "descR", "range", "from", "to", "rotate", "times", "arr", "len", "n", "compact", "shuffle", "rnd", "i", "t", "m", "permutations", "acc", "perm", "e", "pos", "newPerm", "collection_default", "EmptyPcset", "setNumToChroma", "num", "chromaToNumber", "chroma", "REGEX", "isChroma", "set", "isPcsetNum", "isPcset", "cache", "get", "src", "listToChroma", "chromaToPcset", "pcset", "deprecate", "intervals", "IVLS", "chromaToIntervals", "i", "notes", "ivl", "transpose", "chromas", "range", "modes", "normalize", "binary", "compact", "_", "r", "rotate", "isEqual", "s1", "s2", "isSubsetOf", "s", "o", "isSupersetOf", "isNoteIncludedIn", "noteName", "n", "note", "filter", "set", "isIncluded", "isNoteIncludedIn", "notes", "pcset_default", "get", "chroma", "num", "intervals", "chromas", "isSupersetOf", "isSubsetOf", "isEqual", "modes", "pcset", "chromaRotations", "binary", "_", "i", "rotate", "chromaToPcset", "setNum", "chromaToNumber", "normalizedNum", "n", "normalized", "setNumToChroma", "chromaToIntervals", "listToChroma", "EmptyPcset", "pitch", "note", "interval", "CHORDS", "data_default", "NoChordType", "EmptyPcset", "dictionary", "index", "get", "type", "chordType", "deprecate", "names", "chord", "x", "symbols", "keys", "all", "entries", "removeAll", "add", "intervals", "aliases", "fullName", "quality", "getQuality", "alias", "addAlias", "has", "interval", "ivls", "a", "b", "chord_type_default", "namedSet", "notes", "pcToName", "record", "n", "chroma", "note", "detect", "source", "options", "x", "findMatches", "chord", "a", "b", "BITMASK", "testChromaNumber", "bitmask", "chromaNumber", "hasAnyThird", "hasPerfectFifth", "hasAnySeventh", "hasNonPerfectFifth", "hasAnyThirdAndPerfectFifthAndAnySeventh", "chordType", "withPerfectFifth", "weight", "tonic", "tonicChroma", "noteName", "allModes", "modes", "found", "mode", "index", "modeWithPerfectFifth", "all", "chordName", "baseNote", "names", "get", "interval", "name", "semitones", "quality", "num", "simplify", "i", "invert", "step", "alt", "IN", "IQ", "fromSemitones", "d", "n", "c", "distance", "add", "combinator", "a", "b", "addTo", "other", "subtract", "transposeFifths", "fifths", "ivl", "nFifths", "nOcts", "dir", "coordToInterval", "interval_default", "fn", "coordA", "coordB", "coord", "SCALES", "data_default", "NoScaleType", "EmptyPcset", "dictionary", "index", "names", "scale", "get", "type", "scaleType", "deprecate", "all", "entries", "keys", "removeAll", "add", "intervals", "name", "aliases", "alias", "addAlias", "ivls", "scale_type_default", "NoChord", "tokenize", "name", "letter", "acc", "oct", "type", "tokenizeNote", "tokenizeBass", "note", "chord", "split", "get", "src", "getChord", "tonic", "bass", "typeName", "optionalTonic", "optionalBass", "bassInterval", "distance", "bassIndex", "hasRoot", "root", "rootDegree", "hasBass", "intervals", "i", "num", "quality", "newNum", "ivl", "subtract", "notes", "transpose", "symbol", "chordName", "interval", "tr", "slash", "chordScales", "s", "isChordIncluded", "isSupersetOf", "all", "scale", "extended", "isSuperset", "reduced", "isSubset", "isSubsetOf", "degrees", "tonicIntervalsTransposer", "degree", "steps", "chord_default", "detect", "DATA", "data_default", "VALUES", "denominator", "shorthand", "names", "add", "NoDuration", "duration", "name", "shorthands", "dur", "REGEX", "get", "_", "simple", "dots", "base", "fraction", "calcDots", "value", "duration_value_default", "pow", "numerator", "isMidi", "arg", "toMidi", "note", "midiToFreq", "midi", "tuning", "L2", "L440", "freqToMidi", "freq", "v", "SHARPS", "FLATS", "midiToNoteName", "options", "pc", "chroma", "pcsetFromChroma", "pcset", "val", "index", "pcsetFromMidi", "a", "b", "i", "notes", "pcsetNearest", "set", "ch", "pcsetSteps", "tonic", "len", "step", "octaves", "pcsetDegrees", "steps", "degree", "midi_default", "NAMES", "toName", "n", "onlyNotes", "array", "note", "names", "get", "name", "pitchClass", "accidentals", "octave", "midi", "freq", "chroma", "fromMidi", "midiToNoteName", "fromFreq", "freqToMidi", "fromFreqSharps", "fromMidiSharps", "transpose", "tr", "transposeBy", "interval", "trBy", "transposeFrom", "trFrom", "transposeFifths", "noteName", "fifths", "trFifths", "transposeOctaves", "octaves", "ascending", "a", "b", "descending", "sortedNames", "notes", "comparator", "sortedUniqNames", "i", "simplify", "enharmonic", "destName", "src", "dest", "srcChroma", "destChroma", "destOctOffset", "destOct", "note_default", "NoRomanNumeral", "cache", "get", "src", "parse", "NAMES", "isPitch", "fromPitch", "isNamed", "romanNumeral", "deprecate", "names", "major", "NAMES_MINOR", "pitch", "altToAcc", "REGEX", "tokenize", "str", "ROMANS", "name", "acc", "roman", "chordType", "upperRoman", "step", "alt", "accToAlt", "dir", "interval", "roman_numeral_default", "Empty", "NoKey", "NoKeyScale", "NoMajorKey", "NoMinorKey", "mapScaleToType", "scale", "list", "sep", "type", "i", "keyScale", "grades", "triads", "chords", "harmonicFunctions", "chordScales", "tonic", "intervals", "gr", "get", "interval", "transpose", "distInFifths", "from", "to", "f", "note", "t", "MajorScale", "NaturalScale", "HarmonicScale", "MelodicScale", "majorKey", "pc", "alteration", "romanInTonic", "src", "r", "altToAcc", "minorKey", "tnc", "majorTonicFromKeySignature", "sig", "transposeFifths", "accToAlt", "key_default", "MODES", "NoMode", "EmptyPcset", "modes", "toMode", "index", "mode", "alias", "get", "name", "deprecate", "all", "entries", "names", "modeNum", "setNum", "alt", "triad", "seventh", "aliases", "chroma", "notes", "modeName", "tonic", "ivl", "transpose", "chords", "triads", "rotate", "tonics", "i", "x", "seventhChords", "distance", "destination", "source", "from", "to", "simplify", "transposeFifths", "relativeTonic", "mode_default", "fromRomanNumerals", "tonic", "chords", "get", "rn", "transpose", "interval", "toRomanNumerals", "chord", "note", "chordType", "tokenize", "intervalName", "distance", "progression_default", "numeric", "notes", "midi", "compact", "note", "toMidi", "result", "last", "range", "chromatic", "options", "midiToNoteName", "range_default", "NoScale", "tokenize", "name", "i", "tonic", "note", "n", "type", "names", "get", "src", "tokens", "st", "notes", "transpose", "scale", "deprecate", "detect", "options", "notesChroma", "chroma", "tonicChroma", "pitchClasses", "scaleChroma", "rotate", "match", "all", "scaleType", "results", "extended", "scaleName", "scaleChords", "s", "inScale", "isSubsetOf", "chord", "isChroma", "isSuperset", "isSupersetOf", "reduced", "isSubset", "scaleNotes", "pcset", "x", "sortedUniqNames", "modeNames", "tonics", "modes", "modeName", "getNoteNameOf", "chromas", "noteOrMidi", "currNote", "fromMidi", "height", "position", "enharmonic", "rangeOf", "getName", "fromNote", "toNote", "from", "to", "range", "degrees", "intervals", "tonicIntervalsTransposer", "degree", "steps", "scale_default", "NONE", "NAMES", "names", "REGEX", "CACHE", "get", "literal", "stringifiedLiteral", "cached", "ts", "build", "parse", "_", "up", "low", "down", "denominator", "list", "n", "time_signature_default", "isPowerOfTwo", "x", "upper", "a", "b", "lower", "name", "additive", "type", "topNoteDiff", "voicings", "lastVoicing", "topNoteMidi", "voicing", "note_default", "diff", "a", "b", "voice_leading_default", "triads", "lefthand", "all", "defaultDictionary", "lookup", "symbol", "dictionary", "aliases", "chord_default", "match", "_symbol", "voicing_dictionary_default", "defaultRange", "defaultDictionary", "voicing_dictionary_default", "defaultVoiceLeading", "voice_leading_default", "get", "chord", "range", "dictionary", "voiceLeading", "lastVoicing", "voicings", "search", "tonic", "symbol", "chord_default", "sets", "intervals", "notesInRange", "range_default", "voiced", "voicing", "relativeIntervals", "interval", "interval_default", "bottomPitchClass", "note_default", "notes", "note", "start", "sequence", "chords", "voicing_default", "Tonal", "dist_exports", "PcSet", "pcset_default", "ChordDictionary", "chord_type_default", "ScaleDictionary", "scale_type_default"] + "sources": ["../index.ts", "../../pitch/index.ts", "../../pitch-interval/index.ts", "../../pitch-note/index.ts", "../../pitch-distance/index.ts", "../../abc-notation/index.ts", "../../array/node_modules/@tonaljs/pitch-note/index.ts", "../../array/index.ts", "../../core/index.ts", "../../collection/index.ts", "../../pcset/index.ts", "../../chord-type/index.ts", "../../chord-type/data.ts", "../../chord-detect/index.ts", "../../interval/index.ts", "../../scale-type/index.ts", "../../scale-type/data.ts", "../../chord/index.ts", "../../duration-value/data.ts", "../../duration-value/index.ts", "../../midi/index.ts", "../../note/index.ts", "../../roman-numeral/index.ts", "../../key/index.ts", "../../mode/index.ts", "../../progression/index.ts", "../../range/index.ts", "../../scale/index.ts", "../../time-signature/index.ts", "../../voice-leading/index.ts", "../../voicing-dictionary/index.ts", "../../voicing-dictionary/data.ts", "../../voicing/index.ts"], + "sourcesContent": ["import AbcNotation from \"@tonaljs/abc-notation\";\nimport * as Array from \"@tonaljs/array\";\nimport Chord from \"@tonaljs/chord\";\nimport ChordType from \"@tonaljs/chord-type\";\nimport Collection from \"@tonaljs/collection\";\nimport * as Core from \"@tonaljs/core\";\nimport DurationValue from \"@tonaljs/duration-value\";\nimport Interval from \"@tonaljs/interval\";\nimport Key from \"@tonaljs/key\";\nimport Midi from \"@tonaljs/midi\";\nimport Mode from \"@tonaljs/mode\";\nimport Note from \"@tonaljs/note\";\nimport Pcset from \"@tonaljs/pcset\";\nimport Progression from \"@tonaljs/progression\";\nimport Range from \"@tonaljs/range\";\nimport RomanNumeral from \"@tonaljs/roman-numeral\";\nimport Scale from \"@tonaljs/scale\";\nimport ScaleType from \"@tonaljs/scale-type\";\nimport TimeSignature from \"@tonaljs/time-signature\";\nimport VoiceLeading from \"@tonaljs/voice-leading\";\nimport Voicing from \"@tonaljs/voicing\";\nimport VoicingDictionary from \"@tonaljs/voicing-dictionary\";\n\nexport * from \"@tonaljs/core\";\n\n// deprecated (backwards compatibility)\nconst Tonal = Core;\nconst PcSet = Pcset;\nconst ChordDictionary = ChordType;\nconst ScaleDictionary = ScaleType;\n\nexport {\n AbcNotation,\n Array,\n Chord,\n ChordDictionary,\n ChordType,\n Collection,\n Core,\n DurationValue,\n Interval,\n Key,\n Midi,\n Mode,\n Note,\n PcSet,\n Pcset,\n Progression,\n Range,\n RomanNumeral,\n Scale,\n ScaleDictionary,\n ScaleType,\n TimeSignature,\n Tonal,\n VoiceLeading,\n Voicing,\n VoicingDictionary,\n};\n", "export interface NamedPitch {\n readonly name: string;\n}\n\n/*** @deprecated use NamedPitch */\nexport interface Named {\n readonly name: string;\n}\n\nexport interface NotFound extends NamedPitch {\n readonly empty: true;\n readonly name: \"\";\n}\n\nexport function isNamedPitch(src: unknown): src is NamedPitch {\n return src !== null &&\n typeof src === \"object\" &&\n \"name\" in src &&\n typeof src.name === \"string\"\n ? true\n : false;\n}\n\ntype Fifths = number;\ntype Octaves = number;\nexport type Direction = 1 | -1;\n\nexport type PitchClassCoordinates = [Fifths];\nexport type NoteCoordinates = [Fifths, Octaves];\nexport type IntervalCoordinates = [Fifths, Octaves, Direction];\nexport type PitchCoordinates =\n | PitchClassCoordinates\n | NoteCoordinates\n | IntervalCoordinates;\n\n/**\n * Pitch properties\n *\n * - {number} step - The step number: 0 = C, 1 = D, ... 6 = B\n * - {number} alt - Number of alterations: -2 = 'bb', -1 = 'b', 0 = '', 1 = '#', ...\n * - {number} [oct] = The octave (undefined when is a coord class)\n * - {number} [dir] = Interval direction (undefined when is not an interval)\n */\nexport interface Pitch {\n readonly step: number;\n readonly alt: number;\n readonly oct?: number; // undefined for pitch classes\n readonly dir?: Direction; // undefined for notes\n}\n\nconst SIZES = [0, 2, 4, 5, 7, 9, 11];\nexport const chroma = ({ step, alt }: Pitch) => (SIZES[step] + alt + 120) % 12;\n\nexport const height = ({ step, alt, oct, dir = 1 }: Pitch) =>\n dir * (SIZES[step] + alt + 12 * (oct === undefined ? -100 : oct));\n\nexport const midi = (pitch: Pitch) => {\n const h = height(pitch);\n return pitch.oct !== undefined && h >= -12 && h <= 115 ? h + 12 : null;\n};\n\nexport function isPitch(pitch: unknown): pitch is Pitch {\n return pitch !== null &&\n typeof pitch === \"object\" &&\n \"step\" in pitch &&\n typeof pitch.step === \"number\" &&\n \"alt\" in pitch &&\n typeof pitch.alt === \"number\" &&\n !isNaN(pitch.step) &&\n !isNaN(pitch.alt)\n ? true\n : false;\n}\n\n// The number of fifths of [C, D, E, F, G, A, B]\nconst FIFTHS = [0, 2, 4, -1, 1, 3, 5];\n// The number of octaves it span each step\nconst STEPS_TO_OCTS = FIFTHS.map((fifths: number) =>\n Math.floor((fifths * 7) / 12),\n);\n\n/**\n * Get coordinates from pitch object\n */\nexport function coordinates(pitch: Pitch): PitchCoordinates {\n const { step, alt, oct, dir = 1 } = pitch;\n const f = FIFTHS[step] + 7 * alt;\n if (oct === undefined) {\n return [dir * f];\n }\n const o = oct - STEPS_TO_OCTS[step] - 4 * alt;\n return [dir * f, dir * o];\n}\n\n// We need to get the steps from fifths\n// Fifths for CDEFGAB are [ 0, 2, 4, -1, 1, 3, 5 ]\n// We add 1 to fifths to avoid negative numbers, so:\n// for [\"F\", \"C\", \"G\", \"D\", \"A\", \"E\", \"B\"] we have:\nconst FIFTHS_TO_STEPS = [3, 0, 4, 1, 5, 2, 6];\n\n/**\n * Get pitch from coordinate objects\n */\nexport function pitch(coord: PitchCoordinates): Pitch {\n const [f, o, dir] = coord;\n const step = FIFTHS_TO_STEPS[unaltered(f)];\n const alt = Math.floor((f + 1) / 7);\n if (o === undefined) {\n return { step, alt, dir };\n }\n const oct = o + 4 * alt + STEPS_TO_OCTS[step];\n return { step, alt, oct, dir };\n}\n\n// Return the number of fifths as if it were unaltered\nfunction unaltered(f: number): number {\n const i = (f + 1) % 7;\n return i < 0 ? 7 + i : i;\n}\n", "import {\n coordinates,\n Direction,\n IntervalCoordinates,\n isNamedPitch,\n isPitch,\n NamedPitch,\n Pitch,\n pitch,\n PitchCoordinates,\n} from \"@tonaljs/pitch\";\n\nconst fillStr = (s: string, n: number) => Array(Math.abs(n) + 1).join(s);\n\nexport type IntervalName = string;\nexport type IntervalLiteral = IntervalName | Pitch | NamedPitch;\n\ntype Quality =\n | \"dddd\"\n | \"ddd\"\n | \"dd\"\n | \"d\"\n | \"m\"\n | \"M\"\n | \"P\"\n | \"A\"\n | \"AA\"\n | \"AAA\"\n | \"AAAA\";\ntype Type = \"perfectable\" | \"majorable\";\n\nexport interface Interval extends Pitch, NamedPitch {\n readonly empty: boolean;\n readonly name: IntervalName;\n readonly num: number;\n readonly q: Quality;\n readonly type: Type;\n readonly step: number;\n readonly alt: number;\n readonly dir: Direction;\n readonly simple: number;\n readonly semitones: number;\n readonly chroma: number;\n readonly coord: IntervalCoordinates;\n readonly oct: number;\n}\n\nconst NoInterval: Interval = Object.freeze({\n empty: true,\n name: \"\",\n num: NaN,\n q: \"\" as Quality,\n type: \"\" as Type,\n step: NaN,\n alt: NaN,\n dir: NaN as Direction,\n simple: NaN,\n semitones: NaN,\n chroma: NaN,\n coord: [] as unknown as IntervalCoordinates,\n oct: NaN,\n});\n\n// shorthand tonal notation (with quality after number)\nconst INTERVAL_TONAL_REGEX = \"([-+]?\\\\d+)(d{1,4}|m|M|P|A{1,4})\";\n// standard shorthand notation (with quality before number)\nconst INTERVAL_SHORTHAND_REGEX = \"(AA|A|P|M|m|d|dd)([-+]?\\\\d+)\";\nconst REGEX = new RegExp(\n \"^\" + INTERVAL_TONAL_REGEX + \"|\" + INTERVAL_SHORTHAND_REGEX + \"$\",\n);\n\ntype IntervalTokens = [string, string];\n\n/**\n * @private\n */\nexport function tokenizeInterval(str?: IntervalName): IntervalTokens {\n const m = REGEX.exec(`${str}`);\n if (m === null) {\n return [\"\", \"\"];\n }\n return m[1] ? [m[1], m[2]] : [m[4], m[3]];\n}\n\nconst cache: { [key in string]: Interval } = {};\n\n/**\n * Get interval properties. It returns an object with:\n *\n * - name: the interval name\n * - num: the interval number\n * - type: 'perfectable' or 'majorable'\n * - q: the interval quality (d, m, M, A)\n * - dir: interval direction (1 ascending, -1 descending)\n * - simple: the simplified number\n * - semitones: the size in semitones\n * - chroma: the interval chroma\n *\n * @param {string} interval - the interval name\n * @return {Object} the interval properties\n *\n * @example\n * import { interval } from '@tonaljs/core'\n * interval('P5').semitones // => 7\n * interval('m3').type // => 'majorable'\n */\nexport function interval(src: IntervalLiteral): Interval {\n return typeof src === \"string\"\n ? cache[src] || (cache[src] = parse(src))\n : isPitch(src)\n ? interval(pitchName(src))\n : isNamedPitch(src)\n ? interval(src.name)\n : NoInterval;\n}\n\nconst SIZES = [0, 2, 4, 5, 7, 9, 11];\nconst TYPES = \"PMMPPMM\";\nfunction parse(str?: string): Interval {\n const tokens = tokenizeInterval(str);\n if (tokens[0] === \"\") {\n return NoInterval;\n }\n const num = +tokens[0];\n const q = tokens[1] as Quality;\n const step = (Math.abs(num) - 1) % 7;\n const t = TYPES[step];\n if (t === \"M\" && q === \"P\") {\n return NoInterval;\n }\n const type = t === \"M\" ? \"majorable\" : \"perfectable\";\n\n const name = \"\" + num + q;\n const dir = num < 0 ? -1 : 1;\n const simple = num === 8 || num === -8 ? num : dir * (step + 1);\n const alt = qToAlt(type, q);\n const oct = Math.floor((Math.abs(num) - 1) / 7);\n const semitones = dir * (SIZES[step] + alt + 12 * oct);\n const chroma = (((dir * (SIZES[step] + alt)) % 12) + 12) % 12;\n const coord = coordinates({ step, alt, oct, dir }) as IntervalCoordinates;\n return {\n empty: false,\n name,\n num,\n q,\n step,\n alt,\n dir,\n type,\n simple,\n semitones,\n chroma,\n coord,\n oct,\n };\n}\n\n/**\n * @private\n *\n * forceDescending is used in the case of unison (#243)\n */\nexport function coordToInterval(\n coord: PitchCoordinates,\n forceDescending?: boolean,\n): Interval {\n const [f, o = 0] = coord;\n const isDescending = f * 7 + o * 12 < 0;\n const ivl: IntervalCoordinates =\n forceDescending || isDescending ? [-f, -o, -1] : [f, o, 1];\n return interval(pitch(ivl)) as Interval;\n}\n\nfunction qToAlt(type: Type, q: string): number {\n return (q === \"M\" && type === \"majorable\") ||\n (q === \"P\" && type === \"perfectable\")\n ? 0\n : q === \"m\" && type === \"majorable\"\n ? -1\n : /^A+$/.test(q)\n ? q.length\n : /^d+$/.test(q)\n ? -1 * (type === \"perfectable\" ? q.length : q.length + 1)\n : 0;\n}\n\n// return the interval name of a pitch\nfunction pitchName(props: Pitch): string {\n const { step, alt, oct = 0, dir } = props;\n if (!dir) {\n return \"\";\n }\n const calcNum = step + 1 + 7 * oct;\n // this is an edge case: descending pitch class unison (see #243)\n const num = calcNum === 0 ? step + 1 : calcNum;\n const d = dir < 0 ? \"-\" : \"\";\n const type = TYPES[step] === \"M\" ? \"majorable\" : \"perfectable\";\n const name = d + num + altToQ(type, alt);\n return name;\n}\n\nfunction altToQ(type: Type, alt: number): Quality {\n if (alt === 0) {\n return type === \"majorable\" ? \"M\" : \"P\";\n } else if (alt === -1 && type === \"majorable\") {\n return \"m\";\n } else if (alt > 0) {\n return fillStr(\"A\", alt) as Quality;\n } else {\n return fillStr(\"d\", type === \"perfectable\" ? alt : alt + 1) as Quality;\n }\n}\n", "import {\n coordinates,\n isNamedPitch,\n isPitch,\n NamedPitch,\n Pitch,\n pitch,\n PitchCoordinates,\n} from \"@tonaljs/pitch\";\n\nconst fillStr = (s: string, n: number) => Array(Math.abs(n) + 1).join(s);\n\nexport type NoteWithOctave = string;\nexport type PcName = string;\nexport type NoteName = NoteWithOctave | PcName;\nexport type NoteLiteral = NoteName | Pitch | NamedPitch;\n\nexport interface Note extends Pitch, NamedPitch {\n readonly empty: boolean;\n readonly name: NoteName;\n readonly letter: string;\n readonly acc: string;\n readonly pc: PcName;\n readonly chroma: number;\n readonly height: number;\n readonly coord: PitchCoordinates;\n readonly midi: number | null;\n readonly freq: number | null;\n}\n\nconst NoNote: Note = Object.freeze({\n empty: true,\n name: \"\",\n letter: \"\",\n acc: \"\",\n pc: \"\",\n step: NaN,\n alt: NaN,\n chroma: NaN,\n height: NaN,\n coord: [] as unknown as PitchCoordinates,\n midi: null,\n freq: null,\n});\n\nconst cache: Map = new Map();\n\nexport const stepToLetter = (step: number) => \"CDEFGAB\".charAt(step);\nexport const altToAcc = (alt: number): string =>\n alt < 0 ? fillStr(\"b\", -alt) : fillStr(\"#\", alt);\nexport const accToAlt = (acc: string): number =>\n acc[0] === \"b\" ? -acc.length : acc.length;\n\n/**\n * Given a note literal (a note name or a note object), returns the Note object\n * @example\n * note('Bb4') // => { name: \"Bb4\", midi: 70, chroma: 10, ... }\n */\nexport function note(src: NoteLiteral): Note {\n const stringSrc = JSON.stringify(src);\n\n const cached = cache.get(stringSrc);\n if (cached) {\n return cached;\n }\n\n const value =\n typeof src === \"string\"\n ? parse(src)\n : isPitch(src)\n ? note(pitchName(src))\n : isNamedPitch(src)\n ? note(src.name)\n : NoNote;\n cache.set(stringSrc, value);\n return value;\n}\n\ntype NoteTokens = [string, string, string, string];\n\nconst REGEX = /^([a-gA-G]?)(#{1,}|b{1,}|x{1,}|)(-?\\d*)\\s*(.*)$/;\n\n/**\n * @private\n */\nexport function tokenizeNote(str: string): NoteTokens {\n const m = REGEX.exec(str) as string[];\n return m\n ? [m[1].toUpperCase(), m[2].replace(/x/g, \"##\"), m[3], m[4]]\n : [\"\", \"\", \"\", \"\"];\n}\n\n/**\n * @private\n */\nexport function coordToNote(noteCoord: PitchCoordinates): Note {\n return note(pitch(noteCoord)) as Note;\n}\n\nconst mod = (n: number, m: number) => ((n % m) + m) % m;\n\nconst SEMI = [0, 2, 4, 5, 7, 9, 11];\nfunction parse(noteName: NoteName): Note {\n const tokens = tokenizeNote(noteName);\n if (tokens[0] === \"\" || tokens[3] !== \"\") {\n return NoNote;\n }\n\n const letter = tokens[0];\n const acc = tokens[1];\n const octStr = tokens[2];\n\n const step = (letter.charCodeAt(0) + 3) % 7;\n const alt = accToAlt(acc);\n const oct = octStr.length ? +octStr : undefined;\n const coord = coordinates({ step, alt, oct });\n\n const name = letter + acc + octStr;\n const pc = letter + acc;\n const chroma = (SEMI[step] + alt + 120) % 12;\n const height =\n oct === undefined\n ? mod(SEMI[step] + alt, 12) - 12 * 99\n : SEMI[step] + alt + 12 * (oct + 1);\n const midi = height >= 0 && height <= 127 ? height : null;\n const freq = oct === undefined ? null : Math.pow(2, (height - 69) / 12) * 440;\n\n return {\n empty: false,\n acc,\n alt,\n chroma,\n coord,\n freq,\n height,\n letter,\n midi,\n name,\n oct,\n pc,\n step,\n };\n}\n\nfunction pitchName(props: Pitch): NoteName {\n const { step, alt, oct } = props;\n const letter = stepToLetter(step);\n if (!letter) {\n return \"\";\n }\n\n const pc = letter + altToAcc(alt);\n return oct || oct === 0 ? pc + oct : pc;\n}\n", "import { PitchCoordinates } from \"@tonaljs/pitch\";\nimport {\n IntervalLiteral,\n IntervalName,\n interval as asInterval,\n coordToInterval,\n} from \"@tonaljs/pitch-interval\";\nimport {\n NoteLiteral,\n NoteName,\n note as asNote,\n coordToNote,\n} from \"@tonaljs/pitch-note\";\n\n/**\n * Transpose a note by an interval.\n *\n * @param {string} note - the note or note name\n * @param {string} interval - the interval or interval name\n * @return {string} the transposed note name or empty string if not valid notes\n * @example\n * import { transpose } from \"@tonaljs/core\"\n * transpose(\"d3\", \"3M\") // => \"F#3\"\n * transpose(\"D\", \"3M\") // => \"F#\"\n * [\"C\", \"D\", \"E\", \"F\", \"G\"].map(pc => transpose(pc, \"M3)) // => [\"E\", \"F#\", \"G#\", \"A\", \"B\"]\n */\nexport function transpose(\n noteName: NoteLiteral,\n intervalName: IntervalLiteral | [number, number],\n): NoteName {\n const note = asNote(noteName);\n const intervalCoord = Array.isArray(intervalName)\n ? intervalName\n : asInterval(intervalName).coord;\n if (note.empty || !intervalCoord || intervalCoord.length < 2) {\n return \"\";\n }\n const noteCoord = note.coord;\n const tr: PitchCoordinates =\n noteCoord.length === 1\n ? [noteCoord[0] + intervalCoord[0]]\n : [noteCoord[0] + intervalCoord[0], noteCoord[1] + intervalCoord[1]];\n return coordToNote(tr).name;\n}\n\n// Private\nexport function tonicIntervalsTransposer(\n intervals: string[],\n tonic: string | undefined | null,\n) {\n const len = intervals.length;\n return (normalized: number) => {\n if (!tonic) return \"\";\n const index =\n normalized < 0 ? (len - (-normalized % len)) % len : normalized % len;\n const octaves = Math.floor(normalized / len);\n const root = transpose(tonic, [0, octaves]);\n return transpose(root, intervals[index]);\n };\n}\n\n/**\n * Find the interval distance between two notes or coord classes.\n *\n * To find distance between coord classes, both notes must be coord classes and\n * the interval is always ascending\n *\n * @param {Note|string} from - the note or note name to calculate distance from\n * @param {Note|string} to - the note or note name to calculate distance to\n * @return {string} the interval name or empty string if not valid notes\n *\n */\nexport function distance(\n fromNote: NoteLiteral,\n toNote: NoteLiteral,\n): IntervalName {\n const from = asNote(fromNote);\n const to = asNote(toNote);\n if (from.empty || to.empty) {\n return \"\";\n }\n\n const fcoord = from.coord;\n const tcoord = to.coord;\n const fifths = tcoord[0] - fcoord[0];\n const octs =\n fcoord.length === 2 && tcoord.length === 2\n ? tcoord[1] - fcoord[1]\n : -Math.floor((fifths * 7) / 12);\n\n // If it's unison and not pitch class, it can be descending interval (#243)\n const forceDescending =\n to.height === from.height &&\n to.midi !== null &&\n from.midi !== null &&\n from.step > to.step;\n return coordToInterval([fifths, octs], forceDescending).name;\n}\n", "import { distance as dist, transpose as tr } from \"@tonaljs/pitch-distance\";\nimport { note } from \"@tonaljs/pitch-note\";\n\nconst fillStr = (character: string, times: number) =>\n Array(times + 1).join(character);\n\nconst REGEX = /^(_{1,}|=|\\^{1,}|)([abcdefgABCDEFG])([,']*)$/;\n\ntype AbcTokens = [string, string, string];\n\nexport function tokenize(str: string): AbcTokens {\n const m = REGEX.exec(str);\n if (!m) {\n return [\"\", \"\", \"\"];\n }\n return [m[1], m[2], m[3]];\n}\n\n/**\n * Convert a (string) note in ABC notation into a (string) note in scientific notation\n *\n * @example\n * abcToScientificNotation(\"c\") // => \"C5\"\n */\nexport function abcToScientificNotation(str: string): string {\n const [acc, letter, oct] = tokenize(str);\n if (letter === \"\") {\n return \"\";\n }\n let o = 4;\n for (let i = 0; i < oct.length; i++) {\n o += oct.charAt(i) === \",\" ? -1 : 1;\n }\n const a =\n acc[0] === \"_\"\n ? acc.replace(/_/g, \"b\")\n : acc[0] === \"^\"\n ? acc.replace(/\\^/g, \"#\")\n : \"\";\n return letter.charCodeAt(0) > 96\n ? letter.toUpperCase() + a + (o + 1)\n : letter + a + o;\n}\n\n/**\n * Convert a (string) note in scientific notation into a (string) note in ABC notation\n *\n * @example\n * scientificToAbcNotation(\"C#4\") // => \"^C\"\n */\nexport function scientificToAbcNotation(str: string): string {\n const n = note(str);\n if (n.empty || (!n.oct && n.oct !== 0)) {\n return \"\";\n }\n const { letter, acc, oct } = n;\n const a = acc[0] === \"b\" ? acc.replace(/b/g, \"_\") : acc.replace(/#/g, \"^\");\n const l = oct > 4 ? letter.toLowerCase() : letter;\n const o =\n oct === 5 ? \"\" : oct > 4 ? fillStr(\"'\", oct - 5) : fillStr(\",\", 4 - oct);\n return a + l + o;\n}\n\nexport function transpose(note: string, interval: string): string {\n return scientificToAbcNotation(tr(abcToScientificNotation(note), interval));\n}\n\nexport function distance(from: string, to: string): string {\n return dist(abcToScientificNotation(from), abcToScientificNotation(to));\n}\n\nexport default {\n abcToScientificNotation,\n scientificToAbcNotation,\n tokenize,\n transpose,\n distance,\n};\n", "import {\n coordinates,\n isNamedPitch,\n isPitch,\n NamedPitch,\n Pitch,\n pitch,\n PitchCoordinates,\n} from \"@tonaljs/pitch\";\n\nconst fillStr = (s: string, n: number) => Array(Math.abs(n) + 1).join(s);\n\nexport type NoteWithOctave = string;\nexport type PcName = string;\nexport type NoteName = NoteWithOctave | PcName;\nexport type NoteLiteral = NoteName | Pitch | NamedPitch;\n\nexport interface Note extends Pitch, NamedPitch {\n readonly empty: boolean;\n readonly name: NoteName;\n readonly letter: string;\n readonly acc: string;\n readonly pc: PcName;\n readonly chroma: number;\n readonly height: number;\n readonly coord: PitchCoordinates;\n readonly midi: number | null;\n readonly freq: number | null;\n}\n\nexport interface NoNote extends Partial {\n empty: true;\n name: \"\";\n pc: \"\";\n acc: \"\";\n}\nconst NoNote: NoNote = { empty: true, name: \"\", pc: \"\", acc: \"\" };\n\nconst cache: Map = new Map();\n\nexport const stepToLetter = (step: number) => \"CDEFGAB\".charAt(step);\nexport const altToAcc = (alt: number): string =>\n alt < 0 ? fillStr(\"b\", -alt) : fillStr(\"#\", alt);\nexport const accToAlt = (acc: string): number =>\n acc[0] === \"b\" ? -acc.length : acc.length;\n\n/**\n * Given a note literal (a note name or a note object), returns the Note object\n * @example\n * note('Bb4') // => { name: \"Bb4\", midi: 70, chroma: 10, ... }\n */\nexport function note(src: NoteLiteral): Note | NoNote {\n const stringSrc = JSON.stringify(src);\n\n const cached = cache.get(stringSrc);\n if (cached) {\n return cached;\n }\n\n const value =\n typeof src === \"string\"\n ? parse(src)\n : isPitch(src)\n ? note(pitchName(src))\n : isNamedPitch(src)\n ? note(src.name)\n : NoNote;\n cache.set(stringSrc, value);\n return value;\n}\n\ntype NoteTokens = [string, string, string, string];\n\nconst REGEX = /^([a-gA-G]?)(#{1,}|b{1,}|x{1,}|)(-?\\d*)\\s*(.*)$/;\n\n/**\n * @private\n */\nexport function tokenizeNote(str: string): NoteTokens {\n const m = REGEX.exec(str) as string[];\n return [m[1].toUpperCase(), m[2].replace(/x/g, \"##\"), m[3], m[4]];\n}\n\n/**\n * @private\n */\nexport function coordToNote(noteCoord: PitchCoordinates): Note {\n return note(pitch(noteCoord)) as Note;\n}\n\nconst mod = (n: number, m: number) => ((n % m) + m) % m;\n\nconst SEMI = [0, 2, 4, 5, 7, 9, 11];\nfunction parse(noteName: NoteName): Note | NoNote {\n const tokens = tokenizeNote(noteName);\n if (tokens[0] === \"\" || tokens[3] !== \"\") {\n return NoNote;\n }\n\n const letter = tokens[0];\n const acc = tokens[1];\n const octStr = tokens[2];\n\n const step = (letter.charCodeAt(0) + 3) % 7;\n const alt = accToAlt(acc);\n const oct = octStr.length ? +octStr : undefined;\n const coord = coordinates({ step, alt, oct });\n\n const name = letter + acc + octStr;\n const pc = letter + acc;\n const chroma = (SEMI[step] + alt + 120) % 12;\n const height =\n oct === undefined\n ? mod(SEMI[step] + alt, 12) - 12 * 99\n : SEMI[step] + alt + 12 * (oct + 1);\n const midi = height >= 0 && height <= 127 ? height : null;\n const freq = oct === undefined ? null : Math.pow(2, (height - 69) / 12) * 440;\n\n return {\n empty: false,\n acc,\n alt,\n chroma,\n coord,\n freq,\n height,\n letter,\n midi,\n name,\n oct,\n pc,\n step,\n };\n}\n\nfunction pitchName(props: Pitch): NoteName {\n const { step, alt, oct } = props;\n const letter = stepToLetter(step);\n if (!letter) {\n return \"\";\n }\n\n const pc = letter + altToAcc(alt);\n return oct || oct === 0 ? pc + oct : pc;\n}\n", "/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { note, Note } from \"@tonaljs/pitch-note\";\n\n// ascending range\nfunction ascR(b: number, n: number) {\n const a = [];\n // tslint:disable-next-line:curly\n for (; n--; a[n] = n + b);\n return a;\n}\n// descending range\nfunction descR(b: number, n: number) {\n const a = [];\n // tslint:disable-next-line:curly\n for (; n--; a[n] = b - n);\n return a;\n}\n\n/**\n * Creates a numeric range\n *\n * @param {number} from\n * @param {number} to\n * @return {Array}\n *\n * @example\n * range(-2, 2) // => [-2, -1, 0, 1, 2]\n * range(2, -2) // => [2, 1, 0, -1, -2]\n */\nexport function range(from: number, to: number): number[] {\n return from < to ? ascR(from, to - from + 1) : descR(from, from - to + 1);\n}\n\n/**\n * Rotates a list a number of times. It\"s completly agnostic about the\n * contents of the list.\n *\n * @param {Integer} times - the number of rotations\n * @param {Array} array\n * @return {Array} the rotated array\n *\n * @example\n * rotate(1, [1, 2, 3]) // => [2, 3, 1]\n */\nexport function rotate(times: number, arr: T[]): T[] {\n const len = arr.length;\n const n = ((times % len) + len) % len;\n return arr.slice(n, len).concat(arr.slice(0, n));\n}\n\n/**\n * Return a copy of the array with the null values removed\n * @function\n * @param {Array} array\n * @return {Array}\n *\n * @example\n * compact([\"a\", \"b\", null, \"c\"]) // => [\"a\", \"b\", \"c\"]\n */\nexport function compact(arr: any[]): any[] {\n return arr.filter((n) => n === 0 || n);\n}\n\n/**\n * Sort an array of notes in ascending order. Pitch classes are listed\n * before notes. Any string that is not a note is removed.\n *\n * @param {string[]} notes\n * @return {string[]} sorted array of notes\n *\n * @example\n * sortedNoteNames(['c2', 'c5', 'c1', 'c0', 'c6', 'c'])\n * // => ['C', 'C0', 'C1', 'C2', 'C5', 'C6']\n * sortedNoteNames(['c', 'F', 'G', 'a', 'b', 'h', 'J'])\n * // => ['C', 'F', 'G', 'A', 'B']\n */\nexport function sortedNoteNames(notes: string[]): string[] {\n const valid = notes.map((n) => note(n)).filter((n) => !n.empty) as Note[];\n return valid.sort((a, b) => a.height - b.height).map((n) => n.name);\n}\n\n/**\n * Get sorted notes with duplicates removed. Pitch classes are listed\n * before notes.\n *\n * @function\n * @param {string[]} array\n * @return {string[]} unique sorted notes\n *\n * @example\n * Array.sortedUniqNoteNames(['a', 'b', 'c2', '1p', 'p2', 'c2', 'b', 'c', 'c3' ])\n * // => [ 'C', 'A', 'B', 'C2', 'C3' ]\n */\nexport function sortedUniqNoteNames(arr: string[]): string[] {\n return sortedNoteNames(arr).filter((n, i, a) => i === 0 || n !== a[i - 1]);\n}\n\n/**\n * Randomizes the order of the specified array in-place, using the Fisher–Yates shuffle.\n *\n * @function\n * @param {Array} array\n * @return {Array} the array shuffled\n *\n * @example\n * shuffle([\"C\", \"D\", \"E\", \"F\"]) // => [...]\n */\nexport function shuffle(arr: any[], rnd = Math.random): any[] {\n let i: number;\n let t: any;\n let m: number = arr.length;\n while (m) {\n i = Math.floor(rnd() * m--);\n t = arr[m];\n arr[m] = arr[i];\n arr[i] = t;\n }\n return arr;\n}\n\n/**\n * Get all permutations of an array\n *\n * @param {Array} array - the array\n * @return {Array} an array with all the permutations\n * @example\n * permutations([\"a\", \"b\", \"c\"])) // =>\n * [\n * [\"a\", \"b\", \"c\"],\n * [\"b\", \"a\", \"c\"],\n * [\"b\", \"c\", \"a\"],\n * [\"a\", \"c\", \"b\"],\n * [\"c\", \"a\", \"b\"],\n * [\"c\", \"b\", \"a\"]\n * ]\n */\nexport function permutations(arr: any[]): any[] {\n if (arr.length === 0) {\n return [[]];\n }\n return permutations(arr.slice(1)).reduce((acc, perm) => {\n return acc.concat(\n arr.map((e, pos) => {\n const newPerm = perm.slice();\n newPerm.splice(pos, 0, arr[0]);\n return newPerm;\n }),\n );\n }, []);\n}\n", "import { isNamedPitch } from \"@tonaljs/pitch\";\n\nexport * from \"@tonaljs/pitch\";\nexport * from \"@tonaljs/pitch-distance\";\nexport * from \"@tonaljs/pitch-interval\";\nexport * from \"@tonaljs/pitch-note\";\n\nexport const fillStr = (s: string, n: number) => Array(Math.abs(n) + 1).join(s);\n\nexport function deprecate<\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ResultFn extends (this: any, ...newArgs: any[]) => ReturnType,\n>(original: string, alternative: string, fn: ResultFn) {\n return function (this: unknown, ...args: unknown[]): ReturnType {\n // tslint:disable-next-line\n console.warn(`${original} is deprecated. Use ${alternative}.`);\n return fn.apply(this, args);\n };\n}\n\nexport const isNamed = deprecate(\"isNamed\", \"isNamedPitch\", isNamedPitch);\n", "/* eslint-disable @typescript-eslint/no-explicit-any */\n// ascending range\nfunction ascR(b: number, n: number) {\n const a = [];\n // tslint:disable-next-line:curly\n for (; n--; a[n] = n + b);\n return a;\n}\n// descending range\nfunction descR(b: number, n: number) {\n const a = [];\n // tslint:disable-next-line:curly\n for (; n--; a[n] = b - n);\n return a;\n}\n\n/**\n * Creates a numeric range\n *\n * @param {number} from\n * @param {number} to\n * @return {Array}\n *\n * @example\n * range(-2, 2) // => [-2, -1, 0, 1, 2]\n * range(2, -2) // => [2, 1, 0, -1, -2]\n */\nexport function range(from: number, to: number): number[] {\n return from < to ? ascR(from, to - from + 1) : descR(from, from - to + 1);\n}\n\n/**\n * Rotates a list a number of times. It\"s completly agnostic about the\n * contents of the list.\n *\n * @param {Integer} times - the number of rotations\n * @param {Array} collection\n * @return {Array} the rotated collection\n *\n * @example\n * rotate(1, [1, 2, 3]) // => [2, 3, 1]\n */\nexport function rotate(times: number, arr: T[]): T[] {\n const len = arr.length;\n const n = ((times % len) + len) % len;\n return arr.slice(n, len).concat(arr.slice(0, n));\n}\n\n/**\n * Return a copy of the collection with the null values removed\n * @function\n * @param {Array} collection\n * @return {Array}\n *\n * @example\n * compact([\"a\", \"b\", null, \"c\"]) // => [\"a\", \"b\", \"c\"]\n */\nexport function compact(arr: any[]): any[] {\n return arr.filter((n) => n === 0 || n);\n}\n\n/**\n * Randomizes the order of the specified collection in-place, using the Fisher–Yates shuffle.\n *\n * @function\n * @param {Array} collection\n * @return {Array} the collection shuffled\n *\n * @example\n * shuffle([\"C\", \"D\", \"E\", \"F\"]) // => [...]\n */\nexport function shuffle(arr: any[], rnd = Math.random): any[] {\n let i: number;\n let t: any;\n let m: number = arr.length;\n while (m) {\n i = Math.floor(rnd() * m--);\n t = arr[m];\n arr[m] = arr[i];\n arr[i] = t;\n }\n return arr;\n}\n\n/**\n * Get all permutations of an collection\n *\n * @param {Array} collection - the collection\n * @return {Array} an collection with all the permutations\n * @example\n * permutations([\"a\", \"b\", \"c\"])) // =>\n * [\n * [\"a\", \"b\", \"c\"],\n * [\"b\", \"a\", \"c\"],\n * [\"b\", \"c\", \"a\"],\n * [\"a\", \"c\", \"b\"],\n * [\"c\", \"a\", \"b\"],\n * [\"c\", \"b\", \"a\"]\n * ]\n */\nexport function permutations(arr: any[]): any[] {\n if (arr.length === 0) {\n return [[]];\n }\n return permutations(arr.slice(1)).reduce((acc, perm) => {\n return acc.concat(\n arr.map((e, pos) => {\n const newPerm = perm.slice();\n newPerm.splice(pos, 0, arr[0]);\n return newPerm;\n }),\n );\n }, []);\n}\n\nexport default {\n compact,\n permutations,\n range,\n rotate,\n shuffle,\n};\n", "import { compact, range, rotate } from \"@tonaljs/collection\";\nimport {\n Interval,\n IntervalName,\n NotFound,\n Note,\n NoteName,\n deprecate,\n interval,\n note,\n transpose,\n} from \"@tonaljs/core\";\n\n/**\n * The properties of a pitch class set\n * @param {number} num - a number between 1 and 4095 (both included) that\n * uniquely identifies the set. It's the decimal number of the chrom.\n * @param {string} chroma - a string representation of the set: a 12-char string\n * with either \"1\" or \"0\" as characters, representing a pitch class or not\n * for the given position in the octave. For example, a \"1\" at index 0 means 'C',\n * a \"1\" at index 2 means 'D', and so on...\n * @param {string} normalized - the chroma but shifted to the first 1\n * @param {number} length - the number of notes of the pitch class set\n * @param {IntervalName[]} intervals - the intervals of the pitch class set\n * *starting from C*\n */\nexport interface Pcset {\n readonly name: string;\n readonly empty: boolean;\n readonly setNum: number;\n readonly chroma: PcsetChroma;\n readonly normalized: PcsetChroma;\n readonly intervals: IntervalName[];\n}\n\nexport const EmptyPcset: Pcset = {\n empty: true,\n name: \"\",\n setNum: 0,\n chroma: \"000000000000\",\n normalized: \"000000000000\",\n intervals: [],\n};\n\nexport type PcsetChroma = string;\nexport type PcsetNum = number;\n\n// UTILITIES\nconst setNumToChroma = (num: number): string =>\n Number(num).toString(2).padStart(12, \"0\");\nconst chromaToNumber = (chroma: string): number => parseInt(chroma, 2);\nconst REGEX = /^[01]{12}$/;\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function isChroma(set: any): set is PcsetChroma {\n return REGEX.test(set);\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nconst isPcsetNum = (set: any): set is PcsetNum =>\n typeof set === \"number\" && set >= 0 && set <= 4095;\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nconst isPcset = (set: any): set is Pcset => set && isChroma(set.chroma);\n\nconst cache: { [key in string]: Pcset } = { [EmptyPcset.chroma]: EmptyPcset };\n\n/**\n * A definition of a pitch class set. It could be:\n * - The pitch class set chroma (a 12-length string with only 1s or 0s)\n * - The pitch class set number (an integer between 1 and 4095)\n * - An array of note names\n * - An array of interval names\n */\nexport type Set =\n | Partial\n | PcsetChroma\n | PcsetNum\n | NoteName[]\n | IntervalName[];\n\n/**\n * Get the pitch class set of a collection of notes or set number or chroma\n */\nexport function get(src: Set): Pcset {\n const chroma: PcsetChroma = isChroma(src)\n ? src\n : isPcsetNum(src)\n ? setNumToChroma(src)\n : Array.isArray(src)\n ? listToChroma(src)\n : isPcset(src)\n ? src.chroma\n : EmptyPcset.chroma;\n\n return (cache[chroma] = cache[chroma] || chromaToPcset(chroma));\n}\n\n/**\n * Use Pcset.properties\n * @function\n * @deprecated\n */\nexport const pcset = deprecate(\"Pcset.pcset\", \"Pcset.get\", get);\n\n/**\n * Get pitch class set chroma\n * @function\n * @example\n * Pcset.chroma([\"c\", \"d\", \"e\"]); //=> \"101010000000\"\n */\nexport const chroma = (set: Set) => get(set).chroma;\n\n/**\n * Get intervals (from C) of a set\n * @function\n * @example\n * Pcset.intervals([\"c\", \"d\", \"e\"]); //=>\n */\nconst intervals = (set: Set) => get(set).intervals;\n\n/**\n * Get pitch class set number\n * @function\n * @example\n * Pcset.num([\"c\", \"d\", \"e\"]); //=> 2192\n */\nconst num = (set: Set) => get(set).setNum;\n\nconst IVLS = [\n \"1P\",\n \"2m\",\n \"2M\",\n \"3m\",\n \"3M\",\n \"4P\",\n \"5d\",\n \"5P\",\n \"6m\",\n \"6M\",\n \"7m\",\n \"7M\",\n];\n\n/**\n * @private\n * Get the intervals of a pcset *starting from C*\n * @param {Set} set - the pitch class set\n * @return {IntervalName[]} an array of interval names or an empty array\n * if not a valid pitch class set\n */\nexport function chromaToIntervals(chroma: PcsetChroma): IntervalName[] {\n const intervals = [];\n for (let i = 0; i < 12; i++) {\n // tslint:disable-next-line:curly\n if (chroma.charAt(i) === \"1\") intervals.push(IVLS[i]);\n }\n return intervals;\n}\n\nexport function notes(set: Set): NoteName[] {\n return get(set).intervals.map((ivl) => transpose(\"C\", ivl));\n}\n\n/**\n * Get a list of all possible pitch class sets (all possible chromas) *having\n * C as root*. There are 2048 different chromas. If you want them with another\n * note you have to transpose it\n *\n * @see http://allthescales.org/\n * @return {Array} an array of possible chromas from '10000000000' to '11111111111'\n */\nexport function chromas(): PcsetChroma[] {\n return range(2048, 4095).map(setNumToChroma);\n}\n\n/**\n * Given a a list of notes or a pcset chroma, produce the rotations\n * of the chroma discarding the ones that starts with \"0\"\n *\n * This is used, for example, to get all the modes of a scale.\n *\n * @param {Array|string} set - the list of notes or pitchChr of the set\n * @param {boolean} normalize - (Optional, true by default) remove all\n * the rotations that starts with \"0\"\n * @return {Array} an array with all the modes of the chroma\n *\n * @example\n * Pcset.modes([\"C\", \"D\", \"E\"]).map(Pcset.intervals)\n */\nexport function modes(set: Set, normalize = true): PcsetChroma[] {\n const pcs = get(set);\n\n const binary = pcs.chroma.split(\"\");\n return compact(\n binary.map((_, i) => {\n const r = rotate(i, binary);\n return normalize && r[0] === \"0\" ? null : r.join(\"\");\n }),\n );\n}\n\n/**\n * Test if two pitch class sets are numentical\n *\n * @param {Array|string} set1 - one of the pitch class sets\n * @param {Array|string} set2 - the other pitch class set\n * @return {boolean} true if they are equal\n * @example\n * Pcset.isEqual([\"c2\", \"d3\"], [\"c5\", \"d2\"]) // => true\n */\nexport function isEqual(s1: Set, s2: Set) {\n return get(s1).setNum === get(s2).setNum;\n}\n\n/**\n * Create a function that test if a collection of notes is a\n * subset of a given set\n *\n * The function is curryfied.\n *\n * @param {PcsetChroma|NoteName[]} set - the superset to test against (chroma or\n * list of notes)\n * @return{function(PcsetChroma|NoteNames[]): boolean} a function accepting a set\n * to test against (chroma or list of notes)\n * @example\n * const inCMajor = Pcset.isSubsetOf([\"C\", \"E\", \"G\"])\n * inCMajor([\"e6\", \"c4\"]) // => true\n * inCMajor([\"e6\", \"c4\", \"d3\"]) // => false\n */\nexport function isSubsetOf(set: Set) {\n const s = get(set).setNum;\n\n return (notes: Set | Pcset) => {\n const o = get(notes).setNum;\n // tslint:disable-next-line: no-bitwise\n return s && s !== o && (o & s) === o;\n };\n}\n\n/**\n * Create a function that test if a collection of notes is a\n * superset of a given set (it contains all notes and at least one more)\n *\n * @param {Set} set - an array of notes or a chroma set string to test against\n * @return {(subset: Set): boolean} a function that given a set\n * returns true if is a subset of the first one\n * @example\n * const extendsCMajor = Pcset.isSupersetOf([\"C\", \"E\", \"G\"])\n * extendsCMajor([\"e6\", \"a\", \"c4\", \"g2\"]) // => true\n * extendsCMajor([\"c6\", \"e4\", \"g3\"]) // => false\n */\nexport function isSupersetOf(set: Set) {\n const s = get(set).setNum;\n return (notes: Set) => {\n const o = get(notes).setNum;\n // tslint:disable-next-line: no-bitwise\n return s && s !== o && (o | s) === o;\n };\n}\n\n/**\n * Test if a given pitch class set includes a note\n *\n * @param {Array} set - the base set to test against\n * @param {string} note - the note to test\n * @return {boolean} true if the note is included in the pcset\n *\n * Can be partially applied\n *\n * @example\n * const isNoteInCMajor = isNoteIncludedIn(['C', 'E', 'G'])\n * isNoteInCMajor('C4') // => true\n * isNoteInCMajor('C#4') // => false\n */\nexport function isNoteIncludedIn(set: Set) {\n const s = get(set);\n\n return (noteName: NoteName): boolean => {\n const n = note(noteName);\n return s && !n.empty && s.chroma.charAt(n.chroma) === \"1\";\n };\n}\n\n/** @deprecated use: isNoteIncludedIn */\nexport const includes = isNoteIncludedIn;\n\n/**\n * Filter a list with a pitch class set\n *\n * @param {Array|string} set - the pitch class set notes\n * @param {Array|string} notes - the note list to be filtered\n * @return {Array} the filtered notes\n *\n * @example\n * Pcset.filter([\"C\", \"D\", \"E\"], [\"c2\", \"c#2\", \"d2\", \"c3\", \"c#3\", \"d3\"]) // => [ \"c2\", \"d2\", \"c3\", \"d3\" ])\n * Pcset.filter([\"C2\"], [\"c2\", \"c#2\", \"d2\", \"c3\", \"c#3\", \"d3\"]) // => [ \"c2\", \"c3\" ])\n */\nexport function filter(set: Set) {\n const isIncluded = isNoteIncludedIn(set);\n return (notes: NoteName[]) => {\n return notes.filter(isIncluded);\n };\n}\n\nexport default {\n get,\n chroma,\n num,\n intervals,\n chromas,\n isSupersetOf,\n isSubsetOf,\n isNoteIncludedIn,\n isEqual,\n filter,\n modes,\n notes,\n // deprecated\n pcset,\n};\n\n//// PRIVATE ////\n\nfunction chromaRotations(chroma: string): string[] {\n const binary = chroma.split(\"\");\n return binary.map((_, i) => rotate(i, binary).join(\"\"));\n}\n\nfunction chromaToPcset(chroma: PcsetChroma): Pcset {\n const setNum = chromaToNumber(chroma);\n const normalizedNum = chromaRotations(chroma)\n .map(chromaToNumber)\n .filter((n) => n >= 2048)\n .sort()[0];\n const normalized = setNumToChroma(normalizedNum);\n\n const intervals = chromaToIntervals(chroma);\n\n return {\n empty: false,\n name: \"\",\n setNum,\n chroma,\n normalized,\n intervals,\n };\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nfunction listToChroma(set: any[]): PcsetChroma {\n if (set.length === 0) {\n return EmptyPcset.chroma;\n }\n\n let pitch: Note | Interval | NotFound;\n const binary = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];\n // tslint:disable-next-line:prefer-for-of\n for (let i = 0; i < set.length; i++) {\n pitch = note(set[i]);\n // tslint:disable-next-line: curly\n if (pitch.empty) pitch = interval(set[i]);\n // tslint:disable-next-line: curly\n if (!pitch.empty) binary[pitch.chroma] = 1;\n }\n return binary.join(\"\");\n}\n", "import { deprecate } from \"@tonaljs/core\";\nimport {\n EmptyPcset,\n get as pcset,\n Pcset,\n PcsetChroma,\n PcsetNum,\n} from \"@tonaljs/pcset\";\nimport data from \"./data\";\n\nexport type ChordQuality =\n | \"Major\"\n | \"Minor\"\n | \"Augmented\"\n | \"Diminished\"\n | \"Unknown\";\n\nexport interface ChordType extends Pcset {\n name: string;\n quality: ChordQuality;\n aliases: string[];\n}\nconst NoChordType: ChordType = {\n ...EmptyPcset,\n name: \"\",\n quality: \"Unknown\",\n intervals: [],\n aliases: [],\n};\n\ntype ChordTypeName = string | PcsetChroma | PcsetNum;\n\nlet dictionary: ChordType[] = [];\nlet index: Record = {};\n\n/**\n * Given a chord name or chroma, return the chord properties\n * @param {string} source - chord name or pitch class set chroma\n * @example\n * import { get } from 'tonaljs/chord-type'\n * get('major') // => { name: 'major', ... }\n */\nexport function get(type: ChordTypeName): ChordType {\n return index[type] || NoChordType;\n}\n\nexport const chordType = deprecate(\"ChordType.chordType\", \"ChordType.get\", get);\n\n/**\n * Get all chord (long) names\n */\nexport function names() {\n return dictionary.map((chord) => chord.name).filter((x) => x);\n}\n\n/**\n * Get all chord symbols\n */\nexport function symbols() {\n return dictionary.map((chord) => chord.aliases[0]).filter((x) => x);\n}\n\n/**\n * Keys used to reference chord types\n */\nexport function keys() {\n return Object.keys(index);\n}\n\n/**\n * Return a list of all chord types\n */\nexport function all(): ChordType[] {\n return dictionary.slice();\n}\n\nexport const entries = deprecate(\"ChordType.entries\", \"ChordType.all\", all);\n\n/**\n * Clear the dictionary\n */\nexport function removeAll() {\n dictionary = [];\n index = {};\n}\n\n/**\n * Add a chord to the dictionary.\n * @param intervals\n * @param aliases\n * @param [fullName]\n */\nexport function add(intervals: string[], aliases: string[], fullName?: string) {\n const quality = getQuality(intervals);\n const chord = {\n ...pcset(intervals),\n name: fullName || \"\",\n quality,\n intervals,\n aliases,\n };\n dictionary.push(chord);\n if (chord.name) {\n index[chord.name] = chord;\n }\n index[chord.setNum] = chord;\n index[chord.chroma] = chord;\n chord.aliases.forEach((alias) => addAlias(chord, alias));\n}\n\nexport function addAlias(chord: ChordType, alias: string) {\n index[alias] = chord;\n}\n\nfunction getQuality(intervals: string[]): ChordQuality {\n const has = (interval: string) => intervals.indexOf(interval) !== -1;\n return has(\"5A\")\n ? \"Augmented\"\n : has(\"3M\")\n ? \"Major\"\n : has(\"5d\")\n ? \"Diminished\"\n : has(\"3m\")\n ? \"Minor\"\n : \"Unknown\";\n}\n\ndata.forEach(([ivls, fullName, names]: string[]) =>\n add(ivls.split(\" \"), names.split(\" \"), fullName),\n);\ndictionary.sort((a, b) => a.setNum - b.setNum);\n\nexport default {\n names,\n symbols,\n get,\n all,\n add,\n removeAll,\n keys,\n // deprecated\n entries,\n chordType,\n};\n", "/**\n * @private\n * Chord List\n * Source: https://en.wikibooks.org/wiki/Music_Theory/Complete_List_of_Chord_Patterns\n * Format: [\"intervals\", \"full name\", \"abrv1 abrv2\"]\n */\nconst CHORDS: string[][] = [\n // ==Major==\n [\"1P 3M 5P\", \"major\", \"M ^ maj\"],\n [\"1P 3M 5P 7M\", \"major seventh\", \"maj7 Δ ma7 M7 Maj7 ^7\"],\n [\"1P 3M 5P 7M 9M\", \"major ninth\", \"maj9 Δ9 ^9\"],\n [\"1P 3M 5P 7M 9M 13M\", \"major thirteenth\", \"maj13 Maj13 ^13\"],\n [\"1P 3M 5P 6M\", \"sixth\", \"6 add6 add13 M6\"],\n [\"1P 3M 5P 6M 9M\", \"sixth added ninth\", \"6add9 6/9 69 M69\"],\n [\"1P 3M 6m 7M\", \"major seventh flat sixth\", \"M7b6 ^7b6\"],\n [\n \"1P 3M 5P 7M 11A\",\n \"major seventh sharp eleventh\",\n \"maj#4 Δ#4 Δ#11 M7#11 ^7#11 maj7#11\",\n ],\n // ==Minor==\n // '''Normal'''\n [\"1P 3m 5P\", \"minor\", \"m min -\"],\n [\"1P 3m 5P 7m\", \"minor seventh\", \"m7 min7 mi7 -7\"],\n [\n \"1P 3m 5P 7M\",\n \"minor/major seventh\",\n \"m/ma7 m/maj7 mM7 mMaj7 m/M7 -Δ7 mΔ -^7 -maj7\",\n ],\n [\"1P 3m 5P 6M\", \"minor sixth\", \"m6 -6\"],\n [\"1P 3m 5P 7m 9M\", \"minor ninth\", \"m9 -9\"],\n [\"1P 3m 5P 7M 9M\", \"minor/major ninth\", \"mM9 mMaj9 -^9\"],\n [\"1P 3m 5P 7m 9M 11P\", \"minor eleventh\", \"m11 -11\"],\n [\"1P 3m 5P 7m 9M 13M\", \"minor thirteenth\", \"m13 -13\"],\n // '''Diminished'''\n [\"1P 3m 5d\", \"diminished\", \"dim ° o\"],\n [\"1P 3m 5d 7d\", \"diminished seventh\", \"dim7 °7 o7\"],\n [\"1P 3m 5d 7m\", \"half-diminished\", \"m7b5 ø -7b5 h7 h\"],\n // ==Dominant/Seventh==\n // '''Normal'''\n [\"1P 3M 5P 7m\", \"dominant seventh\", \"7 dom\"],\n [\"1P 3M 5P 7m 9M\", \"dominant ninth\", \"9\"],\n [\"1P 3M 5P 7m 9M 13M\", \"dominant thirteenth\", \"13\"],\n [\"1P 3M 5P 7m 11A\", \"lydian dominant seventh\", \"7#11 7#4\"],\n // '''Altered'''\n [\"1P 3M 5P 7m 9m\", \"dominant flat ninth\", \"7b9\"],\n [\"1P 3M 5P 7m 9A\", \"dominant sharp ninth\", \"7#9\"],\n [\"1P 3M 7m 9m\", \"altered\", \"alt7\"],\n // '''Suspended'''\n [\"1P 4P 5P\", \"suspended fourth\", \"sus4 sus\"],\n [\"1P 2M 5P\", \"suspended second\", \"sus2\"],\n [\"1P 4P 5P 7m\", \"suspended fourth seventh\", \"7sus4 7sus\"],\n [\"1P 5P 7m 9M 11P\", \"eleventh\", \"11\"],\n [\n \"1P 4P 5P 7m 9m\",\n \"suspended fourth flat ninth\",\n \"b9sus phryg 7b9sus 7b9sus4\",\n ],\n // ==Other==\n [\"1P 5P\", \"fifth\", \"5\"],\n [\"1P 3M 5A\", \"augmented\", \"aug + +5 ^#5\"],\n [\"1P 3m 5A\", \"minor augmented\", \"m#5 -#5 m+\"],\n [\"1P 3M 5A 7M\", \"augmented seventh\", \"maj7#5 maj7+5 +maj7 ^7#5\"],\n [\n \"1P 3M 5P 7M 9M 11A\",\n \"major sharp eleventh (lydian)\",\n \"maj9#11 Δ9#11 ^9#11\",\n ],\n // ==Legacy==\n [\"1P 2M 4P 5P\", \"\", \"sus24 sus4add9\"],\n [\"1P 3M 5A 7M 9M\", \"\", \"maj9#5 Maj9#5\"],\n [\"1P 3M 5A 7m\", \"\", \"7#5 +7 7+ 7aug aug7\"],\n [\"1P 3M 5A 7m 9A\", \"\", \"7#5#9 7#9#5 7alt\"],\n [\"1P 3M 5A 7m 9M\", \"\", \"9#5 9+\"],\n [\"1P 3M 5A 7m 9M 11A\", \"\", \"9#5#11\"],\n [\"1P 3M 5A 7m 9m\", \"\", \"7#5b9 7b9#5\"],\n [\"1P 3M 5A 7m 9m 11A\", \"\", \"7#5b9#11\"],\n [\"1P 3M 5A 9A\", \"\", \"+add#9\"],\n [\"1P 3M 5A 9M\", \"\", \"M#5add9 +add9\"],\n [\"1P 3M 5P 6M 11A\", \"\", \"M6#11 M6b5 6#11 6b5\"],\n [\"1P 3M 5P 6M 7M 9M\", \"\", \"M7add13\"],\n [\"1P 3M 5P 6M 9M 11A\", \"\", \"69#11\"],\n [\"1P 3m 5P 6M 9M\", \"\", \"m69 -69\"],\n [\"1P 3M 5P 6m 7m\", \"\", \"7b6\"],\n [\"1P 3M 5P 7M 9A 11A\", \"\", \"maj7#9#11\"],\n [\"1P 3M 5P 7M 9M 11A 13M\", \"\", \"M13#11 maj13#11 M13+4 M13#4\"],\n [\"1P 3M 5P 7M 9m\", \"\", \"M7b9\"],\n [\"1P 3M 5P 7m 11A 13m\", \"\", \"7#11b13 7b5b13\"],\n [\"1P 3M 5P 7m 13M\", \"\", \"7add6 67 7add13\"],\n [\"1P 3M 5P 7m 9A 11A\", \"\", \"7#9#11 7b5#9 7#9b5\"],\n [\"1P 3M 5P 7m 9A 11A 13M\", \"\", \"13#9#11\"],\n [\"1P 3M 5P 7m 9A 11A 13m\", \"\", \"7#9#11b13\"],\n [\"1P 3M 5P 7m 9A 13M\", \"\", \"13#9\"],\n [\"1P 3M 5P 7m 9A 13m\", \"\", \"7#9b13\"],\n [\"1P 3M 5P 7m 9M 11A\", \"\", \"9#11 9+4 9#4\"],\n [\"1P 3M 5P 7m 9M 11A 13M\", \"\", \"13#11 13+4 13#4\"],\n [\"1P 3M 5P 7m 9M 11A 13m\", \"\", \"9#11b13 9b5b13\"],\n [\"1P 3M 5P 7m 9m 11A\", \"\", \"7b9#11 7b5b9 7b9b5\"],\n [\"1P 3M 5P 7m 9m 11A 13M\", \"\", \"13b9#11\"],\n [\"1P 3M 5P 7m 9m 11A 13m\", \"\", \"7b9b13#11 7b9#11b13 7b5b9b13\"],\n [\"1P 3M 5P 7m 9m 13M\", \"\", \"13b9\"],\n [\"1P 3M 5P 7m 9m 13m\", \"\", \"7b9b13\"],\n [\"1P 3M 5P 7m 9m 9A\", \"\", \"7b9#9\"],\n [\"1P 3M 5P 9M\", \"\", \"Madd9 2 add9 add2\"],\n [\"1P 3M 5P 9m\", \"\", \"Maddb9\"],\n [\"1P 3M 5d\", \"\", \"Mb5\"],\n [\"1P 3M 5d 6M 7m 9M\", \"\", \"13b5\"],\n [\"1P 3M 5d 7M\", \"\", \"M7b5\"],\n [\"1P 3M 5d 7M 9M\", \"\", \"M9b5\"],\n [\"1P 3M 5d 7m\", \"\", \"7b5\"],\n [\"1P 3M 5d 7m 9M\", \"\", \"9b5\"],\n [\"1P 3M 7m\", \"\", \"7no5\"],\n [\"1P 3M 7m 13m\", \"\", \"7b13\"],\n [\"1P 3M 7m 9M\", \"\", \"9no5\"],\n [\"1P 3M 7m 9M 13M\", \"\", \"13no5\"],\n [\"1P 3M 7m 9M 13m\", \"\", \"9b13\"],\n [\"1P 3m 4P 5P\", \"\", \"madd4\"],\n [\"1P 3m 5P 6m 7M\", \"\", \"mMaj7b6\"],\n [\"1P 3m 5P 6m 7M 9M\", \"\", \"mMaj9b6\"],\n [\"1P 3m 5P 7m 11P\", \"\", \"m7add11 m7add4\"],\n [\"1P 3m 5P 9M\", \"\", \"madd9\"],\n [\"1P 3m 5d 6M 7M\", \"\", \"o7M7\"],\n [\"1P 3m 5d 7M\", \"\", \"oM7\"],\n [\"1P 3m 6m 7M\", \"\", \"mb6M7\"],\n [\"1P 3m 6m 7m\", \"\", \"m7#5\"],\n [\"1P 3m 6m 7m 9M\", \"\", \"m9#5\"],\n [\"1P 3m 5A 7m 9M 11P\", \"\", \"m11A\"],\n [\"1P 3m 6m 9m\", \"\", \"mb6b9\"],\n [\"1P 2M 3m 5d 7m\", \"\", \"m9b5\"],\n [\"1P 4P 5A 7M\", \"\", \"M7#5sus4\"],\n [\"1P 4P 5A 7M 9M\", \"\", \"M9#5sus4\"],\n [\"1P 4P 5A 7m\", \"\", \"7#5sus4\"],\n [\"1P 4P 5P 7M\", \"\", \"M7sus4\"],\n [\"1P 4P 5P 7M 9M\", \"\", \"M9sus4\"],\n [\"1P 4P 5P 7m 9M\", \"\", \"9sus4 9sus\"],\n [\"1P 4P 5P 7m 9M 13M\", \"\", \"13sus4 13sus\"],\n [\"1P 4P 5P 7m 9m 13m\", \"\", \"7sus4b9b13 7b9b13sus4\"],\n [\"1P 4P 7m 10m\", \"\", \"4 quartal\"],\n [\"1P 5P 7m 9m 11P\", \"\", \"11b9\"],\n];\n\nexport default CHORDS;\n", "import { all, ChordType } from \"@tonaljs/chord-type\";\nimport { note } from \"@tonaljs/core\";\nimport { modes } from \"@tonaljs/pcset\";\n\ninterface FoundChord {\n readonly weight: number;\n readonly name: string;\n}\n\nconst namedSet = (notes: string[]) => {\n const pcToName = notes.reduce>((record, n) => {\n const chroma = note(n).chroma;\n if (chroma !== undefined) {\n record[chroma] = record[chroma] || note(n).name;\n }\n return record;\n }, {});\n\n return (chroma: number) => pcToName[chroma];\n};\n\ntype DetectOptions = {\n assumePerfectFifth: boolean;\n};\nexport function detect(\n source: string[],\n options: Partial = {},\n): string[] {\n const notes = source.map((n) => note(n).pc).filter((x) => x);\n if (note.length === 0) {\n return [];\n }\n\n const found: FoundChord[] = findMatches(notes, 1, options);\n\n return found\n .filter((chord) => chord.weight)\n .sort((a, b) => b.weight - a.weight)\n .map((chord) => chord.name);\n}\n\n/* tslint:disable:no-bitwise */\nconst BITMASK = {\n // 3m 000100000000\n // 3M 000010000000\n anyThirds: 384,\n // 5P 000000010000\n perfectFifth: 16,\n // 5d 000000100000\n // 5A 000000001000\n nonPerfectFifths: 40,\n anySeventh: 3,\n};\n\nconst testChromaNumber = (bitmask: number) => (chromaNumber: number) =>\n Boolean(chromaNumber & bitmask);\nconst hasAnyThird = testChromaNumber(BITMASK.anyThirds);\nconst hasPerfectFifth = testChromaNumber(BITMASK.perfectFifth);\nconst hasAnySeventh = testChromaNumber(BITMASK.anySeventh);\nconst hasNonPerfectFifth = testChromaNumber(BITMASK.nonPerfectFifths);\n\nfunction hasAnyThirdAndPerfectFifthAndAnySeventh(chordType: ChordType) {\n const chromaNumber = parseInt(chordType.chroma, 2);\n return (\n hasAnyThird(chromaNumber) &&\n hasPerfectFifth(chromaNumber) &&\n hasAnySeventh(chromaNumber)\n );\n}\n\nfunction withPerfectFifth(chroma: string): string {\n const chromaNumber = parseInt(chroma, 2);\n return hasNonPerfectFifth(chromaNumber)\n ? chroma\n : (chromaNumber | 16).toString(2);\n}\n\n/* tslint:enable:no-bitwise */\n\ntype FindMatchesOptions = {\n assumePerfectFifth: boolean;\n};\nfunction findMatches(\n notes: string[],\n weight: number,\n options: Partial,\n): FoundChord[] {\n const tonic = notes[0];\n const tonicChroma = note(tonic).chroma;\n const noteName = namedSet(notes);\n // we need to test all chromas to get the correct baseNote\n const allModes = modes(notes, false);\n\n const found: FoundChord[] = [];\n allModes.forEach((mode, index) => {\n const modeWithPerfectFifth =\n options.assumePerfectFifth && withPerfectFifth(mode);\n // some chords could have the same chroma but different interval spelling\n const chordTypes = all().filter((chordType) => {\n if (\n options.assumePerfectFifth &&\n hasAnyThirdAndPerfectFifthAndAnySeventh(chordType)\n ) {\n return chordType.chroma === modeWithPerfectFifth;\n }\n return chordType.chroma === mode;\n });\n\n chordTypes.forEach((chordType) => {\n const chordName = chordType.aliases[0];\n const baseNote = noteName(index);\n const isInversion = index !== tonicChroma;\n if (isInversion) {\n found.push({\n weight: 0.5 * weight,\n name: `${baseNote}${chordName}/${tonic}`,\n });\n } else {\n found.push({ weight: 1 * weight, name: `${baseNote}${chordName}` });\n }\n });\n });\n\n return found;\n}\n\nexport default { detect };\n", "import { IntervalCoordinates, NoteCoordinates } from \"@tonaljs/pitch\";\nimport { distance as dist } from \"@tonaljs/pitch-distance\";\nimport {\n IntervalName,\n coordToInterval,\n interval as props,\n} from \"@tonaljs/pitch-interval\";\n\n/**\n * Get the natural list of names\n */\nexport function names(): IntervalName[] {\n return \"1P 2M 3M 4P 5P 6m 7m\".split(\" \");\n}\n\n/**\n * Get properties of an interval\n *\n * @function\n * @example\n * Interval.get('P4') // => {\"alt\": 0, \"dir\": 1, \"name\": \"4P\", \"num\": 4, \"oct\": 0, \"q\": \"P\", \"semitones\": 5, \"simple\": 4, \"step\": 3, \"type\": \"perfectable\"}\n */\nexport const get = props;\n\n/**\n * Get name of an interval\n *\n * @function\n * @example\n * Interval.name('4P') // => \"4P\"\n * Interval.name('P4') // => \"4P\"\n * Interval.name('C4') // => \"\"\n */\nexport const name = (name: string) => props(name).name;\n\n/**\n * Get semitones of an interval\n * @function\n * @example\n * Interval.semitones('P4') // => 5\n */\nexport const semitones = (name: string) => props(name).semitones;\n\n/**\n * Get quality of an interval\n * @function\n * @example\n * Interval.quality('P4') // => \"P\"\n */\nexport const quality = (name: string) => props(name).q;\n\n/**\n * Get number of an interval\n * @function\n * @example\n * Interval.num('P4') // => 4\n */\nexport const num = (name: string) => props(name).num;\n\n/**\n * Get the simplified version of an interval.\n *\n * @function\n * @param {string} interval - the interval to simplify\n * @return {string} the simplified interval\n *\n * @example\n * Interval.simplify(\"9M\") // => \"2M\"\n * Interval.simplify(\"2M\") // => \"2M\"\n * Interval.simplify(\"-2M\") // => \"7m\"\n * [\"8P\", \"9M\", \"10M\", \"11P\", \"12P\", \"13M\", \"14M\", \"15P\"].map(Interval.simplify)\n * // => [ \"8P\", \"2M\", \"3M\", \"4P\", \"5P\", \"6M\", \"7M\", \"8P\" ]\n */\nexport function simplify(name: IntervalName): IntervalName {\n const i = props(name);\n return i.empty ? \"\" : i.simple + i.q;\n}\n\n/**\n * Get the inversion (https://en.wikipedia.org/wiki/Inversion_(music)#Intervals)\n * of an interval.\n *\n * @function\n * @param {string} interval - the interval to invert in interval shorthand\n * notation or interval array notation\n * @return {string} the inverted interval\n *\n * @example\n * Interval.invert(\"3m\") // => \"6M\"\n * Interval.invert(\"2M\") // => \"7m\"\n */\nexport function invert(name: IntervalName): IntervalName {\n const i = props(name);\n if (i.empty) {\n return \"\";\n }\n const step = (7 - i.step) % 7;\n const alt = i.type === \"perfectable\" ? -i.alt : -(i.alt + 1);\n return props({ step, alt, oct: i.oct, dir: i.dir }).name;\n}\n\n// interval numbers\nconst IN = [1, 2, 2, 3, 3, 4, 5, 5, 6, 6, 7, 7];\n// interval qualities\nconst IQ = \"P m M m M P d P m M m M\".split(\" \");\n\n/**\n * Get interval name from semitones number. Since there are several interval\n * names for the same number, the name it's arbitrary, but deterministic.\n *\n * @param {Integer} num - the number of semitones (can be negative)\n * @return {string} the interval name\n * @example\n * Interval.fromSemitones(7) // => \"5P\"\n * Interval.fromSemitones(-7) // => \"-5P\"\n */\nexport function fromSemitones(semitones: number): IntervalName {\n const d = semitones < 0 ? -1 : 1;\n const n = Math.abs(semitones);\n const c = n % 12;\n const o = Math.floor(n / 12);\n return d * (IN[c] + 7 * o) + IQ[c];\n}\n\n/**\n * Find interval between two notes\n *\n * @example\n * Interval.distance(\"C4\", \"G4\"); // => \"5P\"\n */\nexport const distance = dist;\n\n/**\n * Adds two intervals\n *\n * @function\n * @param {string} interval1\n * @param {string} interval2\n * @return {string} the added interval name\n * @example\n * Interval.add(\"3m\", \"5P\") // => \"7m\"\n */\nexport const add = combinator((a, b) => [a[0] + b[0], a[1] + b[1]]);\n\n/**\n * Returns a function that adds an interval\n *\n * @function\n * @example\n * ['1P', '2M', '3M'].map(Interval.addTo('5P')) // => [\"5P\", \"6M\", \"7M\"]\n */\nexport const addTo = (interval: string) => (other: string) =>\n add(interval, other);\n\n/**\n * Subtracts two intervals\n *\n * @function\n * @param {string} minuendInterval\n * @param {string} subtrahendInterval\n * @return {string} the subtracted interval name\n * @example\n * Interval.subtract('5P', '3M') // => '3m'\n * Interval.subtract('3M', '5P') // => '-3m'\n */\nexport const subtract = combinator((a, b) => [a[0] - b[0], a[1] - b[1]]);\n\nexport function transposeFifths(\n interval: IntervalName,\n fifths: number,\n): IntervalName {\n const ivl = get(interval);\n if (ivl.empty) return \"\";\n\n const [nFifths, nOcts, dir] = ivl.coord;\n return coordToInterval([nFifths + fifths, nOcts, dir]).name;\n}\n\nexport default {\n names,\n get,\n name,\n num,\n semitones,\n quality,\n fromSemitones,\n distance,\n invert,\n simplify,\n add,\n addTo,\n subtract,\n transposeFifths,\n};\n\n//// PRIVATE ////\n\ntype Operation = (\n a: IntervalCoordinates,\n b: IntervalCoordinates,\n) => NoteCoordinates;\n\nfunction combinator(fn: Operation) {\n return (a: IntervalName, b: IntervalName): IntervalName | undefined => {\n const coordA = props(a).coord;\n const coordB = props(b).coord;\n if (coordA && coordB) {\n const coord = fn(coordA, coordB);\n return coordToInterval(coord).name;\n }\n };\n}\n", "import { deprecate } from \"@tonaljs/core\";\nimport {\n EmptyPcset,\n get as pcset,\n Pcset,\n PcsetChroma,\n PcsetNum,\n} from \"@tonaljs/pcset\";\nimport data from \"./data\";\n\n/**\n * Properties for a scale in the scale dictionary. It's a pitch class set\n * properties with the following additional information:\n * - name: the scale name\n * - aliases: alternative list of names\n * - intervals: an array of interval names\n */\nexport interface ScaleType extends Pcset {\n readonly name: string;\n readonly aliases: string[];\n}\n\nexport const NoScaleType: ScaleType = {\n ...EmptyPcset,\n intervals: [],\n aliases: [],\n};\n\ntype ScaleTypeName = string | PcsetChroma | PcsetNum;\n\nlet dictionary: ScaleType[] = [];\nlet index: Record = {};\n\nexport function names() {\n return dictionary.map((scale) => scale.name);\n}\n\n/**\n * Given a scale name or chroma, return the scale properties\n *\n * @param {string} type - scale name or pitch class set chroma\n * @example\n * import { get } from 'tonaljs/scale-type'\n * get('major') // => { name: 'major', ... }\n */\nexport function get(type: ScaleTypeName): ScaleType {\n return index[type] || NoScaleType;\n}\n\nexport const scaleType = deprecate(\n \"ScaleDictionary.scaleType\",\n \"ScaleType.get\",\n get,\n);\n\n/**\n * Return a list of all scale types\n */\nexport function all() {\n return dictionary.slice();\n}\n\nexport const entries = deprecate(\n \"ScaleDictionary.entries\",\n \"ScaleType.all\",\n all,\n);\n\n/**\n * Keys used to reference scale types\n */\nexport function keys() {\n return Object.keys(index);\n}\n\n/**\n * Clear the dictionary\n */\nexport function removeAll() {\n dictionary = [];\n index = {};\n}\n\n/**\n * Add a scale into dictionary\n * @param intervals\n * @param name\n * @param aliases\n */\nexport function add(\n intervals: string[],\n name: string,\n aliases: string[] = [],\n): ScaleType {\n const scale = { ...pcset(intervals), name, intervals, aliases };\n dictionary.push(scale);\n index[scale.name] = scale;\n index[scale.setNum] = scale;\n index[scale.chroma] = scale;\n scale.aliases.forEach((alias) => addAlias(scale, alias));\n return scale;\n}\n\nexport function addAlias(scale: ScaleType, alias: string) {\n index[alias] = scale;\n}\n\ndata.forEach(([ivls, name, ...aliases]: string[]) =>\n add(ivls.split(\" \"), name, aliases),\n);\n\nexport default {\n names,\n get,\n all,\n add,\n removeAll,\n keys,\n\n // deprecated\n entries,\n scaleType,\n};\n", "// SCALES\n// Format: [\"intervals\", \"name\", \"alias1\", \"alias2\", ...]\nconst SCALES: string[][] = [\n // Basic scales\n [\"1P 2M 3M 5P 6M\", \"major pentatonic\", \"pentatonic\"],\n [\"1P 2M 3M 4P 5P 6M 7M\", \"major\", \"ionian\"],\n [\"1P 2M 3m 4P 5P 6m 7m\", \"minor\", \"aeolian\"],\n\n // Jazz common scales\n [\"1P 2M 3m 3M 5P 6M\", \"major blues\"],\n [\"1P 3m 4P 5d 5P 7m\", \"minor blues\", \"blues\"],\n [\"1P 2M 3m 4P 5P 6M 7M\", \"melodic minor\"],\n [\"1P 2M 3m 4P 5P 6m 7M\", \"harmonic minor\"],\n [\"1P 2M 3M 4P 5P 6M 7m 7M\", \"bebop\"],\n [\"1P 2M 3m 4P 5d 6m 6M 7M\", \"diminished\", \"whole-half diminished\"],\n\n // Modes\n [\"1P 2M 3m 4P 5P 6M 7m\", \"dorian\"],\n [\"1P 2M 3M 4A 5P 6M 7M\", \"lydian\"],\n [\"1P 2M 3M 4P 5P 6M 7m\", \"mixolydian\", \"dominant\"],\n [\"1P 2m 3m 4P 5P 6m 7m\", \"phrygian\"],\n [\"1P 2m 3m 4P 5d 6m 7m\", \"locrian\"],\n\n // 5-note scales\n [\"1P 3M 4P 5P 7M\", \"ionian pentatonic\"],\n [\"1P 3M 4P 5P 7m\", \"mixolydian pentatonic\", \"indian\"],\n [\"1P 2M 4P 5P 6M\", \"ritusen\"],\n [\"1P 2M 4P 5P 7m\", \"egyptian\"],\n [\"1P 3M 4P 5d 7m\", \"neopolitan major pentatonic\"],\n [\"1P 3m 4P 5P 6m\", \"vietnamese 1\"],\n [\"1P 2m 3m 5P 6m\", \"pelog\"],\n [\"1P 2m 4P 5P 6m\", \"kumoijoshi\"],\n [\"1P 2M 3m 5P 6m\", \"hirajoshi\"],\n [\"1P 2m 4P 5d 7m\", \"iwato\"],\n [\"1P 2m 4P 5P 7m\", \"in-sen\"],\n [\"1P 3M 4A 5P 7M\", \"lydian pentatonic\", \"chinese\"],\n [\"1P 3m 4P 6m 7m\", \"malkos raga\"],\n [\"1P 3m 4P 5d 7m\", \"locrian pentatonic\", \"minor seven flat five pentatonic\"],\n [\"1P 3m 4P 5P 7m\", \"minor pentatonic\", \"vietnamese 2\"],\n [\"1P 3m 4P 5P 6M\", \"minor six pentatonic\"],\n [\"1P 2M 3m 5P 6M\", \"flat three pentatonic\", \"kumoi\"],\n [\"1P 2M 3M 5P 6m\", \"flat six pentatonic\"],\n [\"1P 2m 3M 5P 6M\", \"scriabin\"],\n [\"1P 3M 5d 6m 7m\", \"whole tone pentatonic\"],\n [\"1P 3M 4A 5A 7M\", \"lydian #5P pentatonic\"],\n [\"1P 3M 4A 5P 7m\", \"lydian dominant pentatonic\"],\n [\"1P 3m 4P 5P 7M\", \"minor #7M pentatonic\"],\n [\"1P 3m 4d 5d 7m\", \"super locrian pentatonic\"],\n\n // 6-note scales\n [\"1P 2M 3m 4P 5P 7M\", \"minor hexatonic\"],\n [\"1P 2A 3M 5P 5A 7M\", \"augmented\"],\n [\"1P 2M 4P 5P 6M 7m\", \"piongio\"],\n [\"1P 2m 3M 4A 6M 7m\", \"prometheus neopolitan\"],\n [\"1P 2M 3M 4A 6M 7m\", \"prometheus\"],\n [\"1P 2m 3M 5d 6m 7m\", \"mystery #1\"],\n [\"1P 2m 3M 4P 5A 6M\", \"six tone symmetric\"],\n [\"1P 2M 3M 4A 5A 6A\", \"whole tone\", \"messiaen's mode #1\"],\n [\"1P 2m 4P 4A 5P 7M\", \"messiaen's mode #5\"],\n\n // 7-note scales\n [\"1P 2M 3M 4P 5d 6m 7m\", \"locrian major\", \"arabian\"],\n [\"1P 2m 3M 4A 5P 6m 7M\", \"double harmonic lydian\"],\n [\n \"1P 2m 2A 3M 4A 6m 7m\",\n \"altered\",\n \"super locrian\",\n \"diminished whole tone\",\n \"pomeroy\",\n ],\n [\"1P 2M 3m 4P 5d 6m 7m\", \"locrian #2\", \"half-diminished\", \"aeolian b5\"],\n [\n \"1P 2M 3M 4P 5P 6m 7m\",\n \"mixolydian b6\",\n \"melodic minor fifth mode\",\n \"hindu\",\n ],\n [\"1P 2M 3M 4A 5P 6M 7m\", \"lydian dominant\", \"lydian b7\", \"overtone\"],\n [\"1P 2M 3M 4A 5A 6M 7M\", \"lydian augmented\"],\n [\n \"1P 2m 3m 4P 5P 6M 7m\",\n \"dorian b2\",\n \"phrygian #6\",\n \"melodic minor second mode\",\n ],\n [\n \"1P 2m 3m 4d 5d 6m 7d\",\n \"ultralocrian\",\n \"superlocrian bb7\",\n \"superlocrian diminished\",\n ],\n [\"1P 2m 3m 4P 5d 6M 7m\", \"locrian 6\", \"locrian natural 6\", \"locrian sharp 6\"],\n [\"1P 2A 3M 4P 5P 5A 7M\", \"augmented heptatonic\"],\n // Source https://en.wikipedia.org/wiki/Ukrainian_Dorian_scale\n [\n \"1P 2M 3m 4A 5P 6M 7m\",\n \"dorian #4\",\n \"ukrainian dorian\",\n \"romanian minor\",\n \"altered dorian\",\n ],\n [\"1P 2M 3m 4A 5P 6M 7M\", \"lydian diminished\"],\n [\"1P 2M 3M 4A 5A 7m 7M\", \"leading whole tone\"],\n [\"1P 2M 3M 4A 5P 6m 7m\", \"lydian minor\"],\n [\"1P 2m 3M 4P 5P 6m 7m\", \"phrygian dominant\", \"spanish\", \"phrygian major\"],\n [\"1P 2m 3m 4P 5P 6m 7M\", \"balinese\"],\n [\"1P 2m 3m 4P 5P 6M 7M\", \"neopolitan major\"],\n [\"1P 2M 3M 4P 5P 6m 7M\", \"harmonic major\"],\n [\"1P 2m 3M 4P 5P 6m 7M\", \"double harmonic major\", \"gypsy\"],\n [\"1P 2M 3m 4A 5P 6m 7M\", \"hungarian minor\"],\n [\"1P 2A 3M 4A 5P 6M 7m\", \"hungarian major\"],\n [\"1P 2m 3M 4P 5d 6M 7m\", \"oriental\"],\n [\"1P 2m 3m 3M 4A 5P 7m\", \"flamenco\"],\n [\"1P 2m 3m 4A 5P 6m 7M\", \"todi raga\"],\n [\"1P 2m 3M 4P 5d 6m 7M\", \"persian\"],\n [\"1P 2m 3M 5d 6m 7m 7M\", \"enigmatic\"],\n [\n \"1P 2M 3M 4P 5A 6M 7M\",\n \"major augmented\",\n \"major #5\",\n \"ionian augmented\",\n \"ionian #5\",\n ],\n [\"1P 2A 3M 4A 5P 6M 7M\", \"lydian #9\"],\n\n // 8-note scales\n [\"1P 2m 2M 4P 4A 5P 6m 7M\", \"messiaen's mode #4\"],\n [\"1P 2m 3M 4P 4A 5P 6m 7M\", \"purvi raga\"],\n [\"1P 2m 3m 3M 4P 5P 6m 7m\", \"spanish heptatonic\"],\n [\"1P 2M 3m 3M 4P 5P 6M 7m\", \"bebop minor\"],\n [\"1P 2M 3M 4P 5P 5A 6M 7M\", \"bebop major\"],\n [\"1P 2m 3m 4P 5d 5P 6m 7m\", \"bebop locrian\"],\n [\"1P 2M 3m 4P 5P 6m 7m 7M\", \"minor bebop\"],\n [\"1P 2M 3M 4P 5d 5P 6M 7M\", \"ichikosucho\"],\n [\"1P 2M 3m 4P 5P 6m 6M 7M\", \"minor six diminished\"],\n [\n \"1P 2m 3m 3M 4A 5P 6M 7m\",\n \"half-whole diminished\",\n \"dominant diminished\",\n \"messiaen's mode #2\",\n ],\n [\"1P 3m 3M 4P 5P 6M 7m 7M\", \"kafi raga\"],\n [\"1P 2M 3M 4P 4A 5A 6A 7M\", \"messiaen's mode #6\"],\n\n // 9-note scales\n [\"1P 2M 3m 3M 4P 5d 5P 6M 7m\", \"composite blues\"],\n [\"1P 2M 3m 3M 4A 5P 6m 7m 7M\", \"messiaen's mode #3\"],\n\n // 10-note scales\n [\"1P 2m 2M 3m 4P 4A 5P 6m 6M 7M\", \"messiaen's mode #7\"],\n\n // 12-note scales\n [\"1P 2m 2M 3m 3M 4P 5d 5P 6m 6M 7m 7M\", \"chromatic\"],\n];\n\nexport default SCALES;\n", "import { detect } from \"@tonaljs/chord-detect\";\nimport {\n ChordType,\n all as chordTypes,\n get as getChordType,\n} from \"@tonaljs/chord-type\";\nimport { subtract } from \"@tonaljs/interval\";\nimport { isSubsetOf, isSupersetOf } from \"@tonaljs/pcset\";\nimport {\n distance,\n tonicIntervalsTransposer,\n transpose as transposeNote,\n} from \"@tonaljs/pitch-distance\";\nimport { NoteName, note, tokenizeNote } from \"@tonaljs/pitch-note\";\nimport { all as scaleTypes } from \"@tonaljs/scale-type\";\n\nexport { detect } from \"@tonaljs/chord-detect\";\n\ntype ChordNameOrTokens =\n | string // full name to be parsed\n | [string] // only the name\n | [string, string] // tonic, name\n | [string, string, string]; // tonic, name, bass\ntype ChordNameTokens = [string, string, string]; // [TONIC, SCALE TYPE, BASS]\n\nexport interface Chord extends ChordType {\n tonic: string | null;\n type: string;\n root: string;\n bass: string;\n rootDegree: number;\n symbol: string;\n notes: NoteName[];\n}\n\nconst NoChord: Chord = {\n empty: true,\n name: \"\",\n symbol: \"\",\n root: \"\",\n bass: \"\",\n rootDegree: 0,\n type: \"\",\n tonic: null,\n setNum: NaN,\n quality: \"Unknown\",\n chroma: \"\",\n normalized: \"\",\n aliases: [],\n notes: [],\n intervals: [],\n};\n\n// 6, 64, 7, 9, 11 and 13 are consider part of the chord\n// (see https://github.com/danigb/tonal/issues/55)\n//const NUM_TYPES = /^(6|64|7|9|11|13)$/;\n/**\n * Tokenize a chord name. It returns an array with the tonic, chord type and bass\n * If not tonic is found, all the name is considered the chord name.\n *\n * This function does NOT check if the chord type exists or not. It only tries\n * to split the tonic and chord type.\n *\n * This function does NOT check if the bass is part of the chord or not but it\n * only accepts a pitch class as bass\n *\n * @function\n * @param {string} name - the chord name\n * @return {Array} an array with [tonic, type, bass]\n * @example\n * tokenize(\"Cmaj7\") // => [ \"C\", \"maj7\" ]\n * tokenize(\"C7\") // => [ \"C\", \"7\" ]\n * tokenize(\"mMaj7\") // => [ null, \"mMaj7\" ]\n * tokenize(\"Cnonsense\") // => [ null, \"nonsense\" ]\n */\nexport function tokenize(name: string): ChordNameTokens {\n const [letter, acc, oct, type] = tokenizeNote(name);\n if (letter === \"\") {\n return tokenizeBass(\"\", name);\n } else if (letter === \"A\" && type === \"ug\") {\n return tokenizeBass(\"\", \"aug\");\n } else {\n return tokenizeBass(letter + acc, oct + type);\n }\n}\n\nfunction tokenizeBass(note: string, chord: string): ChordNameTokens {\n const split = chord.split(\"/\");\n if (split.length === 1) {\n return [note, split[0], \"\"];\n }\n const [letter, acc, oct, type] = tokenizeNote(split[1]);\n // Only a pitch class is accepted as bass note\n if (letter !== \"\" && oct === \"\" && type === \"\") {\n return [note, split[0], letter + acc];\n } else {\n return [note, chord, \"\"];\n }\n}\n\n/**\n * Get a Chord from a chord name.\n */\nexport function get(src: ChordNameOrTokens): Chord {\n if (Array.isArray(src)) {\n return getChord(src[1] || \"\", src[0], src[2]);\n } else if (src === \"\") {\n return NoChord;\n } else {\n const [tonic, type, bass] = tokenize(src);\n const chord = getChord(type, tonic, bass);\n return chord.empty ? getChord(src) : chord;\n }\n}\n\n/**\n * Get chord properties\n *\n * @param typeName - the chord type name\n * @param [tonic] - Optional tonic\n * @param [root] - Optional root (requires a tonic)\n */\nexport function getChord(\n typeName: string,\n optionalTonic?: string,\n optionalBass?: string,\n): Chord {\n const type = getChordType(typeName);\n const tonic = note(optionalTonic || \"\");\n const bass = note(optionalBass || \"\");\n\n if (\n type.empty ||\n (optionalTonic && tonic.empty) ||\n (optionalBass && bass.empty)\n ) {\n return NoChord;\n }\n\n const bassInterval = distance(tonic.pc, bass.pc);\n const bassIndex = type.intervals.indexOf(bassInterval);\n const hasRoot = bassIndex >= 0;\n const root = hasRoot ? bass : note(\"\");\n const rootDegree = bassIndex === -1 ? NaN : bassIndex + 1;\n const hasBass = bass.pc && bass.pc !== tonic.pc;\n\n const intervals = Array.from(type.intervals);\n\n if (hasRoot) {\n for (let i = 1; i < rootDegree; i++) {\n const num = intervals[0][0];\n const quality = intervals[0][1];\n const newNum = parseInt(num, 10) + 7;\n intervals.push(`${newNum}${quality}`);\n intervals.shift();\n }\n } else if (hasBass) {\n const ivl = subtract(distance(tonic.pc, bass.pc), \"8P\");\n if (ivl) intervals.unshift(ivl);\n }\n\n const notes = tonic.empty\n ? []\n : intervals.map((i) => transposeNote(tonic.pc, i));\n\n typeName = type.aliases.indexOf(typeName) !== -1 ? typeName : type.aliases[0];\n const symbol = `${tonic.empty ? \"\" : tonic.pc}${typeName}${\n hasRoot && rootDegree > 1 ? \"/\" + root.pc : hasBass ? \"/\" + bass.pc : \"\"\n }`;\n const name = `${optionalTonic ? tonic.pc + \" \" : \"\"}${type.name}${\n hasRoot && rootDegree > 1\n ? \" over \" + root.pc\n : hasBass\n ? \" over \" + bass.pc\n : \"\"\n }`;\n return {\n ...type,\n name,\n symbol,\n tonic: tonic.pc,\n type: type.name,\n root: root.pc,\n bass: hasBass ? bass.pc : \"\",\n intervals,\n rootDegree,\n notes,\n };\n}\n\nexport const chord = get;\n\n/**\n * Transpose a chord name\n *\n * @param {string} chordName - the chord name\n * @return {string} the transposed chord\n *\n * @example\n * transpose('Dm7', 'P4') // => 'Gm7\n */\nexport function transpose(chordName: string, interval: string): string {\n const [tonic, type, bass] = tokenize(chordName);\n if (!tonic) {\n return chordName;\n }\n const tr = transposeNote(bass, interval);\n const slash = tr ? \"/\" + tr : \"\";\n return transposeNote(tonic, interval) + type + slash;\n}\n\n/**\n * Get all scales where the given chord fits\n *\n * @example\n * chordScales('C7b9')\n * // => [\"phrygian dominant\", \"flamenco\", \"spanish heptatonic\", \"half-whole diminished\", \"chromatic\"]\n */\nexport function chordScales(name: string): string[] {\n const s = get(name);\n const isChordIncluded = isSupersetOf(s.chroma);\n return scaleTypes()\n .filter((scale) => isChordIncluded(scale.chroma))\n .map((scale) => scale.name);\n}\n/**\n * Get all chords names that are a superset of the given one\n * (has the same notes and at least one more)\n *\n * @function\n * @example\n * extended(\"CMaj7\")\n * // => [ 'Cmaj#4', 'Cmaj7#9#11', 'Cmaj9', 'CM7add13', 'Cmaj13', 'Cmaj9#11', 'CM13#11', 'CM7b9' ]\n */\nexport function extended(chordName: string): string[] {\n const s = get(chordName);\n const isSuperset = isSupersetOf(s.chroma);\n return chordTypes()\n .filter((chord) => isSuperset(chord.chroma))\n .map((chord) => s.tonic + chord.aliases[0]);\n}\n\n/**\n * Find all chords names that are a subset of the given one\n * (has less notes but all from the given chord)\n *\n * @example\n */\nexport function reduced(chordName: string): string[] {\n const s = get(chordName);\n const isSubset = isSubsetOf(s.chroma);\n return chordTypes()\n .filter((chord) => isSubset(chord.chroma))\n .map((chord) => s.tonic + chord.aliases[0]);\n}\n\n/**\n * Return the chord notes\n */\nexport function notes(chordName: ChordNameOrTokens, tonic?: string): string[] {\n const chord = get(chordName);\n const note = tonic || chord.tonic;\n if (!note || chord.empty) return [];\n return chord.intervals.map((ivl) => transposeNote(note, ivl));\n}\n\n/**\n * Returns a function to get a note name from the scale degree.\n *\n * @example\n * [1, 2, 3, 4].map(Chord.degrees(\"C\")) => [\"C\", \"E\", \"G\", \"C\"]\n * [1, 2, 3, 4].map(Chord.degrees(\"C4\")) => [\"C4\", \"E4\", \"G4\", \"C5\"]\n */\nexport function degrees(chordName: ChordNameOrTokens, tonic?: string) {\n const chord = get(chordName);\n const note = tonic || chord.tonic;\n const transpose = tonicIntervalsTransposer(chord.intervals, note);\n return (degree: number) =>\n degree ? transpose(degree > 0 ? degree - 1 : degree) : \"\";\n}\n\n/**\n * Sames as `degree` but with 0-based index\n */\nexport function steps(chordName: ChordNameOrTokens, tonic?: string) {\n const chord = get(chordName);\n const note = tonic || chord.tonic;\n return tonicIntervalsTransposer(chord.intervals, note);\n}\n\nexport default {\n getChord,\n get,\n detect,\n chordScales,\n extended,\n reduced,\n tokenize,\n transpose,\n degrees,\n steps,\n notes,\n chord,\n};\n", "// source: https://en.wikipedia.org/wiki/Note_value\nconst DATA: [number, string, string[]][] = [\n [\n 0.125,\n \"dl\",\n [\"large\", \"duplex longa\", \"maxima\", \"octuple\", \"octuple whole\"],\n ],\n [0.25, \"l\", [\"long\", \"longa\"]],\n [0.5, \"d\", [\"double whole\", \"double\", \"breve\"]],\n [1, \"w\", [\"whole\", \"semibreve\"]],\n [2, \"h\", [\"half\", \"minim\"]],\n [4, \"q\", [\"quarter\", \"crotchet\"]],\n [8, \"e\", [\"eighth\", \"quaver\"]],\n [16, \"s\", [\"sixteenth\", \"semiquaver\"]],\n [32, \"t\", [\"thirty-second\", \"demisemiquaver\"]],\n [64, \"sf\", [\"sixty-fourth\", \"hemidemisemiquaver\"]],\n [128, \"h\", [\"hundred twenty-eighth\"]],\n [256, \"th\", [\"two hundred fifty-sixth\"]],\n];\n\nexport default DATA;\n", "import DATA from \"./data\";\n\ntype Fraction = [number, number];\n\nconst VALUES: DurationValue[] = [];\n\nDATA.forEach(([denominator, shorthand, names]) =>\n add(denominator, shorthand, names),\n);\n\nexport interface DurationValue {\n empty: boolean;\n value: number;\n name: string;\n fraction: Fraction;\n shorthand: string;\n dots: string;\n names: string[];\n}\n\nconst NoDuration: DurationValue = {\n empty: true,\n name: \"\",\n value: 0,\n fraction: [0, 0],\n shorthand: \"\",\n dots: \"\",\n names: [],\n};\n\nexport function names(): string[] {\n return VALUES.reduce((names, duration) => {\n duration.names.forEach((name) => names.push(name));\n return names;\n }, [] as string[]);\n}\n\nexport function shorthands(): string[] {\n return VALUES.map((dur) => dur.shorthand);\n}\n\nconst REGEX = /^([^.]+)(\\.*)$/;\n\nexport function get(name: string): DurationValue {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const [_, simple, dots] = REGEX.exec(name) || [];\n const base = VALUES.find(\n (dur) => dur.shorthand === simple || dur.names.includes(simple),\n );\n if (!base) {\n return NoDuration;\n }\n\n const fraction = calcDots(base.fraction, dots.length);\n const value = fraction[0] / fraction[1];\n\n return { ...base, name, dots, value, fraction };\n}\n\nexport const value = (name: string) => get(name).value;\nexport const fraction = (name: string) => get(name).fraction;\n\nexport default { names, shorthands, get, value, fraction };\n\n//// PRIVATE ////\n\nfunction add(denominator: number, shorthand: string, names: string[]) {\n VALUES.push({\n empty: false,\n dots: \"\",\n name: \"\",\n value: 1 / denominator,\n fraction: denominator < 1 ? [1 / denominator, 1] : [1, denominator],\n shorthand,\n names,\n });\n}\n\nfunction calcDots(fraction: Fraction, dots: number): Fraction {\n const pow = Math.pow(2, dots);\n\n let numerator = fraction[0] * pow;\n let denominator = fraction[1] * pow;\n const base = numerator;\n\n // add fractions\n for (let i = 0; i < dots; i++) {\n numerator += base / Math.pow(2, i + 1);\n }\n\n // simplify\n while (numerator % 2 === 0 && denominator % 2 === 0) {\n numerator /= 2;\n denominator /= 2;\n }\n return [numerator, denominator];\n}\n", "import { NoteName, note as props } from \"@tonaljs/core\";\n\ntype Midi = number;\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function isMidi(arg: any): arg is Midi {\n return +arg >= 0 && +arg <= 127;\n}\n\n/**\n * Get the note midi number (a number between 0 and 127)\n *\n * It returns undefined if not valid note name\n *\n * @function\n * @param {string|number} note - the note name or midi number\n * @return {Integer} the midi number or undefined if not valid note\n * @example\n * import { toMidi } from '@tonaljs/midi'\n * toMidi(\"C4\") // => 60\n * toMidi(60) // => 60\n * toMidi('60') // => 60\n */\nexport function toMidi(note: NoteName | number): number | null {\n if (isMidi(note)) {\n return +note;\n }\n const n = props(note);\n return n.empty ? null : n.midi;\n}\n\n/**\n * Get the frequency in hertzs from midi number\n *\n * @param {number} midi - the note midi number\n * @param {number} [tuning = 440] - A4 tuning frequency in Hz (440 by default)\n * @return {number} the frequency or null if not valid note midi\n * @example\n * import { midiToFreq} from '@tonaljs/midi'\n * midiToFreq(69) // => 440\n */\nexport function midiToFreq(midi: number, tuning = 440): number {\n return Math.pow(2, (midi - 69) / 12) * tuning;\n}\n\nconst L2 = Math.log(2);\nconst L440 = Math.log(440);\n\n/**\n * Get the midi number from a frequency in hertz. The midi number can\n * contain decimals (with two digits precision)\n *\n * @param {number} frequency\n * @return {number}\n * @example\n * import { freqToMidi} from '@tonaljs/midi'\n * freqToMidi(220)); //=> 57\n * freqToMidi(261.62)); //=> 60\n * freqToMidi(261)); //=> 59.96\n */\nexport function freqToMidi(freq: number): number {\n const v = (12 * (Math.log(freq) - L440)) / L2 + 69;\n return Math.round(v * 100) / 100;\n}\n\nexport interface ToNoteNameOptions {\n pitchClass?: boolean;\n sharps?: boolean;\n}\n\nconst SHARPS = \"C C# D D# E F F# G G# A A# B\".split(\" \");\nconst FLATS = \"C Db D Eb E F Gb G Ab A Bb B\".split(\" \");\n/**\n * Given a midi number, returns a note name. The altered notes will have\n * flats unless explicitly set with the optional `useSharps` parameter.\n *\n * @function\n * @param {number} midi - the midi note number\n * @param {Object} options = default: `{ sharps: false, pitchClass: false }`\n * @param {boolean} useSharps - (Optional) set to true to use sharps instead of flats\n * @return {string} the note name\n * @example\n * import { midiToNoteName } from '@tonaljs/midi'\n * midiToNoteName(61) // => \"Db4\"\n * midiToNoteName(61, { pitchClass: true }) // => \"Db\"\n * midiToNoteName(61, { sharps: true }) // => \"C#4\"\n * midiToNoteName(61, { pitchClass: true, sharps: true }) // => \"C#\"\n * // it rounds to nearest note\n * midiToNoteName(61.7) // => \"D4\"\n */\nexport function midiToNoteName(midi: number, options: ToNoteNameOptions = {}) {\n if (isNaN(midi) || midi === -Infinity || midi === Infinity) return \"\";\n midi = Math.round(midi);\n const pcs = options.sharps === true ? SHARPS : FLATS;\n const pc = pcs[midi % 12];\n if (options.pitchClass) {\n return pc;\n }\n const o = Math.floor(midi / 12) - 1;\n return pc + o;\n}\n\nexport function chroma(midi: number): number {\n return midi % 12;\n}\n\nfunction pcsetFromChroma(chroma: string): number[] {\n return chroma.split(\"\").reduce((pcset, val, index) => {\n if (index < 12 && val === \"1\") pcset.push(index);\n return pcset;\n }, [] as number[]);\n}\n\nfunction pcsetFromMidi(midi: number[]): number[] {\n return midi\n .map(chroma)\n .sort((a, b) => a - b)\n .filter((n, i, a) => i === 0 || n !== a[i - 1]);\n}\n\n/**\n * Given a list of midi numbers, returns the pitch class set (unique chroma numbers)\n * @param midi\n * @example\n *\n */\nexport function pcset(notes: number[] | string): number[] {\n return Array.isArray(notes) ? pcsetFromMidi(notes) : pcsetFromChroma(notes);\n}\n\nexport function pcsetNearest(notes: number[] | string) {\n const set = pcset(notes);\n return (midi: number): number | undefined => {\n const ch = chroma(midi);\n for (let i = 0; i < 12; i++) {\n if (set.includes(ch + i)) return midi + i;\n if (set.includes(ch - i)) return midi - i;\n }\n return undefined;\n };\n}\n\nexport function pcsetSteps(notes: number[] | string, tonic: number) {\n const set = pcset(notes);\n const len = set.length;\n return (step: number): number => {\n const index = step < 0 ? (len - (-step % len)) % len : step % len;\n const octaves = Math.floor(step / len);\n return set[index] + octaves * 12 + tonic;\n };\n}\n\nexport function pcsetDegrees(notes: number[] | string, tonic: number) {\n const steps = pcsetSteps(notes, tonic);\n return (degree: number): number | undefined => {\n if (degree === 0) return undefined;\n return steps(degree > 0 ? degree - 1 : degree);\n };\n}\n\nexport default {\n chroma,\n freqToMidi,\n isMidi,\n midiToFreq,\n midiToNoteName,\n pcsetNearest,\n pcset,\n pcsetDegrees,\n pcsetSteps,\n toMidi,\n};\n", "/* eslint-disable @typescript-eslint/no-explicit-any */\nimport {\n IntervalName,\n Note,\n NoteLiteral,\n NoteName,\n Pitch,\n transpose as _tr,\n note as props,\n} from \"@tonaljs/core\";\nimport { freqToMidi, midiToNoteName } from \"@tonaljs/midi\";\n\nconst NAMES = [\"C\", \"D\", \"E\", \"F\", \"G\", \"A\", \"B\"];\n\nconst toName = (n: Note) => n.name;\nconst onlyNotes = (array: any[]) =>\n array.map(props).filter((n) => !n.empty) as Note[];\n\n/**\n * Return the natural note names without octave\n * @function\n * @example\n * Note.names(); // => [\"C\", \"D\", \"E\", \"F\", \"G\", \"A\", \"B\"]\n */\nexport function names(array?: any[]): string[] {\n if (array === undefined) {\n return NAMES.slice();\n } else if (!Array.isArray(array)) {\n return [];\n } else {\n return onlyNotes(array).map(toName);\n }\n}\n\n/**\n * Get a note from a note name\n *\n * @function\n * @example\n * Note.get('Bb4') // => { name: \"Bb4\", midi: 70, chroma: 10, ... }\n */\nexport const get = props;\n\n/**\n * Get the note name\n * @function\n */\nexport const name = (note: NoteLiteral) => get(note).name;\n\n/**\n * Get the note pitch class name\n * @function\n */\nexport const pitchClass = (note: NoteLiteral) => get(note).pc;\n\n/**\n * Get the note accidentals\n * @function\n */\nexport const accidentals = (note: NoteLiteral) => get(note).acc;\n\n/**\n * Get the note octave\n * @function\n */\nexport const octave = (note: NoteLiteral) => get(note).oct;\n\n/**\n * Get the note midi\n * @function\n */\nexport const midi = (note: NoteLiteral) => get(note).midi;\n\n/**\n * Get the note midi\n * @function\n */\nexport const freq = (note: NoteLiteral) => get(note).freq;\n\n/**\n * Get the note chroma\n * @function\n */\nexport const chroma = (note: NoteLiteral) => get(note).chroma;\n\n/**\n * Given a midi number, returns a note name. Uses flats for altered notes.\n *\n * @function\n * @param {number} midi - the midi note number\n * @return {string} the note name\n * @example\n * Note.fromMidi(61) // => \"Db4\"\n * Note.fromMidi(61.7) // => \"D4\"\n */\nexport function fromMidi(midi: number) {\n return midiToNoteName(midi);\n}\n\n/**\n * Given a midi number, returns a note name. Uses flats for altered notes.\n */\nexport function fromFreq(freq: number) {\n return midiToNoteName(freqToMidi(freq));\n}\n/**\n * Given a midi number, returns a note name. Uses flats for altered notes.\n */\nexport function fromFreqSharps(freq: number) {\n return midiToNoteName(freqToMidi(freq), { sharps: true });\n}\n\n/**\n * Given a midi number, returns a note name. Uses flats for altered notes.\n *\n * @function\n * @param {number} midi - the midi note number\n * @return {string} the note name\n * @example\n * Note.fromMidiSharps(61) // => \"C#4\"\n */\n\nexport function fromMidiSharps(midi: number) {\n return midiToNoteName(midi, { sharps: true });\n}\n\n/**\n * Transpose a note by an interval\n */\nexport const transpose = _tr;\nexport const tr = _tr;\n\n/**\n * Transpose by an interval.\n * @function\n * @param {string} interval\n * @return {function} a function that transposes by the given interval\n * @example\n * [\"C\", \"D\", \"E\"].map(Note.transposeBy(\"5P\"));\n * // => [\"G\", \"A\", \"B\"]\n */\nexport const transposeBy = (interval: IntervalName) => (note: NoteName) =>\n transpose(note, interval);\nexport const trBy = transposeBy;\n\n/**\n * Transpose from a note\n * @function\n * @param {string} note\n * @return {function} a function that transposes the the note by an interval\n * [\"1P\", \"3M\", \"5P\"].map(Note.transposeFrom(\"C\"));\n * // => [\"C\", \"E\", \"G\"]\n */\nexport const transposeFrom = (note: NoteName) => (interval: IntervalName) =>\n transpose(note, interval);\nexport const trFrom = transposeFrom;\n\n/**\n * Transpose a note by a number of perfect fifths.\n *\n * @function\n * @param {string} note - the note name\n * @param {number} fifhts - the number of fifths\n * @return {string} the transposed note name\n *\n * @example\n * import { transposeFifths } from \"@tonaljs/note\"\n * transposeFifths(\"G4\", 1) // => \"D\"\n * [0, 1, 2, 3, 4].map(fifths => transposeFifths(\"C\", fifths)) // => [\"C\", \"G\", \"D\", \"A\", \"E\"]\n */\nexport function transposeFifths(noteName: NoteName, fifths: number): NoteName {\n return transpose(noteName, [fifths, 0]);\n}\nexport const trFifths = transposeFifths;\n\n// TODO: documentation\nexport function transposeOctaves(\n noteName: NoteName,\n octaves: number,\n): NoteName {\n return transpose(noteName, [0, octaves]);\n}\n\nexport type NoteComparator = (a: Note, b: Note) => number;\n\nexport const ascending: NoteComparator = (a, b) => a.height - b.height;\nexport const descending: NoteComparator = (a, b) => b.height - a.height;\n\nexport function sortedNames(\n notes: any[],\n comparator?: NoteComparator,\n): string[] {\n comparator = comparator || ascending;\n return onlyNotes(notes).sort(comparator).map(toName);\n}\n\nexport function sortedUniqNames(notes: any[]): string[] {\n return sortedNames(notes, ascending).filter(\n (n, i, a) => i === 0 || n !== a[i - 1],\n );\n}\n\n/**\n * Simplify a note\n *\n * @function\n * @param {string} note - the note to be simplified\n * - sameAccType: default true. Use same kind of accidentals that source\n * @return {string} the simplified note or '' if not valid note\n * @example\n * simplify(\"C##\") // => \"D\"\n * simplify(\"C###\") // => \"D#\"\n * simplify(\"C###\")\n * simplify(\"B#4\") // => \"C5\"\n */\nexport const simplify = (noteName: NoteName | Pitch): string => {\n const note = get(noteName);\n if (note.empty) {\n return \"\";\n }\n return midiToNoteName(note.midi || note.chroma, {\n sharps: note.alt > 0,\n pitchClass: note.midi === null,\n });\n};\n/**\n * Get enharmonic of a note\n *\n * @function\n * @param {string} note\n * @param [string] - [optional] Destination pitch class\n * @return {string} the enharmonic note name or '' if not valid note\n * @example\n * Note.enharmonic(\"Db\") // => \"C#\"\n * Note.enharmonic(\"C\") // => \"C\"\n * Note.enharmonic(\"F2\",\"E#\") // => \"E#2\"\n */\nexport function enharmonic(noteName: string, destName?: string) {\n const src = get(noteName);\n if (src.empty) {\n return \"\";\n }\n\n // destination: use given or generate one\n const dest = get(\n destName ||\n midiToNoteName(src.midi || src.chroma, {\n sharps: src.alt < 0,\n pitchClass: true,\n }),\n );\n\n // ensure destination is valid\n if (dest.empty || dest.chroma !== src.chroma) {\n return \"\";\n }\n\n // if src has no octave, no need to calculate anything else\n if (src.oct === undefined) {\n return dest.pc;\n }\n\n // detect any octave overflow\n const srcChroma = src.chroma - src.alt;\n const destChroma = dest.chroma - dest.alt;\n const destOctOffset =\n srcChroma > 11 || destChroma < 0\n ? -1\n : srcChroma < 0 || destChroma > 11\n ? +1\n : 0;\n // calculate the new octave\n const destOct = src.oct + destOctOffset;\n return dest.pc + destOct;\n}\n\nexport default {\n names,\n get,\n name,\n pitchClass,\n accidentals,\n octave,\n midi,\n ascending,\n descending,\n sortedNames,\n sortedUniqNames,\n fromMidi,\n fromMidiSharps,\n freq,\n fromFreq,\n fromFreqSharps,\n chroma,\n transpose,\n tr,\n transposeBy,\n trBy,\n transposeFrom,\n trFrom,\n transposeFifths,\n transposeOctaves,\n trFifths,\n simplify,\n enharmonic,\n};\n", "import {\n accToAlt,\n altToAcc,\n deprecate,\n interval,\n isNamed,\n isPitch,\n Pitch,\n} from \"@tonaljs/core\";\n\nexport interface RomanNumeral extends Pitch {\n readonly name: string;\n readonly empty: boolean;\n readonly roman: string;\n readonly interval: string;\n readonly acc: string;\n readonly chordType: string;\n readonly major: boolean;\n readonly dir: 1;\n}\n\nexport interface NoRomanNumeral extends Partial {\n readonly empty: true;\n readonly name: \"\";\n readonly chordType: \"\";\n}\nconst NoRomanNumeral: NoRomanNumeral = { empty: true, name: \"\", chordType: \"\" };\n\nconst cache: Record = {};\n\n/**\n * Get properties of a roman numeral string\n *\n * @function\n * @param {string} - the roman numeral string (can have type, like: Imaj7)\n * @return {Object} - the roman numeral properties\n * @param {string} name - the roman numeral (tonic)\n * @param {string} type - the chord type\n * @param {string} num - the number (1 = I, 2 = II...)\n * @param {boolean} major - major or not\n *\n * @example\n * romanNumeral(\"VIIb5\") // => { name: \"VII\", type: \"b5\", num: 7, major: true }\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function get(src: any): RomanNumeral | NoRomanNumeral {\n return typeof src === \"string\"\n ? cache[src] || (cache[src] = parse(src))\n : typeof src === \"number\"\n ? get(NAMES[src] || \"\")\n : isPitch(src)\n ? fromPitch(src)\n : isNamed(src)\n ? get(src.name)\n : NoRomanNumeral;\n}\n\nconst romanNumeral = deprecate(\n \"RomanNumeral.romanNumeral\",\n \"RomanNumeral.get\",\n get,\n);\n\n/**\n * Get roman numeral names\n *\n * @function\n * @param {boolean} [isMajor=true]\n * @return {Array}\n *\n * @example\n * names() // => [\"I\", \"II\", \"III\", \"IV\", \"V\", \"VI\", \"VII\"]\n */\nexport function names(major = true) {\n return (major ? NAMES : NAMES_MINOR).slice();\n}\n\nfunction fromPitch(pitch: Pitch): RomanNumeral | NoRomanNumeral {\n return get(altToAcc(pitch.alt) + NAMES[pitch.step]);\n}\n\nconst REGEX =\n /^(#{1,}|b{1,}|x{1,}|)(IV|I{1,3}|VI{0,2}|iv|i{1,3}|vi{0,2})([^IViv]*)$/;\n\n// [name, accidentals, romanNumeral, chordType]\ntype RomanNumeralTokens = [string, string, string, string];\nexport function tokenize(str: string): RomanNumeralTokens {\n return (REGEX.exec(str) || [\"\", \"\", \"\", \"\"]) as RomanNumeralTokens;\n}\n\nconst ROMANS = \"I II III IV V VI VII\";\nconst NAMES = ROMANS.split(\" \");\nconst NAMES_MINOR = ROMANS.toLowerCase().split(\" \");\n\nfunction parse(src: string): RomanNumeral | NoRomanNumeral {\n const [name, acc, roman, chordType] = tokenize(src);\n if (!roman) {\n return NoRomanNumeral;\n }\n\n const upperRoman = roman.toUpperCase();\n const step = NAMES.indexOf(upperRoman);\n const alt = accToAlt(acc);\n const dir = 1;\n return {\n empty: false,\n name,\n roman,\n interval: interval({ step, alt, dir }).name,\n acc,\n chordType,\n alt,\n step,\n major: roman === upperRoman,\n oct: 0,\n dir,\n };\n}\n\nexport default {\n names,\n get,\n // deprecated\n romanNumeral,\n};\n", "import { accToAlt, altToAcc, note, transpose } from \"@tonaljs/core\";\nimport { transposeFifths } from \"@tonaljs/note\";\nimport { get as roman } from \"@tonaljs/roman-numeral\";\n\nconst Empty: readonly string[] = Object.freeze([] as string[]);\n\nexport interface Key {\n readonly type: \"major\" | \"minor\";\n readonly tonic: string;\n readonly alteration: number;\n readonly keySignature: string;\n}\n\nconst NoKey: Key = {\n type: \"major\",\n tonic: \"\",\n alteration: 0,\n keySignature: \"\",\n};\n\nexport interface KeyScale {\n readonly tonic: string;\n readonly grades: readonly string[];\n readonly intervals: readonly string[];\n readonly scale: readonly string[];\n readonly triads: readonly string[];\n readonly chords: readonly string[];\n readonly chordsHarmonicFunction: readonly string[];\n readonly chordScales: readonly string[];\n}\n\nconst NoKeyScale: KeyScale = {\n tonic: \"\",\n grades: Empty,\n intervals: Empty,\n scale: Empty,\n triads: Empty,\n chords: Empty,\n chordsHarmonicFunction: Empty,\n chordScales: Empty,\n};\n\nexport interface MajorKey extends Key, KeyScale {\n readonly type: \"major\";\n readonly minorRelative: string;\n readonly scale: readonly string[];\n readonly secondaryDominants: readonly string[];\n readonly secondaryDominantsMinorRelative: readonly string[];\n readonly substituteDominants: readonly string[];\n readonly substituteDominantsMinorRelative: readonly string[];\n}\n\nconst NoMajorKey: MajorKey = {\n ...NoKey,\n ...NoKeyScale,\n type: \"major\",\n minorRelative: \"\",\n scale: Empty,\n secondaryDominants: Empty,\n secondaryDominantsMinorRelative: Empty,\n substituteDominants: Empty,\n substituteDominantsMinorRelative: Empty,\n};\n\nexport interface MinorKey extends Key {\n readonly type: \"minor\";\n readonly relativeMajor: string;\n readonly natural: KeyScale;\n readonly harmonic: KeyScale;\n readonly melodic: KeyScale;\n}\n\nconst NoMinorKey: MinorKey = {\n ...NoKey,\n type: \"minor\",\n relativeMajor: \"\",\n natural: NoKeyScale,\n harmonic: NoKeyScale,\n melodic: NoKeyScale,\n};\n\nconst mapScaleToType = (scale: string[], list: string[], sep = \"\") =>\n list.map((type, i) => `${scale[i]}${sep}${type}`);\n\nfunction keyScale(\n grades: string[],\n triads: string[],\n chords: string[],\n harmonicFunctions: string[],\n chordScales: string[],\n) {\n return (tonic: string): KeyScale => {\n const intervals = grades.map((gr) => roman(gr).interval || \"\");\n const scale = intervals.map((interval) => transpose(tonic, interval));\n\n return {\n tonic,\n grades,\n intervals,\n scale,\n triads: mapScaleToType(scale, triads),\n chords: mapScaleToType(scale, chords),\n chordsHarmonicFunction: harmonicFunctions.slice(),\n chordScales: mapScaleToType(scale, chordScales, \" \"),\n };\n };\n}\n\nconst distInFifths = (from: string, to: string) => {\n const f = note(from);\n const t = note(to);\n return f.empty || t.empty ? 0 : t.coord[0] - f.coord[0];\n};\n\nconst MajorScale = keyScale(\n \"I II III IV V VI VII\".split(\" \"),\n \" m m m dim\".split(\" \"),\n \"maj7 m7 m7 maj7 7 m7 m7b5\".split(\" \"),\n \"T SD T SD D T D\".split(\" \"),\n \"major,dorian,phrygian,lydian,mixolydian,minor,locrian\".split(\",\"),\n);\nconst NaturalScale = keyScale(\n \"I II bIII IV V bVI bVII\".split(\" \"),\n \"m dim m m \".split(\" \"),\n \"m7 m7b5 maj7 m7 m7 maj7 7\".split(\" \"),\n \"T SD T SD D SD SD\".split(\" \"),\n \"minor,locrian,major,dorian,phrygian,lydian,mixolydian\".split(\",\"),\n);\nconst HarmonicScale = keyScale(\n \"I II bIII IV V bVI VII\".split(\" \"),\n \"m dim aug m dim\".split(\" \"),\n \"mMaj7 m7b5 +maj7 m7 7 maj7 o7\".split(\" \"),\n \"T SD T SD D SD D\".split(\" \"),\n \"harmonic minor,locrian 6,major augmented,lydian diminished,phrygian dominant,lydian #9,ultralocrian\".split(\n \",\",\n ),\n);\nconst MelodicScale = keyScale(\n \"I II bIII IV V VI VII\".split(\" \"),\n \"m m aug dim dim\".split(\" \"),\n \"m6 m7 +maj7 7 7 m7b5 m7b5\".split(\" \"),\n \"T SD T SD D \".split(\" \"),\n \"melodic minor,dorian b2,lydian augmented,lydian dominant,mixolydian b6,locrian #2,altered\".split(\n \",\",\n ),\n);\n\n/**\n * Get a major key properties in a given tonic\n * @param tonic\n */\nexport function majorKey(tonic: string): MajorKey {\n const pc = note(tonic).pc;\n if (!pc) return NoMajorKey;\n\n const keyScale = MajorScale(pc);\n const alteration = distInFifths(\"C\", pc);\n const romanInTonic = (src: string) => {\n const r = roman(src);\n if (r.empty) return \"\";\n\n return transpose(tonic, r.interval) + r.chordType;\n };\n\n return {\n ...keyScale,\n type: \"major\",\n minorRelative: transpose(pc, \"-3m\"),\n alteration,\n keySignature: altToAcc(alteration),\n secondaryDominants: \"- VI7 VII7 I7 II7 III7 -\".split(\" \").map(romanInTonic),\n secondaryDominantsMinorRelative: \"- IIIm7b5 IV#m7 Vm7 VIm7 VIIm7b5 -\"\n .split(\" \")\n .map(romanInTonic),\n substituteDominants: \"- bIII7 IV7 bV7 bVI7 bVII7 -\"\n .split(\" \")\n .map(romanInTonic),\n substituteDominantsMinorRelative: \"- IIIm7 Im7 IIbm7 VIm7 IVm7 -\"\n .split(\" \")\n .map(romanInTonic),\n };\n}\n\n/**\n * Get minor key properties in a given tonic\n * @param tonic\n */\nexport function minorKey(tnc: string): MinorKey {\n const pc = note(tnc).pc;\n if (!pc) return NoMinorKey;\n\n const alteration = distInFifths(\"C\", pc) - 3;\n return {\n type: \"minor\",\n tonic: pc,\n relativeMajor: transpose(pc, \"3m\"),\n alteration,\n keySignature: altToAcc(alteration),\n natural: NaturalScale(pc),\n harmonic: HarmonicScale(pc),\n melodic: MelodicScale(pc),\n };\n}\n\n/**\n * Given a key signature, returns the tonic of the major key\n * @param sigature\n * @example\n * majorTonicFromKeySignature('###') // => 'A'\n */\nexport function majorTonicFromKeySignature(\n sig: string | number,\n): string | null {\n if (typeof sig === \"number\") {\n return transposeFifths(\"C\", sig);\n } else if (typeof sig === \"string\" && /^b+|#+$/.test(sig)) {\n return transposeFifths(\"C\", accToAlt(sig));\n }\n return null;\n}\n\nexport default { majorKey, majorTonicFromKeySignature, minorKey };\n", "import { rotate } from \"@tonaljs/collection\";\nimport { deprecate, NamedPitch, NoteName, transpose } from \"@tonaljs/core\";\nimport { simplify, transposeFifths } from \"@tonaljs/interval\";\nimport { EmptyPcset, Pcset } from \"@tonaljs/pcset\";\nimport { get as getType } from \"@tonaljs/scale-type\";\n\nconst MODES = [\n [0, 2773, 0, \"ionian\", \"\", \"Maj7\", \"major\"],\n [1, 2902, 2, \"dorian\", \"m\", \"m7\"],\n [2, 3418, 4, \"phrygian\", \"m\", \"m7\"],\n [3, 2741, -1, \"lydian\", \"\", \"Maj7\"],\n [4, 2774, 1, \"mixolydian\", \"\", \"7\"],\n [5, 2906, 3, \"aeolian\", \"m\", \"m7\", \"minor\"],\n [6, 3434, 5, \"locrian\", \"dim\", \"m7b5\"],\n] as const;\n\ntype ModeDatum = (typeof MODES)[number];\n\nexport interface Mode extends Pcset {\n readonly name: string;\n readonly modeNum: number;\n readonly alt: number; // number of alterations === number of fiths\n readonly triad: string;\n readonly seventh: string;\n readonly aliases: string[];\n}\n\nconst NoMode: Mode = {\n ...EmptyPcset,\n name: \"\",\n alt: 0,\n modeNum: NaN,\n triad: \"\",\n seventh: \"\",\n aliases: [],\n};\n\nconst modes: Mode[] = MODES.map(toMode);\nconst index: Record = {};\nmodes.forEach((mode) => {\n index[mode.name] = mode;\n mode.aliases.forEach((alias) => {\n index[alias] = mode;\n });\n});\n\ntype ModeLiteral = string | NamedPitch;\n\n/**\n * Get a Mode by it's name\n *\n * @example\n * get('dorian')\n * // =>\n * // {\n * // intervals: [ '1P', '2M', '3m', '4P', '5P', '6M', '7m' ],\n * // modeNum: 1,\n * // chroma: '101101010110',\n * // normalized: '101101010110',\n * // name: 'dorian',\n * // setNum: 2902,\n * // alt: 2,\n * // triad: 'm',\n * // seventh: 'm7',\n * // aliases: []\n * // }\n */\nexport function get(name: ModeLiteral): Mode {\n return typeof name === \"string\"\n ? index[name.toLowerCase()] || NoMode\n : name && name.name\n ? get(name.name)\n : NoMode;\n}\n\nexport const mode = deprecate(\"Mode.mode\", \"Mode.get\", get);\n\n/**\n * Get a list of all modes\n */\nexport function all() {\n return modes.slice();\n}\nexport const entries = deprecate(\"Mode.mode\", \"Mode.all\", all);\n\n/**\n * Get a list of all mode names\n */\nexport function names() {\n return modes.map((mode) => mode.name);\n}\n\nfunction toMode(mode: ModeDatum): Mode {\n const [modeNum, setNum, alt, name, triad, seventh, alias] = mode;\n const aliases = alias ? [alias] : [];\n const chroma = Number(setNum).toString(2);\n const intervals = getType(name).intervals;\n return {\n empty: false,\n intervals,\n modeNum,\n chroma,\n normalized: chroma,\n name,\n setNum,\n alt,\n triad,\n seventh,\n aliases,\n };\n}\n\nexport function notes(modeName: ModeLiteral, tonic: NoteName) {\n return get(modeName).intervals.map((ivl) => transpose(tonic, ivl));\n}\n\nfunction chords(chords: string[]) {\n return (modeName: ModeLiteral, tonic: NoteName) => {\n const mode = get(modeName);\n if (mode.empty) return [];\n const triads = rotate(mode.modeNum, chords);\n const tonics = mode.intervals.map((i) => transpose(tonic, i));\n return triads.map((triad, i) => tonics[i] + triad);\n };\n}\n\nexport const triads = chords(MODES.map((x) => x[4]));\nexport const seventhChords = chords(MODES.map((x) => x[5]));\n\nexport function distance(destination: ModeLiteral, source: ModeLiteral) {\n const from = get(source);\n const to = get(destination);\n if (from.empty || to.empty) return \"\";\n return simplify(transposeFifths(\"1P\", to.alt - from.alt));\n}\n\nexport function relativeTonic(\n destination: ModeLiteral,\n source: ModeLiteral,\n tonic: NoteName,\n) {\n return transpose(tonic, distance(destination, source));\n}\n\nexport default {\n get,\n names,\n all,\n distance,\n relativeTonic,\n notes,\n triads,\n seventhChords,\n // deprecated\n entries,\n mode,\n};\n", "import { tokenize } from \"@tonaljs/chord\";\nimport { distance, interval, NoteLiteral, transpose } from \"@tonaljs/core\";\nimport { get as romanNumeral } from \"@tonaljs/roman-numeral\";\n\n/**\n * Given a tonic and a chord list expressed with roman numeral notation\n * returns the progression expressed with leadsheet chords symbols notation\n * @example\n * fromRomanNumerals(\"C\", [\"I\", \"IIm7\", \"V7\"]);\n * // => [\"C\", \"Dm7\", \"G7\"]\n */\nexport function fromRomanNumerals(\n tonic: NoteLiteral,\n chords: string[],\n): string[] {\n const romanNumerals = chords.map(romanNumeral);\n return romanNumerals.map(\n (rn) => transpose(tonic, interval(rn)) + rn.chordType,\n );\n}\n\n/**\n * Given a tonic and a chord list with leadsheet symbols notation,\n * return the chord list with roman numeral notation\n * @example\n * toRomanNumerals(\"C\", [\"CMaj7\", \"Dm7\", \"G7\"]);\n * // => [\"IMaj7\", \"IIm7\", \"V7\"]\n */\nexport function toRomanNumerals(\n tonic: NoteLiteral,\n chords: string[],\n): string[] {\n return chords.map((chord) => {\n const [note, chordType] = tokenize(chord);\n const intervalName = distance(tonic, note);\n const roman = romanNumeral(interval(intervalName));\n return roman.name + chordType;\n });\n}\n\nexport default { fromRomanNumerals, toRomanNumerals };\n", "import { compact, range } from \"@tonaljs/collection\";\nimport { midiToNoteName, toMidi, ToNoteNameOptions } from \"@tonaljs/midi\";\n\n/**\n * Create a numeric range. You supply a list of notes or numbers and it will\n * be connected to create complex ranges.\n *\n * @param {Array} notes - the list of notes or midi numbers used\n * @return {Array} an array of numbers or empty array if not valid parameters\n *\n * @example\n * numeric([\"C5\", \"C4\"]) // => [ 72, 71, 70, 69, 68, 67, 66, 65, 64, 63, 62, 61, 60 ]\n * // it works midi notes\n * numeric([10, 5]) // => [ 10, 9, 8, 7, 6, 5 ]\n * // complex range\n * numeric([\"C4\", \"E4\", \"Bb3\"]) // => [60, 61, 62, 63, 64, 63, 62, 61, 60, 59, 58]\n */\nexport function numeric(notes: (string | number)[]): number[] {\n const midi: number[] = compact(\n notes.map((note) => (typeof note === \"number\" ? note : toMidi(note))),\n );\n if (!notes.length || midi.length !== notes.length) {\n // there is no valid notes\n return [];\n }\n\n return midi.reduce(\n (result, note) => {\n const last: number = result[result.length - 1];\n return result.concat(range(last, note).slice(1));\n },\n [midi[0]],\n );\n}\n\n/**\n * Create a range of chromatic notes. The altered notes will use flats.\n *\n * @function\n * @param {Array} notes - the list of notes or midi note numbers to create a range from\n * @param {Object} options - The same as `midiToNoteName` (`{ sharps: boolean, pitchClass: boolean }`)\n * @return {Array} an array of note names\n *\n * @example\n * Range.chromatic([\"C2, \"E2\", \"D2\"]) // => [\"C2\", \"Db2\", \"D2\", \"Eb2\", \"E2\", \"Eb2\", \"D2\"]\n * // with sharps\n * Range.chromatic([\"C2\", \"C3\"], { sharps: true }) // => [ \"C2\", \"C#2\", \"D2\", \"D#2\", \"E2\", \"F2\", \"F#2\", \"G2\", \"G#2\", \"A2\", \"A#2\", \"B2\", \"C3\" ]\n */\nexport function chromatic(\n notes: (string | number)[],\n options?: ToNoteNameOptions,\n): string[] {\n return numeric(notes).map((midi) => midiToNoteName(midi, options));\n}\n\nexport default { numeric, chromatic };\n", "/**\n * References:\n * - https://www.researchgate.net/publication/327567188_An_Algorithm_for_Spelling_the_Pitches_of_Any_Musical_Scale\n * @module scale\n */\nimport { all as chordTypes } from \"@tonaljs/chord-type\";\nimport { range as nums, rotate } from \"@tonaljs/collection\";\nimport {\n deprecate,\n note,\n NoteName,\n tonicIntervalsTransposer,\n transpose,\n} from \"@tonaljs/core\";\nimport { enharmonic, fromMidi, sortedUniqNames } from \"@tonaljs/note\";\nimport {\n chroma,\n isChroma,\n isSubsetOf,\n isSupersetOf,\n modes,\n} from \"@tonaljs/pcset\";\nimport {\n all,\n all as scaleTypes,\n get as getScaleType,\n names as scaleTypeNames,\n ScaleType,\n} from \"@tonaljs/scale-type\";\n\ntype ScaleName = string;\ntype ScaleNameTokens = [string, string]; // [TONIC, SCALE TYPE]\n\nexport interface Scale extends ScaleType {\n tonic: string | null;\n type: string;\n notes: NoteName[];\n}\n\nconst NoScale: Scale = {\n empty: true,\n name: \"\",\n type: \"\",\n tonic: null,\n setNum: NaN,\n chroma: \"\",\n normalized: \"\",\n aliases: [],\n notes: [],\n intervals: [],\n};\n\n/**\n * Given a string with a scale name and (optionally) a tonic, split\n * that components.\n *\n * It retuns an array with the form [ name, tonic ] where tonic can be a\n * note name or null and name can be any arbitrary string\n * (this function doesn\"t check if that scale name exists)\n *\n * @function\n * @param {string} name - the scale name\n * @return {Array} an array [tonic, name]\n * @example\n * tokenize(\"C mixolydean\") // => [\"C\", \"mixolydean\"]\n * tokenize(\"anything is valid\") // => [\"\", \"anything is valid\"]\n * tokenize() // => [\"\", \"\"]\n */\nexport function tokenize(name: ScaleName): ScaleNameTokens {\n if (typeof name !== \"string\") {\n return [\"\", \"\"];\n }\n const i = name.indexOf(\" \");\n const tonic = note(name.substring(0, i));\n if (tonic.empty) {\n const n = note(name);\n return n.empty ? [\"\", name] : [n.name, \"\"];\n }\n\n const type = name.substring(tonic.name.length + 1);\n return [tonic.name, type.length ? type : \"\"];\n}\n\n/**\n * Get all scale names\n * @function\n */\nexport const names = scaleTypeNames;\n\n/**\n * Get a Scale from a scale name.\n */\nexport function get(src: ScaleName | ScaleNameTokens): Scale {\n const tokens = Array.isArray(src) ? src : tokenize(src);\n const tonic = note(tokens[0]).name;\n const st = getScaleType(tokens[1]);\n if (st.empty) {\n return NoScale;\n }\n\n const type = st.name;\n const notes: string[] = tonic\n ? st.intervals.map((i) => transpose(tonic, i))\n : [];\n\n const name = tonic ? tonic + \" \" + type : type;\n\n return { ...st, name, type, tonic, notes };\n}\n\nexport const scale = deprecate(\"Scale.scale\", \"Scale.get\", get);\n\nexport function detect(\n notes: string[],\n options: { tonic?: string; match?: \"exact\" | \"fit\" } = {},\n): string[] {\n const notesChroma = chroma(notes);\n const tonic = note(options.tonic ?? notes[0] ?? \"\");\n const tonicChroma = tonic.chroma;\n if (tonicChroma === undefined) {\n return [];\n }\n\n const pitchClasses = notesChroma.split(\"\");\n pitchClasses[tonicChroma] = \"1\";\n const scaleChroma = rotate(tonicChroma, pitchClasses).join(\"\");\n const match = all().find((scaleType) => scaleType.chroma === scaleChroma);\n\n const results: string[] = [];\n if (match) {\n results.push(tonic.name + \" \" + match.name);\n }\n if (options.match === \"exact\") {\n return results;\n }\n\n extended(scaleChroma).forEach((scaleName) => {\n results.push(tonic.name + \" \" + scaleName);\n });\n\n return results;\n}\n\n/**\n * Get all chords that fits a given scale\n *\n * @function\n * @param {string} name - the scale name\n * @return {Array} - the chord names\n *\n * @example\n * scaleChords(\"pentatonic\") // => [\"5\", \"64\", \"M\", \"M6\", \"Madd9\", \"Msus2\"]\n */\nexport function scaleChords(name: string): string[] {\n const s = get(name);\n const inScale = isSubsetOf(s.chroma);\n return chordTypes()\n .filter((chord) => inScale(chord.chroma))\n .map((chord) => chord.aliases[0]);\n}\n/**\n * Get all scales names that are a superset of the given one\n * (has the same notes and at least one more)\n *\n * @function\n * @param {string} name\n * @return {Array} a list of scale names\n * @example\n * extended(\"major\") // => [\"bebop\", \"bebop dominant\", \"bebop major\", \"chromatic\", \"ichikosucho\"]\n */\nexport function extended(name: string): string[] {\n const chroma = isChroma(name) ? name : get(name).chroma;\n const isSuperset = isSupersetOf(chroma);\n return scaleTypes()\n .filter((scale) => isSuperset(scale.chroma))\n .map((scale) => scale.name);\n}\n\n/**\n * Find all scales names that are a subset of the given one\n * (has less notes but all from the given scale)\n *\n * @function\n * @param {string} name\n * @return {Array} a list of scale names\n *\n * @example\n * reduced(\"major\") // => [\"ionian pentatonic\", \"major pentatonic\", \"ritusen\"]\n */\nexport function reduced(name: string): string[] {\n const isSubset = isSubsetOf(get(name).chroma);\n return scaleTypes()\n .filter((scale) => isSubset(scale.chroma))\n .map((scale) => scale.name);\n}\n\n/**\n * Given an array of notes, return the scale: a pitch class set starting from\n * the first note of the array\n *\n * @function\n * @param {string[]} notes\n * @return {string[]} pitch classes with same tonic\n * @example\n * scaleNotes(['C4', 'c3', 'C5', 'C4', 'c4']) // => [\"C\"]\n * scaleNotes(['D4', 'c#5', 'A5', 'F#6']) // => [\"D\", \"F#\", \"A\", \"C#\"]\n */\nexport function scaleNotes(notes: NoteName[]) {\n const pcset: string[] = notes.map((n) => note(n).pc).filter((x) => x);\n const tonic = pcset[0];\n const scale = sortedUniqNames(pcset);\n return rotate(scale.indexOf(tonic), scale);\n}\n\ntype ScaleMode = [string, string];\n/**\n * Find mode names of a scale\n *\n * @function\n * @param {string} name - scale name\n * @example\n * modeNames(\"C pentatonic\") // => [\n * [\"C\", \"major pentatonic\"],\n * [\"D\", \"egyptian\"],\n * [\"E\", \"malkos raga\"],\n * [\"G\", \"ritusen\"],\n * [\"A\", \"minor pentatonic\"]\n * ]\n */\nexport function modeNames(name: string): ScaleMode[] {\n const s = get(name);\n if (s.empty) {\n return [];\n }\n\n const tonics = s.tonic ? s.notes : s.intervals;\n return modes(s.chroma)\n .map((chroma: string, i: number): ScaleMode => {\n const modeName = get(chroma).name;\n return modeName ? [tonics[i], modeName] : [\"\", \"\"];\n })\n .filter((x) => x[0]);\n}\n\nfunction getNoteNameOf(scale: string | string[]) {\n const names = Array.isArray(scale) ? scaleNotes(scale) : get(scale).notes;\n const chromas = names.map((name) => note(name).chroma);\n\n return (noteOrMidi: string | number): string | undefined => {\n const currNote =\n typeof noteOrMidi === \"number\"\n ? note(fromMidi(noteOrMidi))\n : note(noteOrMidi);\n const height = currNote.height;\n\n if (height === undefined) return undefined;\n const chroma = height % 12;\n const position = chromas.indexOf(chroma);\n if (position === -1) return undefined;\n return enharmonic(currNote.name, names[position]);\n };\n}\n\nexport function rangeOf(scale: string | string[]) {\n const getName = getNoteNameOf(scale);\n return (fromNote: string, toNote: string) => {\n const from = note(fromNote).height;\n const to = note(toNote).height;\n if (from === undefined || to === undefined) return [];\n\n return nums(from, to)\n .map(getName)\n .filter((x) => x);\n };\n}\n\n/**\n * Returns a function to get a note name from the scale degree.\n *\n * @example\n * [1, 2, 3].map(Scale.degrees(\"C major\")) => [\"C\", \"D\", \"E\"]\n * [1, 2, 3].map(Scale.degrees(\"C4 major\")) => [\"C4\", \"D4\", \"E4\"]\n */\nexport function degrees(scaleName: string | ScaleNameTokens) {\n const { intervals, tonic } = get(scaleName);\n const transpose = tonicIntervalsTransposer(intervals, tonic);\n return (degree: number) =>\n degree ? transpose(degree > 0 ? degree - 1 : degree) : \"\";\n}\n\n/**\n * Sames as `degree` but with 0-based index\n */\nexport function steps(scaleName: string | ScaleNameTokens) {\n const { intervals, tonic } = get(scaleName);\n return tonicIntervalsTransposer(intervals, tonic);\n}\n\nexport default {\n degrees,\n detect,\n extended,\n get,\n modeNames,\n names,\n rangeOf,\n reduced,\n scaleChords,\n scaleNotes,\n steps,\n tokenize,\n\n // deprecated\n scale,\n};\n", "// TYPES: PARSING\nexport type TimeSignatureLiteral = string | [number, number] | [string, string];\ntype ParsedTimeSignature = [number | number[], number];\n\n// TYPES: PROPERTIES\nexport type ValidTimeSignature = {\n readonly empty: false;\n readonly name: string;\n readonly upper: number | number[];\n readonly lower: number;\n readonly type: \"simple\" | \"compound\" | \"irregular\" | \"irrational\";\n readonly additive: number[];\n};\n\nexport type InvalidTimeSignature = {\n readonly empty: true;\n readonly name: \"\";\n readonly upper: undefined;\n readonly lower: undefined;\n readonly type: undefined;\n readonly additive: [];\n};\n\nexport type TimeSignature = ValidTimeSignature | InvalidTimeSignature;\n\n// CONSTANTS\nconst NONE: InvalidTimeSignature = {\n empty: true,\n name: \"\",\n upper: undefined,\n lower: undefined,\n type: undefined,\n additive: [],\n};\n\nconst NAMES = [\"4/4\", \"3/4\", \"2/4\", \"2/2\", \"12/8\", \"9/8\", \"6/8\", \"3/8\"];\n\n// PUBLIC API\n\nexport function names() {\n return NAMES.slice();\n}\n\nconst REGEX = /^(\\d*\\d(?:\\+\\d)*)\\/(\\d+)$/;\nconst CACHE = new Map();\n\nexport function get(literal: TimeSignatureLiteral): TimeSignature {\n const stringifiedLiteral = JSON.stringify(literal);\n const cached = CACHE.get(stringifiedLiteral);\n if (cached) {\n return cached;\n }\n\n const ts = build(parse(literal));\n CACHE.set(stringifiedLiteral, ts);\n return ts;\n}\n\nexport function parse(literal: TimeSignatureLiteral): ParsedTimeSignature {\n if (typeof literal === \"string\") {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const [_, up, low] = REGEX.exec(literal) || [];\n return parse([up, low]);\n }\n\n const [up, down] = literal;\n const denominator = +down;\n if (typeof up === \"number\") {\n return [up, denominator];\n }\n\n const list = up.split(\"+\").map((n) => +n);\n return list.length === 1 ? [list[0], denominator] : [list, denominator];\n}\n\nexport default { names, parse, get };\n\n// PRIVATE\n\nconst isPowerOfTwo = (x: number) => (Math.log(x) / Math.log(2)) % 1 === 0;\n\nfunction build([up, down]: ParsedTimeSignature): TimeSignature {\n const upper = Array.isArray(up) ? up.reduce((a, b) => a + b, 0) : up;\n const lower = down;\n if (upper === 0 || lower === 0) {\n return NONE;\n }\n\n const name = Array.isArray(up) ? `${up.join(\"+\")}/${down}` : `${up}/${down}`;\n const additive = Array.isArray(up) ? up : [];\n const type =\n lower === 4 || lower === 2\n ? \"simple\"\n : lower === 8 && upper % 3 === 0\n ? \"compound\"\n : isPowerOfTwo(lower)\n ? \"irregular\"\n : \"irrational\";\n\n return {\n empty: false,\n name,\n type,\n upper,\n lower,\n additive,\n };\n}\n", "import Note from \"@tonaljs/note\";\n\n// A function that decides which of a set of voicings is picked as a follow up to lastVoicing.\nexport declare type VoiceLeadingFunction = (\n voicings: string[][],\n lastVoicing: string[],\n) => string[];\n\nexport const topNoteDiff: VoiceLeadingFunction = (voicings, lastVoicing) => {\n if (!lastVoicing || !lastVoicing.length) {\n return voicings[0];\n }\n const topNoteMidi = (voicing: string[]) =>\n Note.midi(voicing[voicing.length - 1]) || 0;\n const diff = (voicing: string[]) =>\n Math.abs(topNoteMidi(lastVoicing) - topNoteMidi(voicing));\n return voicings.sort((a, b) => diff(a) - diff(b))[0];\n};\n\nexport default {\n topNoteDiff,\n};\n", "import Chord from \"@tonaljs/chord\";\nimport { lefthand, VoicingDictionary, triads, all } from \"./data\";\n\nconst defaultDictionary: VoicingDictionary = lefthand;\n\nfunction lookup(\n symbol: string,\n dictionary = defaultDictionary,\n): string[] | undefined {\n if (dictionary[symbol]) {\n return dictionary[symbol];\n }\n const { aliases } = Chord.get(\"C\" + symbol);\n // TODO: find other way to get aliases of symbol\n const match =\n Object.keys(dictionary).find((_symbol) => aliases.includes(_symbol)) || \"\";\n if (match !== undefined) {\n return dictionary[match];\n }\n return undefined;\n}\n\nexport default {\n lookup,\n lefthand,\n triads,\n all,\n defaultDictionary,\n};\n", "export type VoicingDictionary = { [symbol: string]: string[] };\n\nexport const triads: VoicingDictionary = {\n M: [\"1P 3M 5P\", \"3M 5P 8P\", \"5P 8P 10M\"],\n m: [\"1P 3m 5P\", \"3m 5P 8P\", \"5P 8P 10m\"],\n o: [\"1P 3m 5d\", \"3m 5d 8P\", \"5d 8P 10m\"],\n aug: [\"1P 3m 5A\", \"3m 5A 8P\", \"5A 8P 10m\"],\n};\nexport const lefthand: VoicingDictionary = {\n m7: [\"3m 5P 7m 9M\", \"7m 9M 10m 12P\"],\n \"7\": [\"3M 6M 7m 9M\", \"7m 9M 10M 13M\"],\n \"^7\": [\"3M 5P 7M 9M\", \"7M 9M 10M 12P\"],\n \"69\": [\"3M 5P 6A 9M\"],\n m7b5: [\"3m 5d 7m 8P\", \"7m 8P 10m 12d\"],\n \"7b9\": [\"3M 6m 7m 9m\", \"7m 9m 10M 13m\"], // b9 / b13\n \"7b13\": [\"3M 6m 7m 9m\", \"7m 9m 10M 13m\"], // b9 / b13\n o7: [\"1P 3m 5d 6M\", \"5d 6M 8P 10m\"],\n \"7#11\": [\"7m 9M 11A 13A\"],\n \"7#9\": [\"3M 7m 9A\"],\n mM7: [\"3m 5P 7M 9M\", \"7M 9M 10m 12P\"],\n m6: [\"3m 5P 6M 9M\", \"6M 9M 10m 12P\"],\n};\nexport const all: VoicingDictionary = {\n M: [\"1P 3M 5P\", \"3M 5P 8P\", \"5P 8P 10M\"],\n m: [\"1P 3m 5P\", \"3m 5P 8P\", \"5P 8P 10m\"],\n o: [\"1P 3m 5d\", \"3m 5d 8P\", \"5d 8P 10m\"],\n aug: [\"1P 3m 5A\", \"3m 5A 8P\", \"5A 8P 10m\"],\n m7: [\"3m 5P 7m 9M\", \"7m 9M 10m 12P\"],\n \"7\": [\"3M 6M 7m 9M\", \"7m 9M 10M 13M\"],\n \"^7\": [\"3M 5P 7M 9M\", \"7M 9M 10M 12P\"],\n \"69\": [\"3M 5P 6A 9M\"],\n m7b5: [\"3m 5d 7m 8P\", \"7m 8P 10m 12d\"],\n \"7b9\": [\"3M 6m 7m 9m\", \"7m 9m 10M 13m\"], // b9 / b13\n \"7b13\": [\"3M 6m 7m 9m\", \"7m 9m 10M 13m\"], // b9 / b13\n o7: [\"1P 3m 5d 6M\", \"5d 6M 8P 10m\"],\n \"7#11\": [\"7m 9M 11A 13A\"],\n \"7#9\": [\"3M 7m 9A\"],\n mM7: [\"3m 5P 7M 9M\", \"7M 9M 10m 12P\"],\n m6: [\"3m 5P 6M 9M\", \"6M 9M 10m 12P\"],\n};\n", "import Chord from \"@tonaljs/chord\";\nimport Interval from \"@tonaljs/interval\";\nimport Note from \"@tonaljs/note\";\nimport Range from \"@tonaljs/range\";\nimport VoiceLeading from \"@tonaljs/voice-leading\";\nimport VoicingDictionary from \"@tonaljs/voicing-dictionary\";\n\nconst defaultRange = [\"C3\", \"C5\"];\nconst defaultDictionary = VoicingDictionary.all;\nconst defaultVoiceLeading = VoiceLeading.topNoteDiff;\n\nfunction get(\n chord: string,\n range: string[] = defaultRange,\n dictionary = defaultDictionary,\n voiceLeading = defaultVoiceLeading,\n lastVoicing?: string[],\n) {\n const voicings = search(chord, range, dictionary);\n if (!lastVoicing || !lastVoicing.length) {\n // notes = voicings[Math.ceil(voicings.length / 2)]; // pick middle voicing..\n return voicings[0]; // pick lowest voicing..\n } else {\n // calculates the distance between the last note and the given voicings top note\n // sort voicings with differ\n return voiceLeading(voicings, lastVoicing);\n }\n}\n\nfunction search(\n chord: string,\n range = defaultRange,\n dictionary = VoicingDictionary.triads,\n): string[][] {\n const [tonic, symbol] = Chord.tokenize(chord);\n const sets = VoicingDictionary.lookup(symbol, dictionary);\n // find equivalent symbol that is used as a key in dictionary:\n if (!sets) {\n return [];\n }\n // resolve array of interval arrays for the wanted symbol\n const voicings = sets.map((intervals) => intervals.split(\" \"));\n const notesInRange = Range.chromatic(range); // gives array of notes inside range\n return voicings.reduce((voiced: string[][], voicing: string[]) => {\n // transpose intervals relative to first interval (e.g. 3m 5P > 1P 3M)\n const relativeIntervals = voicing.map(\n (interval) => Interval.subtract(interval, voicing[0]) || \"\",\n );\n // get enharmonic correct pitch class the bottom note\n const bottomPitchClass = Note.transpose(tonic, voicing[0]);\n // get all possible start notes for voicing\n const starts = notesInRange\n // only get the start notes:\n .filter((note) => Note.chroma(note) === Note.chroma(bottomPitchClass))\n // filter out start notes that will overshoot the top end of the range\n .filter(\n (note) =>\n (Note.midi(\n Note.transpose(\n note,\n relativeIntervals[relativeIntervals.length - 1],\n ),\n ) || 0) <= (Note.midi(range[1]) || 0),\n )\n // replace Range.chromatic notes with the correct enharmonic equivalents\n .map((note) => Note.enharmonic(note, bottomPitchClass));\n // render one voicing for each start note\n const notes = starts.map((start) =>\n relativeIntervals.map((interval) => Note.transpose(start, interval)),\n );\n return voiced.concat(notes);\n }, []);\n}\n\nfunction sequence(\n chords: string[],\n range = defaultRange,\n dictionary = defaultDictionary,\n voiceLeading = defaultVoiceLeading,\n lastVoicing?: string[],\n) {\n const { voicings } = chords.reduce<{\n voicings: string[][];\n lastVoicing: string[] | undefined;\n }>(\n ({ voicings, lastVoicing }, chord) => {\n const voicing = get(chord, range, dictionary, voiceLeading, lastVoicing);\n lastVoicing = voicing;\n voicings.push(voicing);\n return { voicings, lastVoicing };\n },\n { voicings: [], lastVoicing },\n );\n return voicings;\n}\n\nexport default {\n get,\n search,\n sequence,\n};\n"], + "mappings": "ucAAA,IAAAA,GAAA,GAAAC,GAAAD,GAAA,iBAAAE,GAAA,UAAAC,GAAA,UAAAC,EAAA,oBAAAC,GAAA,cAAAC,GAAA,eAAAC,GAAA,SAAAJ,GAAA,kBAAAK,GAAA,aAAAC,GAAA,QAAAC,GAAA,SAAAC,GAAA,SAAAC,GAAA,SAAAC,EAAA,UAAAC,GAAA,UAAAC,GAAA,gBAAAC,GAAA,UAAAC,GAAA,iBAAAC,GAAA,UAAAC,GAAA,oBAAAC,GAAA,cAAAC,GAAA,kBAAAC,GAAA,UAAAC,GAAA,iBAAAC,GAAA,YAAAC,GAAA,sBAAAC,EAAA,aAAAC,EAAA,aAAAC,EAAA,WAAAC,GAAA,oBAAAC,EAAA,gBAAAC,GAAA,gBAAAC,EAAA,cAAAC,EAAA,aAAAC,EAAA,YAAAC,GAAA,WAAAC,GAAA,aAAAC,EAAA,YAAAC,GAAA,iBAAAC,EAAA,YAAAC,EAAA,SAAAC,GAAA,SAAAC,EAAA,UAAAC,EAAA,iBAAAC,GAAA,qBAAAC,GAAA,iBAAAC,EAAA,6BAAAC,EAAA,cAAAC,ICcO,SAASC,EAAaC,EAAiC,CAC5D,OAAOA,IAAQ,MACb,OAAOA,GAAQ,UACf,SAAUA,GACV,OAAOA,EAAI,MAAS,QAGxB,CA6BA,IAAMC,GAAQ,CAAC,EAAG,EAAG,EAAG,EAAG,EAAG,EAAG,EAAE,EACtBC,GAAS,CAAC,CAAE,KAAAC,EAAM,IAAAC,CAAI,KAAcH,GAAME,CAAI,EAAIC,EAAM,KAAO,GAE/DC,GAAS,CAAC,CAAE,KA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MC,EAAoBD,EAAQ,IAC/BE,GAAaC,GAAS,SAASD,EAAUF,EAAQ,CAAC,CAAC,GAAK,EAC3D,EAEMI,EAAmBC,EAAK,UAAUb,EAAOQ,EAAQ,CAAC,CAAC,EAkBnDM,EAhBST,EAEZ,OAAQU,GAASF,EAAK,OAAOE,CAAI,IAAMF,EAAK,OAAOD,CAAgB,CAAC,EAEpE,OACEG,IACEF,EAAK,KACJA,EAAK,UACHE,EACAN,EAAkBA,EAAkB,OAAS,CAAC,CAChD,CACF,GAAK,KAAOI,EAAK,KAAKnB,EAAM,CAAC,CAAC,GAAK,EACvC,EAEC,IAAKqB,GAASF,EAAK,WAAWE,EAAMH,CAAgB,CAAC,EAEnC,IAAKI,GACxBP,EAAkB,IAAKC,IAAaG,EAAK,UAAUG,EAAON,EAAQ,CAAC,CACrE,EACA,OAAOH,EAAO,OAAOO,CAAK,CAC5B,EAAG,CAAC,CAAC,CACP,CAEA,SAASG,GACPC,EACAxB,EAAQP,GACRQ,EAAaP,GACbQ,EAAeN,GACfO,EACA,CACA,GAAM,CAAE,SAAAC,CAAS,EAAIoB,EAAO,OAI1B,CAAC,CAAE,SAAApB,EAAU,YAAAD,CAAY,EAAGJ,IAAU,CACpC,IAAMe,EAAUhB,GAAIC,EAAOC,EAAOC,EAAYC,EAAcC,CAAW,EACvEA,OAAAA,EAAcW,EACdV,EAAS,KAAKU,CAAO,EACd,CAAE,SAAAV,EAAU,YAAAD,CAAY,CACjC,EACA,CAAE,SAAU,CAAC,EAAG,YAAAA,CAAY,CAC9B,EACA,OAAOC,CACT,CAEA,IAAOqB,GAAQ,CACb,IAAA3B,GACA,OAAAO,GACA,SAAAkB,EACF,EhC1EA,IAAMG,GAAQC,GACRC,GAAQC,GACRC,GAAkBC,GAClBC,GAAkBC", + "names": ["tonal_exports", "__export", "abc_notation_default", "dist_exports", "chord_default", "ChordDictionary", "chord_type_default", "collection_default", "duration_value_default", "interval_default", "key_default", "midi_default", "mode_default", "note_default", "PcSet", "pcset_default", "progression_default", "range_default", "roman_numeral_default", "scale_default", "ScaleDictionary", "scale_type_default", "time_signature_default", "Tonal", "voice_leading_default", "voicing_default", "voicing_dictionary_default", "accToAlt", "altToAcc", "chroma", "coordToInterval", "coordToNote", "coordinates", "deprecate", "distance", "fillStr", "height", "interval", "isNamed", "isNamedPitch", "isPitch", "midi", "note", "pitch", "stepToLetter", "tokenizeInterval", "tokenizeNote", "tonicIntervalsTransposer", "transpose", "isNamedPitch", "src", "SIZES", "chroma", "step", "alt", "height", "oct", "dir", "midi", "pitch", "h", "isPitch", "FIFTHS", "STEPS_TO_OCTS", "fifths", "coordinates", "f", "o", "FIFTHS_TO_STEPS", "coord", "unaltered", "i", "fillStr", "s", "NoInterval", "INTERVAL_TONAL_REGEX", "INTERVAL_SHORTHAND_REGEX", "REGEX", "tokenizeInterval", "str", "m", "cache", "interval", "src", "parse", "isPitch", "pitchName", "isNamedPitch", "SIZES", "TYPES", "tokens", "num", "q", "step", "t", "type", "name", "dir", "simple", "alt", "qToAlt", "oct", "semitones", "chroma", "coord", "coordinates", "coordToInterval", "forceDescending", "f", "o", "isDescending", "ivl", "pitch", "props", "calcNum", "d", "altToQ", "fillStr", "s", "NoNote", "cache", "stepToLetter", "step", "altToAcc", "alt", "accToAlt", "acc", "note", "src", "stringSrc", "cached", "value", "parse", "isPitch", "pitchName", "isNamedPitch", "REGEX", "tokenizeNote", "str", "m", "coordToNote", "noteCoord", "pitch", "mod", "n", "SEMI", "noteName", "tokens", "letter", "octStr", "oct", "coord", "coordinates", "name", "pc", "chroma", "height", "midi", "freq", "props", "transpose", "noteName", "intervalName", "note", "intervalCoord", "interval", "noteCoord", "tr", "coordToNote", "tonicIntervalsTransposer", "intervals", "tonic", "len", "normalized", "index", "octaves", "root", "distance", "fromNote", "toNote", "from", "to", "fcoord", "tcoord", "fifths", "octs", "forceDescending", "coordToInterval", "fillStr", "character", "times", "REGEX", "tokenize", "str", "m", "abcToScientificNotation", "acc", "letter", "oct", "i", "scientificToAbcNotation", "note", "l", "o", "transpose", "interval", "distance", "from", "to", "abc_notation_default", "fillStr", "s", "NoNote", "cache", "stepToLetter", "step", "altToAcc", "alt", "accToAlt", "acc", "note", "src", "stringSrc", "cached", "value", "parse", "isPitch", "pitchName", "isNamedPitch", "REGEX", "tokenizeNote", "str", "m", "mod", "n", "m", "SEMI", "parse", "noteName", "tokens", "tokenizeNote", "NoNote", "letter", "acc", "octStr", "step", "alt", "accToAlt", "oct", "coord", "coordinates", "name", "pc", "chroma", "height", "midi", "freq", "pitchName", "props", "stepToLetter", "altToAcc", "ascR", "b", "a", "descR", "range", "from", "to", "rotate", "times", "arr", "len", "n", "compact", "sortedNoteNames", "notes", "note", "sortedUniqNoteNames", "i", "shuffle", "rnd", "t", "m", "permutations", "acc", "perm", "e", "pos", "newPerm", "fillStr", "s", "deprecate", "original", "alternative", "fn", "args", "isNamed", "isNamedPitch", "ascR", "b", "a", "descR", "range", "from", "to", "rotate", "times", "arr", "len", "n", "compact", "shuffle", "rnd", "i", "t", "m", "permutations", "acc", "perm", "e", "pos", "newPerm", "collection_default", "EmptyPcset", "setNumToChroma", "num", "chromaToNumber", "chroma", "REGEX", "isChroma", "set", "isPcsetNum", "isPcset", "cache", "get", "src", "listToChroma", "chromaToPcset", "pcset", "deprecate", "intervals", "IVLS", "chromaToIntervals", "i", "notes", "ivl", "transpose", "chromas", "range", "modes", "normalize", "binary", "compact", "_", "r", "rotate", "isEqual", "s1", "s2", "isSubsetOf", "s", "o", "isSupersetOf", "isNoteIncludedIn", "noteName", "n", "note", "filter", "set", "isIncluded", "isNoteIncludedIn", "notes", "pcset_default", "get", "chroma", "num", "intervals", "chromas", "isSupersetOf", "isSubsetOf", "isEqual", "modes", "pcset", "chromaRotations", "binary", "_", "i", "rotate", "chromaToPcset", "setNum", "chromaToNumber", "normalizedNum", "n", "normalized", "setNumToChroma", "chromaToIntervals", "listToChroma", "EmptyPcset", "pitch", "note", "interval", "CHORDS", "data_default", "NoChordType", "EmptyPcset", "dictionary", "index", "get", "type", "chordType", "deprecate", "names", "chord", "x", "symbols", "keys", "all", "entries", "removeAll", "add", "intervals", "aliases", "fullName", "quality", "getQuality", "alias", "addAlias", "has", "interval", "ivls", "a", "b", "chord_type_default", "namedSet", "notes", "pcToName", "record", "n", "chroma", "note", "detect", "source", "options", "x", "findMatches", "chord", "a", "b", "BITMASK", "testChromaNumber", "bitmask", "chromaNumber", "hasAnyThird", "hasPerfectFifth", "hasAnySeventh", "hasNonPerfectFifth", "hasAnyThirdAndPerfectFifthAndAnySeventh", "chordType", "withPerfectFifth", "weight", "tonic", "tonicChroma", "noteName", "allModes", "modes", "found", "mode", "index", "modeWithPerfectFifth", "all", "chordName", "baseNote", "names", "get", "interval", "name", "semitones", "quality", "num", "simplify", "i", "invert", "step", "alt", "IN", "IQ", "fromSemitones", "d", "n", "c", "distance", "add", "combinator", "a", "b", "addTo", "other", "subtract", "transposeFifths", "fifths", "ivl", "nFifths", "nOcts", "dir", "coordToInterval", "interval_default", "fn", "coordA", "coordB", "coord", "SCALES", "data_default", "NoScaleType", "EmptyPcset", "dictionary", "index", "names", "scale", "get", "type", "scaleType", "deprecate", "all", "entries", "keys", "removeAll", "add", "intervals", "name", "aliases", "alias", "addAlias", "ivls", "scale_type_default", "NoChord", "tokenize", "name", "letter", "acc", "oct", "type", "tokenizeNote", "tokenizeBass", "note", "chord", "split", "get", "src", "getChord", "tonic", "bass", "typeName", "optionalTonic", "optionalBass", "bassInterval", "distance", "bassIndex", "hasRoot", "root", "rootDegree", "hasBass", "intervals", "i", "num", "quality", "newNum", "ivl", "subtract", "notes", "transpose", "symbol", "chordName", "interval", "tr", "slash", "chordScales", "s", "isChordIncluded", "isSupersetOf", "all", "scale", "extended", "isSuperset", "reduced", "isSubset", "isSubsetOf", "degrees", "tonicIntervalsTransposer", "degree", "steps", "chord_default", "detect", "DATA", "data_default", "VALUES", "denominator", "shorthand", "names", "add", "NoDuration", "duration", "name", "shorthands", "dur", "REGEX", "get", "_", "simple", "dots", "base", "fraction", "calcDots", "value", "duration_value_default", "pow", "numerator", "i", "isMidi", "arg", "toMidi", "note", "midiToFreq", "midi", "tuning", "L2", "L440", "freqToMidi", "freq", "v", "SHARPS", "FLATS", "midiToNoteName", "options", "pc", "chroma", "pcsetFromChroma", "pcset", "val", "index", "pcsetFromMidi", "a", "b", "i", "notes", "pcsetNearest", "set", "ch", "pcsetSteps", "tonic", "len", "step", "octaves", "pcsetDegrees", "steps", "degree", "midi_default", "NAMES", "toName", "n", "onlyNotes", "array", "note", "names", "get", "name", "pitchClass", "accidentals", "octave", "midi", "freq", "chroma", "fromMidi", "midiToNoteName", "fromFreq", "freqToMidi", "fromFreqSharps", "fromMidiSharps", "transpose", "tr", "transposeBy", "interval", "trBy", "transposeFrom", "trFrom", "transposeFifths", "noteName", "fifths", "trFifths", "transposeOctaves", "octaves", "ascending", "a", "b", "descending", "sortedNames", "notes", "comparator", "sortedUniqNames", "i", "simplify", "enharmonic", "destName", "src", "dest", "srcChroma", "destChroma", "destOctOffset", "destOct", "note_default", "NoRomanNumeral", "cache", "get", "src", "parse", "NAMES", "isPitch", "fromPitch", "isNamed", "romanNumeral", "deprecate", "names", "major", "NAMES_MINOR", "pitch", "altToAcc", "REGEX", "tokenize", "str", "ROMANS", "name", "acc", "roman", "chordType", "upperRoman", "step", "alt", "accToAlt", "dir", "interval", "roman_numeral_default", "Empty", "NoKey", "NoKeyScale", "NoMajorKey", "NoMinorKey", "mapScaleToType", "scale", "list", "sep", "type", "i", "keyScale", "grades", "triads", "chords", "harmonicFunctions", "chordScales", "tonic", "intervals", "gr", "get", "interval", "transpose", "distInFifths", "from", "to", "f", "note", "t", "MajorScale", "NaturalScale", "HarmonicScale", "MelodicScale", "majorKey", "pc", "alteration", "romanInTonic", "src", "r", "altToAcc", "minorKey", "tnc", "majorTonicFromKeySignature", "sig", "transposeFifths", "accToAlt", "key_default", "MODES", "NoMode", "EmptyPcset", "modes", "toMode", "index", "mode", "alias", "get", "name", "deprecate", "all", "entries", "names", "modeNum", "setNum", "alt", "triad", "seventh", "aliases", "chroma", "notes", "modeName", "tonic", "ivl", "transpose", "chords", "triads", "rotate", "tonics", "i", "x", "seventhChords", "distance", "destination", "source", "from", "to", "simplify", "transposeFifths", "relativeTonic", "mode_default", "fromRomanNumerals", "tonic", "chords", "get", "rn", "transpose", "interval", "toRomanNumerals", "chord", "note", "chordType", "tokenize", "intervalName", "distance", "progression_default", "numeric", "notes", "midi", "compact", "note", "toMidi", "result", "last", "range", "chromatic", "options", "midiToNoteName", "range_default", "NoScale", "tokenize", "name", "i", "tonic", "note", "n", "type", "names", "get", "src", "tokens", "st", "notes", "transpose", "scale", "deprecate", "detect", "options", "notesChroma", "chroma", "tonicChroma", "pitchClasses", "scaleChroma", "rotate", "match", "all", "scaleType", "results", "extended", "scaleName", "scaleChords", "s", "inScale", "isSubsetOf", "chord", "isChroma", "isSuperset", "isSupersetOf", "reduced", "isSubset", "scaleNotes", "pcset", "x", "sortedUniqNames", "modeNames", "tonics", "modes", "modeName", "getNoteNameOf", "chromas", "noteOrMidi", "currNote", "fromMidi", "height", "position", "enharmonic", "rangeOf", "getName", "fromNote", "toNote", "from", "to", "range", "degrees", "intervals", "tonicIntervalsTransposer", "degree", "steps", "scale_default", "NONE", "NAMES", "names", "REGEX", "CACHE", "get", "literal", "stringifiedLiteral", "cached", "ts", "build", "parse", "_", "up", "low", "down", "denominator", "list", "n", "time_signature_default", "isPowerOfTwo", "x", "upper", "a", "b", "lower", "name", "additive", "type", "topNoteDiff", "voicings", "lastVoicing", "topNoteMidi", "voicing", "note_default", "diff", "a", "b", "voice_leading_default", "triads", "lefthand", "all", "defaultDictionary", "lookup", "symbol", "dictionary", "aliases", "chord_default", "match", "_symbol", "voicing_dictionary_default", "defaultRange", "defaultDictionary", "voicing_dictionary_default", "defaultVoiceLeading", "voice_leading_default", "get", "chord", "range", "dictionary", "voiceLeading", "lastVoicing", "voicings", "search", "tonic", "symbol", "chord_default", "sets", "intervals", "notesInRange", "range_default", "voiced", "voicing", "relativeIntervals", "interval", "interval_default", "bottomPitchClass", "note_default", "notes", "note", "start", "sequence", "chords", "voicing_default", "Tonal", "dist_exports", "PcSet", "pcset_default", "ChordDictionary", "chord_type_default", "ScaleDictionary", "scale_type_default"] }