diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 03e7bbd6..3c9ef006 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -1,5 +1,17 @@ # tonal +## 6.3.0 + +- New `Key.majorKeyChords` and `Key.minorKeyChords` functions. + +```js +import * as Key from "tonal"; + +Key.majorKeyChords("C").find((chord) => chord.name === "Em"); // => { name: "Em", roles: ["T", "ii/II"] } +``` + +- Renamed fields of key results. `secondaryDominantsMinorRelative` is now `secondaryDominantSupertonics` and `substituteDominantsMinorRelative` is now `substituteDominantSupertonics`. Previous names are kept for compatibility as deprecated (will be removed in next major version) + ## 6.2.0 ### Minor Changes diff --git a/packages/key/CHANGELOG.md b/packages/key/CHANGELOG.md index 8c91e389..ac7f5217 100644 --- a/packages/key/CHANGELOG.md +++ b/packages/key/CHANGELOG.md @@ -1,5 +1,17 @@ # @tonaljs/key +## 4.11.0 + +- New `Key.majorKeyChords` and `Key.minorKeyChords` functions. + +```js +import * as Key from "tonal"; + +Key.majorKeyChords("C").find((chord) => chord.name === "Em"); // => { name: "Em", roles: ["T", "ii/II"] } +``` + +- Renamed fields of key results. `secondaryDominantsMinorRelative` is now `secondaryDominantSupertonics` and `substituteDominantsMinorRelative` is now `substituteDominantSupertonics`. Previous names are kept for compatibility as deprecated (will be removed in next major version) + ## 4.10.0 ### Minor Changes diff --git a/packages/key/__snapshots__/test.ts.snap b/packages/key/__snapshots__/test.ts.snap new file mode 100644 index 00000000..6e490574 --- /dev/null +++ b/packages/key/__snapshots__/test.ts.snap @@ -0,0 +1,2017 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`@tonal/key C major 1`] = ` +{ + "alteration": 0, + "chordScales": [ + "C major", + "D dorian", + "E phrygian", + "F lydian", + "G mixolydian", + "A minor", + "B locrian", + ], + "chords": [ + "Cmaj7", + "Dm7", + "Em7", + "Fmaj7", + "G7", + "Am7", + "Bm7b5", + ], + "chordsHarmonicFunction": [ + "T", + "SD", + "T", + "SD", + "D", + "T", + "D", + ], + "grades": [ + "I", + "II", + "III", + "IV", + "V", + "VI", + "VII", + ], + "intervals": [ + "1P", + "2M", + "3M", + "4P", + "5P", + "6M", + "7M", + ], + "keySignature": "", + "minorRelative": "A", + "scale": [ + "C", + "D", + "E", + "F", + "G", + "A", + "B", + ], + "secondaryDominantSupertonics": [ + "", + "Em7", + "F#m7", + "Gm7b5", + "Am7b5", + "Bm7", + "", + ], + "secondaryDominants": [ + "", + "A7", + "B7", + "C7", + "D7", + "E7", + "", + ], + "secondaryDominantsMinorRelative": [ + "", + "Em7", + "F#m7", + "Gm7b5", + "Am7b5", + "Bm7", + "", + ], + "substituteDominantSupertonics": [ + "", + "Bbm7", + "Cm7", + "Dbm7b5", + "Ebm7b5", + "Fm7", + "", + ], + "substituteDominants": [ + "", + "Eb7", + "F7", + "Gb7", + "Ab7", + "Bb7", + "", + ], + "substituteDominantsMinorRelative": [ + "", + "Bbm7", + "Cm7", + "Dbm7b5", + "Ebm7b5", + "Fm7", + "", + ], + "tonic": "C", + "triads": [ + "C", + "Dm", + "Em", + "F", + "G", + "Am", + "Bdim", + ], + "type": "major", +} +`; + +exports[`@tonal/key C major chords 1`] = ` +[ + { + "name": "Cmaj7", + "roles": [ + "T", + ], + }, + { + "name": "Dm7", + "roles": [ + "SD", + ], + }, + { + "name": "Em7", + "roles": [ + "T", + "ii/II", + ], + }, + { + "name": "Fmaj7", + "roles": [ + "SD", + ], + }, + { + "name": "G7", + "roles": [ + "D", + ], + }, + { + "name": "Am7", + "roles": [ + "T", + ], + }, + { + "name": "Bm7b5", + "roles": [ + "D", + ], + }, + { + "name": "A7", + "roles": [ + "V/II", + ], + }, + { + "name": "B7", + "roles": [ + "V/III", + ], + }, + { + "name": "C7", + "roles": [ + "V/IV", + ], + }, + { + "name": "D7", + "roles": [ + "V/V", + ], + }, + { + "name": "E7", + "roles": [ + "V/VI", + ], + }, + { + "name": "F#m7", + "roles": [ + "ii/III", + ], + }, + { + "name": "Gm7b5", + "roles": [ + "ii/IV", + ], + }, + { + "name": "Am7b5", + "roles": [ + "ii/V", + ], + }, + { + "name": "Bm7", + "roles": [ + "ii/VI", + ], + }, + { + "name": "Eb7", + "roles": [ + "subV/II", + ], + }, + { + "name": "F7", + "roles": [ + "subV/III", + ], + }, + { + "name": "Gb7", + "roles": [ + "subV/IV", + ], + }, + { + "name": "Ab7", + "roles": [ + "subV/V", + ], + }, + { + "name": "Bb7", + "roles": [ + "subV/VI", + ], + }, + { + "name": "Bbm7", + "roles": [ + "subii/II", + ], + }, + { + "name": "Cm7", + "roles": [ + "subii/III", + ], + }, + { + "name": "Dbm7b5", + "roles": [ + "subii/IV", + ], + }, + { + "name": "Ebm7b5", + "roles": [ + "subii/V", + ], + }, + { + "name": "Fm7", + "roles": [ + "subii/VI", + ], + }, +] +`; + +exports[`@tonal/key C minor chords 1`] = ` +[ + { + "name": "Cm7", + "roles": [ + "T", + ], + }, + { + "name": "Dm7b5", + "roles": [ + "SD", + ], + }, + { + "name": "Ebmaj7", + "roles": [ + "T", + ], + }, + { + "name": "Fm7", + "roles": [ + "SD", + ], + }, + { + "name": "Gm7", + "roles": [ + "D", + "ii/IV", + ], + }, + { + "name": "Abmaj7", + "roles": [ + "SD", + ], + }, + { + "name": "Bb7", + "roles": [ + "SD", + ], + }, + { + "name": "G7", + "roles": [ + "V/I", + "D", + ], + }, + { + "name": "C7", + "roles": [ + "V/IV", + ], + }, + { + "name": "D7", + "roles": [ + "V/V", + ], + }, + { + "name": "Eb7", + "roles": [ + "V/bVI", + "subV/II", + ], + }, + { + "name": "F7", + "roles": [ + "V/bVII", + "SD", + ], + }, + { + "name": "Dm7", + "roles": [ + "ii/I", + "SD", + ], + }, + { + "name": "Am7", + "roles": [ + "ii/V", + ], + }, + { + "name": "Bbm7b5", + "roles": [ + "ii/bVI", + ], + }, + { + "name": "Cm7b5", + "roles": [ + "ii/bVII", + ], + }, + { + "name": "Db7", + "roles": [ + "subV/I", + ], + }, + { + "name": "Gb7", + "roles": [ + "subV/IV", + ], + }, + { + "name": "Ab7", + "roles": [ + "subV/V", + ], + }, + { + "name": "Bbb7", + "roles": [ + "subV/bVI", + ], + }, + { + "name": "Cb7", + "roles": [ + "subV/bVII", + ], + }, + { + "name": "Abm7", + "roles": [ + "subii/I", + ], + }, + { + "name": "Dbm7", + "roles": [ + "subii/IV", + ], + }, + { + "name": "Ebm7", + "roles": [ + "subii/V", + ], + }, + { + "name": "Fbm7b5", + "roles": [ + "subii/bVI", + ], + }, + { + "name": "Gbm7b5", + "roles": [ + "subii/bVII", + ], + }, + { + "name": "CmMaj7", + "roles": [ + "T", + ], + }, + { + "name": "Eb+maj7", + "roles": [ + "T", + ], + }, + { + "name": "Bo7", + "roles": [ + "D", + ], + }, + { + "name": "Am7b5", + "roles": [ + "ii/V", + ], + }, + { + "name": "Ebm7b5", + "roles": [ + "subii/V", + ], + }, + { + "name": "Cm6", + "roles": [ + "T", + ], + }, + { + "name": "Bm7b5", + "roles": [], + }, + { + "name": "A7", + "roles": [ + "V/II", + ], + }, + { + "name": "Em7", + "roles": [ + "ii/II", + ], + }, + { + "name": "Gm7b5", + "roles": [ + "ii/IV", + ], + }, + { + "name": "Bbm7", + "roles": [ + "subii/II", + ], + }, + { + "name": "Dbm7b5", + "roles": [ + "subii/IV", + ], + }, +] +`; + +exports[`@tonal/key majorKeys 1`] = ` +{ + "alteration": 3, + "chordScales": [ + "A major", + "B dorian", + "C# phrygian", + "D lydian", + "E mixolydian", + "F# minor", + "G# locrian", + ], + "chords": [ + "Amaj7", + "Bm7", + "C#m7", + "Dmaj7", + "E7", + "F#m7", + "G#m7b5", + ], + "chordsHarmonicFunction": [ + "T", + "SD", + "T", + "SD", + "D", + "T", + "D", + ], + "grades": [ + "I", + "II", + "III", + "IV", + "V", + "VI", + "VII", + ], + "intervals": [ + "1P", + "2M", + "3M", + "4P", + "5P", + "6M", + "7M", + ], + "keySignature": "###", + "minorRelative": "F#", + "scale": [ + "A", + "B", + "C#", + "D", + "E", + "F#", + "G#", + ], + "secondaryDominantSupertonics": [ + "", + "C#m7", + "D#m7", + "Em7b5", + "F#m7b5", + "G#m7", + "", + ], + "secondaryDominants": [ + "", + "F#7", + "G#7", + "A7", + "B7", + "C#7", + "", + ], + "secondaryDominantsMinorRelative": [ + "", + "C#m7", + "D#m7", + "Em7b5", + "F#m7b5", + "G#m7", + "", + ], + "substituteDominantSupertonics": [ + "", + "Gm7", + "Am7", + "Bbm7b5", + "Cm7b5", + "Dm7", + "", + ], + "substituteDominants": [ + "", + "C7", + "D7", + "Eb7", + "F7", + "G7", + "", + ], + "substituteDominantsMinorRelative": [ + "", + "Gm7", + "Am7", + "Bbm7b5", + "Cm7b5", + "Dm7", + "", + ], + "tonic": "A", + "triads": [ + "A", + "Bm", + "C#m", + "D", + "E", + "F#m", + "G#dim", + ], + "type": "major", +} +`; + +exports[`@tonal/key majorKeys 2`] = ` +{ + "alteration": -2, + "chordScales": [ + "Bb major", + "C dorian", + "D phrygian", + "Eb lydian", + "F mixolydian", + "G minor", + "A locrian", + ], + "chords": [ + "Bbmaj7", + "Cm7", + "Dm7", + "Ebmaj7", + "F7", + "Gm7", + "Am7b5", + ], + "chordsHarmonicFunction": [ + "T", + "SD", + "T", + "SD", + "D", + "T", + "D", + ], + "grades": [ + "I", + "II", + "III", + "IV", + "V", + "VI", + "VII", + ], + "intervals": [ + "1P", + "2M", + "3M", + "4P", + "5P", + "6M", + "7M", + ], + "keySignature": "bb", + "minorRelative": "G", + "scale": [ + "Bb", + "C", + "D", + "Eb", + "F", + "G", + "A", + ], + "secondaryDominantSupertonics": [ + "", + "Dm7", + "Em7", + "Fm7b5", + "Gm7b5", + "Am7", + "", + ], + "secondaryDominants": [ + "", + "G7", + "A7", + "Bb7", + "C7", + "D7", + "", + ], + "secondaryDominantsMinorRelative": [ + "", + "Dm7", + "Em7", + "Fm7b5", + "Gm7b5", + "Am7", + "", + ], + "substituteDominantSupertonics": [ + "", + "Abm7", + "Bbm7", + "Cbm7b5", + "Dbm7b5", + "Ebm7", + "", + ], + "substituteDominants": [ + "", + "Db7", + "Eb7", + "Fb7", + "Gb7", + "Ab7", + "", + ], + "substituteDominantsMinorRelative": [ + "", + "Abm7", + "Bbm7", + "Cbm7b5", + "Dbm7b5", + "Ebm7", + "", + ], + "tonic": "Bb", + "triads": [ + "Bb", + "Cm", + "Dm", + "Eb", + "F", + "Gm", + "Adim", + ], + "type": "major", +} +`; + +exports[`@tonal/key majorKeys 3`] = ` +{ + "alteration": 4, + "chordScales": [ + "E major", + "F# dorian", + "G# phrygian", + "A lydian", + "B mixolydian", + "C# minor", + "D# locrian", + ], + "chords": [ + "Emaj7", + "F#m7", + "G#m7", + "Amaj7", + "B7", + "C#m7", + "D#m7b5", + ], + "chordsHarmonicFunction": [ + "T", + "SD", + "T", + "SD", + "D", + "T", + "D", + ], + "grades": [ + "I", + "II", + "III", + "IV", + "V", + "VI", + "VII", + ], + "intervals": [ + "1P", + "2M", + "3M", + "4P", + "5P", + "6M", + "7M", + ], + "keySignature": "####", + "minorRelative": "C#", + "scale": [ + "E", + "F#", + "G#", + "A", + "B", + "C#", + "D#", + ], + "secondaryDominantSupertonics": [ + "", + "G#m7", + "A#m7", + "Bm7b5", + "C#m7b5", + "D#m7", + "", + ], + "secondaryDominants": [ + "", + "C#7", + "D#7", + "E7", + "F#7", + "G#7", + "", + ], + "secondaryDominantsMinorRelative": [ + "", + "G#m7", + "A#m7", + "Bm7b5", + "C#m7b5", + "D#m7", + "", + ], + "substituteDominantSupertonics": [ + "", + "Dm7", + "Em7", + "Fm7b5", + "Gm7b5", + "Am7", + "", + ], + "substituteDominants": [ + "", + "G7", + "A7", + "Bb7", + "C7", + "D7", + "", + ], + "substituteDominantsMinorRelative": [ + "", + "Dm7", + "Em7", + "Fm7b5", + "Gm7b5", + "Am7", + "", + ], + "tonic": "E", + "triads": [ + "E", + "F#m", + "G#m", + "A", + "B", + "C#m", + "D#dim", + ], + "type": "major", +} +`; + +exports[`@tonal/key minorKey 1`] = ` +{ + "alteration": -3, + "harmonic": { + "chordScales": [ + "C harmonic minor", + "D locrian 6", + "Eb major augmented", + "F lydian diminished", + "G phrygian dominant", + "Ab lydian #9", + "B ultralocrian", + ], + "chords": [ + "CmMaj7", + "Dm7b5", + "Eb+maj7", + "Fm7", + "G7", + "Abmaj7", + "Bo7", + ], + "chordsHarmonicFunction": [ + "T", + "SD", + "T", + "SD", + "D", + "SD", + "D", + ], + "grades": [ + "I", + "II", + "bIII", + "IV", + "V", + "bVI", + "VII", + ], + "intervals": [ + "1P", + "2M", + "3m", + "4P", + "5P", + "6m", + "7M", + ], + "scale": [ + "C", + "D", + "Eb", + "F", + "G", + "Ab", + "B", + ], + "secondaryDominantSupertonics": [ + "", + "", + "", + "Gm7", + "Am7b5", + "Bbm7b5", + "", + ], + "secondaryDominants": [ + "", + "", + "", + "C7", + "D7", + "Eb7", + "", + ], + "secondaryDominantsMinorRelative": [ + "", + "", + "", + "Gm7", + "Am7b5", + "Bbm7b5", + "", + ], + "substituteDominantSupertonics": [ + "", + "", + "", + "Dbm7", + "Ebm7b5", + "Fbm7b5", + "", + ], + "substituteDominants": [ + "", + "", + "", + "Gb7", + "Ab7", + "Bbb7", + "", + ], + "substituteDominantsMinorRelative": [ + "", + "", + "", + "Dbm7", + "Ebm7b5", + "Fbm7b5", + "", + ], + "tonic": "C", + "triads": [ + "Cm", + "Ddim", + "Ebaug", + "Fm", + "G", + "Ab", + "Bdim", + ], + }, + "keySignature": "bbb", + "melodic": { + "chordScales": [ + "C melodic minor", + "D dorian b2", + "Eb lydian augmented", + "F lydian dominant", + "G mixolydian b6", + "A locrian #2", + "B altered", + ], + "chords": [ + "Cm6", + "Dm7", + "Eb+maj7", + "F7", + "G7", + "Am7b5", + "Bm7b5", + ], + "chordsHarmonicFunction": [ + "T", + "SD", + "T", + "SD", + "D", + "", + "", + ], + "grades": [ + "I", + "II", + "bIII", + "IV", + "V", + "VI", + "VII", + ], + "intervals": [ + "1P", + "2M", + "3m", + "4P", + "5P", + "6M", + "7M", + ], + "scale": [ + "C", + "D", + "Eb", + "F", + "G", + "A", + "B", + ], + "secondaryDominantSupertonics": [ + "", + "Em7", + "", + "Gm7b5", + "Am7b5", + "", + "", + ], + "secondaryDominants": [ + "", + "A7", + "", + "C7", + "D7", + "", + "", + ], + "secondaryDominantsMinorRelative": [ + "", + "Em7", + "", + "Gm7b5", + "Am7b5", + "", + "", + ], + "substituteDominantSupertonics": [ + "", + "Bbm7", + "", + "Dbm7b5", + "Ebm7b5", + "", + "", + ], + "substituteDominants": [ + "", + "Eb7", + "", + "Gb7", + "Ab7", + "", + "", + ], + "substituteDominantsMinorRelative": [ + "", + "Bbm7", + "", + "Dbm7b5", + "Ebm7b5", + "", + "", + ], + "tonic": "C", + "triads": [ + "Cm", + "Dm", + "Ebaug", + "F", + "G", + "Adim", + "Bdim", + ], + }, + "natural": { + "chordScales": [ + "C minor", + "D locrian", + "Eb major", + "F dorian", + "G phrygian", + "Ab lydian", + "Bb mixolydian", + ], + "chords": [ + "Cm7", + "Dm7b5", + "Ebmaj7", + "Fm7", + "Gm7", + "Abmaj7", + "Bb7", + ], + "chordsHarmonicFunction": [ + "T", + "SD", + "T", + "SD", + "D", + "SD", + "SD", + ], + "grades": [ + "I", + "II", + "bIII", + "IV", + "V", + "bVI", + "bVII", + ], + "intervals": [ + "1P", + "2M", + "3m", + "4P", + "5P", + "6m", + "7m", + ], + "scale": [ + "C", + "D", + "Eb", + "F", + "G", + "Ab", + "Bb", + ], + "secondaryDominantSupertonics": [ + "Dm7", + "", + "", + "Gm7", + "Am7", + "Bbm7b5", + "Cm7b5", + ], + "secondaryDominants": [ + "G7", + "", + "", + "C7", + "D7", + "Eb7", + "F7", + ], + "secondaryDominantsMinorRelative": [ + "Dm7", + "", + "", + "Gm7", + "Am7", + "Bbm7b5", + "Cm7b5", + ], + "substituteDominantSupertonics": [ + "Abm7", + "", + "", + "Dbm7", + "Ebm7", + "Fbm7b5", + "Gbm7b5", + ], + "substituteDominants": [ + "Db7", + "", + "", + "Gb7", + "Ab7", + "Bbb7", + "Cb7", + ], + "substituteDominantsMinorRelative": [ + "Abm7", + "", + "", + "Dbm7", + "Ebm7", + "Fbm7b5", + "Gbm7b5", + ], + "tonic": "C", + "triads": [ + "Cm", + "Ddim", + "Eb", + "Fm", + "Gm", + "Ab", + "Bb", + ], + }, + "relativeMajor": "Eb", + "tonic": "C", + "type": "minor", +} +`; + +exports[`@tonal/key minorKey 2`] = ` +{ + "alteration": -5, + "harmonic": { + "chordScales": [ + "Bb harmonic minor", + "C locrian 6", + "Db major augmented", + "Eb lydian diminished", + "F phrygian dominant", + "Gb lydian #9", + "A ultralocrian", + ], + "chords": [ + "BbmMaj7", + "Cm7b5", + "Db+maj7", + "Ebm7", + "F7", + "Gbmaj7", + "Ao7", + ], + "chordsHarmonicFunction": [ + "T", + "SD", + "T", + "SD", + "D", + "SD", + "D", + ], + "grades": [ + "I", + "II", + "bIII", + "IV", + "V", + "bVI", + "VII", + ], + "intervals": [ + "1P", + "2M", + "3m", + "4P", + "5P", + "6m", + "7M", + ], + "scale": [ + "Bb", + "C", + "Db", + "Eb", + "F", + "Gb", + "A", + ], + "secondaryDominantSupertonics": [ + "", + "", + "", + "Fm7", + "Gm7b5", + "Abm7b5", + "", + ], + "secondaryDominants": [ + "", + "", + "", + "Bb7", + "C7", + "Db7", + "", + ], + "secondaryDominantsMinorRelative": [ + "", + "", + "", + "Fm7", + "Gm7b5", + "Abm7b5", + "", + ], + "substituteDominantSupertonics": [ + "", + "", + "", + "Cbm7", + "Dbm7b5", + "Ebbm7b5", + "", + ], + "substituteDominants": [ + "", + "", + "", + "Fb7", + "Gb7", + "Abb7", + "", + ], + "substituteDominantsMinorRelative": [ + "", + "", + "", + "Cbm7", + "Dbm7b5", + "Ebbm7b5", + "", + ], + "tonic": "Bb", + "triads": [ + "Bbm", + "Cdim", + "Dbaug", + "Ebm", + "F", + "Gb", + "Adim", + ], + }, + "keySignature": "bbbbb", + "melodic": { + "chordScales": [ + "Bb melodic minor", + "C dorian b2", + "Db lydian augmented", + "Eb lydian dominant", + "F mixolydian b6", + "G locrian #2", + "A altered", + ], + "chords": [ + "Bbm6", + "Cm7", + "Db+maj7", + "Eb7", + "F7", + "Gm7b5", + "Am7b5", + ], + "chordsHarmonicFunction": [ + "T", + "SD", + "T", + "SD", + "D", + "", + "", + ], + "grades": [ + "I", + "II", + "bIII", + "IV", + "V", + "VI", + "VII", + ], + "intervals": [ + "1P", + "2M", + "3m", + "4P", + "5P", + "6M", + "7M", + ], + "scale": [ + "Bb", + "C", + "Db", + "Eb", + "F", + "G", + "A", + ], + "secondaryDominantSupertonics": [ + "", + "Dm7", + "", + "Fm7b5", + "Gm7b5", + "", + "", + ], + "secondaryDominants": [ + "", + "G7", + "", + "Bb7", + "C7", + "", + "", + ], + "secondaryDominantsMinorRelative": [ + "", + "Dm7", + "", + "Fm7b5", + "Gm7b5", + "", + "", + ], + "substituteDominantSupertonics": [ + "", + "Abm7", + "", + "Cbm7b5", + "Dbm7b5", + "", + "", + ], + "substituteDominants": [ + "", + "Db7", + "", + "Fb7", + "Gb7", + "", + "", + ], + "substituteDominantsMinorRelative": [ + "", + "Abm7", + "", + "Cbm7b5", + "Dbm7b5", + "", + "", + ], + "tonic": "Bb", + "triads": [ + "Bbm", + "Cm", + "Dbaug", + "Eb", + "F", + "Gdim", + "Adim", + ], + }, + "natural": { + "chordScales": [ + "Bb minor", + "C locrian", + "Db major", + "Eb dorian", + "F phrygian", + "Gb lydian", + "Ab mixolydian", + ], + "chords": [ + "Bbm7", + "Cm7b5", + "Dbmaj7", + "Ebm7", + "Fm7", + "Gbmaj7", + "Ab7", + ], + "chordsHarmonicFunction": [ + "T", + "SD", + "T", + "SD", + "D", + "SD", + "SD", + ], + "grades": [ + "I", + "II", + "bIII", + "IV", + "V", + "bVI", + "bVII", + ], + "intervals": [ + "1P", + "2M", + "3m", + "4P", + "5P", + "6m", + "7m", + ], + "scale": [ + "Bb", + "C", + "Db", + "Eb", + "F", + "Gb", + "Ab", + ], + "secondaryDominantSupertonics": [ + "Cm7", + "", + "", + "Fm7", + "Gm7", + "Abm7b5", + "Bbm7b5", + ], + "secondaryDominants": [ + "F7", + "", + "", + "Bb7", + "C7", + "Db7", + "Eb7", + ], + "secondaryDominantsMinorRelative": [ + "Cm7", + "", + "", + "Fm7", + "Gm7", + "Abm7b5", + "Bbm7b5", + ], + "substituteDominantSupertonics": [ + "Gbm7", + "", + "", + "Cbm7", + "Dbm7", + "Ebbm7b5", + "Fbm7b5", + ], + "substituteDominants": [ + "Cb7", + "", + "", + "Fb7", + "Gb7", + "Abb7", + "Bbb7", + ], + "substituteDominantsMinorRelative": [ + "Gbm7", + "", + "", + "Cbm7", + "Dbm7", + "Ebbm7b5", + "Fbm7b5", + ], + "tonic": "Bb", + "triads": [ + "Bbm", + "Cdim", + "Db", + "Ebm", + "Fm", + "Gb", + "Ab", + ], + }, + "relativeMajor": "Db", + "tonic": "Bb", + "type": "minor", +} +`; + +exports[`@tonal/key minorKey 3`] = ` +{ + "alteration": 2, + "harmonic": { + "chordScales": [ + "B harmonic minor", + "C# locrian 6", + "D major augmented", + "E lydian diminished", + "F# phrygian dominant", + "G lydian #9", + "A# ultralocrian", + ], + "chords": [ + "BmMaj7", + "C#m7b5", + "D+maj7", + "Em7", + "F#7", + "Gmaj7", + "A#o7", + ], + "chordsHarmonicFunction": [ + "T", + "SD", + "T", + "SD", + "D", + "SD", + "D", + ], + "grades": [ + "I", + "II", + "bIII", + "IV", + "V", + "bVI", + "VII", + ], + "intervals": [ + "1P", + "2M", + "3m", + "4P", + "5P", + "6m", + "7M", + ], + "scale": [ + "B", + "C#", + "D", + "E", + "F#", + "G", + "A#", + ], + "secondaryDominantSupertonics": [ + "", + "", + "", + "F#m7", + "G#m7b5", + "Am7b5", + "", + ], + "secondaryDominants": [ + "", + "", + "", + "B7", + "C#7", + "D7", + "", + ], + "secondaryDominantsMinorRelative": [ + "", + "", + "", + "F#m7", + "G#m7b5", + "Am7b5", + "", + ], + "substituteDominantSupertonics": [ + "", + "", + "", + "Cm7", + "Dm7b5", + "Ebm7b5", + "", + ], + "substituteDominants": [ + "", + "", + "", + "F7", + "G7", + "Ab7", + "", + ], + "substituteDominantsMinorRelative": [ + "", + "", + "", + "Cm7", + "Dm7b5", + "Ebm7b5", + "", + ], + "tonic": "B", + "triads": [ + "Bm", + "C#dim", + "Daug", + "Em", + "F#", + "G", + "A#dim", + ], + }, + "keySignature": "##", + "melodic": { + "chordScales": [ + "B melodic minor", + "C# dorian b2", + "D lydian augmented", + "E lydian dominant", + "F# mixolydian b6", + "G# locrian #2", + "A# altered", + ], + "chords": [ + "Bm6", + "C#m7", + "D+maj7", + "E7", + "F#7", + "G#m7b5", + "A#m7b5", + ], + "chordsHarmonicFunction": [ + "T", + "SD", + "T", + "SD", + "D", + "", + "", + ], + "grades": [ + "I", + "II", + "bIII", + "IV", + "V", + "VI", + "VII", + ], + "intervals": [ + "1P", + "2M", + "3m", + "4P", + "5P", + "6M", + "7M", + ], + "scale": [ + "B", + "C#", + "D", + "E", + "F#", + "G#", + "A#", + ], + "secondaryDominantSupertonics": [ + "", + "D#m7", + "", + "F#m7b5", + "G#m7b5", + "", + "", + ], + "secondaryDominants": [ + "", + "G#7", + "", + "B7", + "C#7", + "", + "", + ], + "secondaryDominantsMinorRelative": [ + "", + "D#m7", + "", + "F#m7b5", + "G#m7b5", + "", + "", + ], + "substituteDominantSupertonics": [ + "", + "Am7", + "", + "Cm7b5", + "Dm7b5", + "", + "", + ], + "substituteDominants": [ + "", + "D7", + "", + "F7", + "G7", + "", + "", + ], + "substituteDominantsMinorRelative": [ + "", + "Am7", + "", + "Cm7b5", + "Dm7b5", + "", + "", + ], + "tonic": "B", + "triads": [ + "Bm", + "C#m", + "Daug", + "E", + "F#", + "G#dim", + "A#dim", + ], + }, + "natural": { + "chordScales": [ + "B minor", + "C# locrian", + "D major", + "E dorian", + "F# phrygian", + "G lydian", + "A mixolydian", + ], + "chords": [ + "Bm7", + "C#m7b5", + "Dmaj7", + "Em7", + "F#m7", + "Gmaj7", + "A7", + ], + "chordsHarmonicFunction": [ + "T", + "SD", + "T", + "SD", + "D", + "SD", + "SD", + ], + "grades": [ + "I", + "II", + "bIII", + "IV", + "V", + "bVI", + "bVII", + ], + "intervals": [ + "1P", + "2M", + "3m", + "4P", + "5P", + "6m", + "7m", + ], + "scale": [ + "B", + "C#", + "D", + "E", + "F#", + "G", + "A", + ], + "secondaryDominantSupertonics": [ + "C#m7", + "", + "", + "F#m7", + "G#m7", + "Am7b5", + "Bm7b5", + ], + "secondaryDominants": [ + "F#7", + "", + "", + "B7", + "C#7", + "D7", + "E7", + ], + "secondaryDominantsMinorRelative": [ + "C#m7", + "", + "", + "F#m7", + "G#m7", + "Am7b5", + "Bm7b5", + ], + "substituteDominantSupertonics": [ + "Gm7", + "", + "", + "Cm7", + "Dm7", + "Ebm7b5", + "Fm7b5", + ], + "substituteDominants": [ + "C7", + "", + "", + "F7", + "G7", + "Ab7", + "Bb7", + ], + "substituteDominantsMinorRelative": [ + "Gm7", + "", + "", + "Cm7", + "Dm7", + "Ebm7b5", + "Fm7b5", + ], + "tonic": "B", + "triads": [ + "Bm", + "C#dim", + "D", + "Em", + "F#m", + "G", + "A", + ], + }, + "relativeMajor": "D", + "tonic": "B", + "type": "minor", +} +`; diff --git a/packages/key/index.ts b/packages/key/index.ts index eb0ec894..5f99b813 100644 --- a/packages/key/index.ts +++ b/packages/key/index.ts @@ -27,6 +27,15 @@ export interface KeyScale { readonly chords: readonly string[]; readonly chordsHarmonicFunction: readonly string[]; readonly chordScales: readonly string[]; + readonly secondaryDominants: readonly string[]; + readonly secondaryDominantSupertonics: readonly string[]; + readonly substituteDominants: readonly string[]; + readonly substituteDominantSupertonics: readonly string[]; + + // @deprecated use secondaryDominantsSupertonic + readonly secondaryDominantsMinorRelative: readonly string[]; + // @deprecated use substituteDominantSupertonics + readonly substituteDominantsMinorRelative: readonly string[]; } const NoKeyScale: KeyScale = { @@ -38,15 +47,21 @@ const NoKeyScale: KeyScale = { chords: Empty, chordsHarmonicFunction: Empty, chordScales: Empty, + secondaryDominants: Empty, + secondaryDominantSupertonics: Empty, + substituteDominantsMinorRelative: Empty, + substituteDominants: Empty, + substituteDominantSupertonics: Empty, + secondaryDominantsMinorRelative: Empty, }; export interface MajorKey extends Key, KeyScale { readonly type: "major"; readonly minorRelative: string; readonly scale: readonly string[]; - readonly secondaryDominants: readonly string[]; - readonly secondaryDominantsMinorRelative: readonly string[]; readonly substituteDominants: readonly string[]; + readonly secondaryDominantSupertonics: readonly string[]; + // @deprecated use secondaryDominantsSupertonic readonly substituteDominantsMinorRelative: readonly string[]; } @@ -56,9 +71,8 @@ const NoMajorKey: MajorKey = { type: "major", minorRelative: "", scale: Empty, - secondaryDominants: Empty, - secondaryDominantsMinorRelative: Empty, substituteDominants: Empty, + secondaryDominantSupertonics: Empty, substituteDominantsMinorRelative: Empty, }; @@ -79,19 +93,48 @@ const NoMinorKey: MinorKey = { melodic: NoKeyScale, }; +export type KeyChord = { + name: string; + roles: string[]; +}; + const mapScaleToType = (scale: string[], list: string[], sep = "") => list.map((type, i) => `${scale[i]}${sep}${type}`); function keyScale( grades: string[], triads: string[], - chords: string[], + chordTypes: string[], harmonicFunctions: string[], chordScales: string[], ) { return (tonic: string): KeyScale => { const intervals = grades.map((gr) => roman(gr).interval || ""); const scale = intervals.map((interval) => transpose(tonic, interval)); + const chords = mapScaleToType(scale, chordTypes); + const secondaryDominants = scale + .map((note) => transpose(note, "5P")) + .map((note) => + // A secondary dominant is a V chord which: + // 1. is not diatonic to the key, + // 2. it must have a diatonic root. + scale.includes(note) && !chords.includes(note + "7") ? note + "7" : "", + ); + + const secondaryDominantSupertonics = supertonics( + secondaryDominants, + triads, + ); + const substituteDominants = secondaryDominants.map((chord) => { + if (!chord) return ""; + const domRoot = chord.slice(0, -1); + const subRoot = transpose(domRoot, "5d"); + return subRoot + "7"; + }); + const substituteDominantSupertonics = supertonics( + substituteDominants, + triads, + ); return { tonic, @@ -99,13 +142,33 @@ function keyScale( intervals, scale, triads: mapScaleToType(scale, triads), - chords: mapScaleToType(scale, chords), + chords, chordsHarmonicFunction: harmonicFunctions.slice(), chordScales: mapScaleToType(scale, chordScales, " "), + secondaryDominants, + secondaryDominantSupertonics, + substituteDominants, + substituteDominantSupertonics, + + // @deprecated use secondaryDominantsSupertonic + secondaryDominantsMinorRelative: secondaryDominantSupertonics, + // @deprecated use secondaryDominantsSupertonic + substituteDominantsMinorRelative: substituteDominantSupertonics, }; }; } +const supertonics = (dominants: string[], targetTriads: string[]) => { + return dominants.map((chord, index) => { + if (!chord) return ""; + const domRoot = chord.slice(0, -1); + const minorRoot = transpose(domRoot, "5P"); + const target = targetTriads[index]; + const isMinor = target.endsWith("m"); + return isMinor ? minorRoot + "m7" : minorRoot + "m7b5"; + }); +}; + const distInFifths = (from: string, to: string) => { const f = note(from); const t = note(to); @@ -155,12 +218,6 @@ export function majorKey(tonic: string): MajorKey { const keyScale = MajorScale(pc); const alteration = distInFifths("C", pc); - const romanInTonic = (src: string) => { - const r = roman(src); - if (r.empty) return ""; - - return transpose(tonic, r.interval) + r.chordType; - }; return { ...keyScale, @@ -168,19 +225,65 @@ export function majorKey(tonic: string): MajorKey { minorRelative: transpose(pc, "-3m"), alteration, keySignature: altToAcc(alteration), - secondaryDominants: "- VI7 VII7 I7 II7 III7 -".split(" ").map(romanInTonic), - secondaryDominantsMinorRelative: "- IIIm7b5 IV#m7 Vm7 VIm7 VIIm7b5 -" - .split(" ") - .map(romanInTonic), - substituteDominants: "- bIII7 IV7 bV7 bVI7 bVII7 -" - .split(" ") - .map(romanInTonic), - substituteDominantsMinorRelative: "- IIIm7 Im7 IIbm7 VIm7 IVm7 -" - .split(" ") - .map(romanInTonic), }; } +/** + * Get a list of available chords for a given major key + * @param tonic + * @returns array of { name: string, roles: string[] } + */ +export function majorKeyChords(tonic: string): KeyChord[] { + const key = majorKey(tonic); + const chords: KeyChord[] = []; + keyChordsOf(key, chords); + return chords; +} + +/** + * Get a list of available chords for a given major key + * @param tonic + * @returns array of { name: string, roles: string[] } + */ +export function minorKeyChords(tonic: string): KeyChord[] { + const key = minorKey(tonic); + const chords: KeyChord[] = []; + keyChordsOf(key.natural, chords); + keyChordsOf(key.harmonic, chords); + keyChordsOf(key.melodic, chords); + return chords; +} + +function keyChordsOf(key: KeyScale, chords: KeyChord[]) { + const updateChord = (name: string, newRole: string) => { + if (!name) return; + let keyChord = chords.find((chord) => chord.name === name); + if (!keyChord) { + keyChord = { name, roles: [] }; + chords.push(keyChord); + } + if (newRole && !keyChord.roles.includes(newRole)) { + keyChord.roles.push(newRole); + } + }; + + key.chords.forEach((chordName, index) => + updateChord(chordName, key.chordsHarmonicFunction[index]), + ); + key.secondaryDominants.forEach((chordName, index) => + updateChord(chordName, `V/${key.grades[index]}`), + ); + key.secondaryDominantSupertonics.forEach((chordName, index) => + updateChord(chordName, `ii/${key.grades[index]}`), + ); + key.substituteDominants.forEach((chordName, index) => + updateChord(chordName, `subV/${key.grades[index]}`), + ); + key.substituteDominantSupertonics.forEach((chordName, index) => + updateChord(chordName, `subii/${key.grades[index]}`), + ); +} + /** * Get minor key properties in a given tonic * @param tonic diff --git a/packages/key/package.json b/packages/key/package.json index df6b9879..bd7dcc5c 100644 --- a/packages/key/package.json +++ b/packages/key/package.json @@ -1,6 +1,6 @@ { "name": "@tonaljs/key", - "version": "4.10.0", + "version": "4.11.0", "description": "Functions to work with musical keys", "keywords": [ "key", diff --git a/packages/key/test.ts b/packages/key/test.ts index cc8f0323..70a35f56 100644 --- a/packages/key/test.ts +++ b/packages/key/test.ts @@ -2,7 +2,7 @@ import { get as scale } from "@tonaljs/scale"; // tslint:disable-next-line: no-implicit-dependencies import { get as chord } from "@tonaljs/chord"; -import Key from "./index"; +import * as Key from "./index"; describe("@tonal/key", () => { test("fromAlter", () => { @@ -99,7 +99,7 @@ describe("@tonal/key", () => { [ major.chords, major.secondaryDominants, - major.secondaryDominantsMinorRelative, + major.substituteDominantSupertonics, major.substituteDominants, major.substituteDominantsMinorRelative, minor.natural.chords, @@ -115,115 +115,25 @@ describe("@tonal/key", () => { }); }); - test("majorKey", () => { - expect(Key.majorKey("C")).toMatchInlineSnapshot(` - { - "alteration": 0, - "chordScales": [ - "C major", - "D dorian", - "E phrygian", - "F lydian", - "G mixolydian", - "A minor", - "B locrian", - ], - "chords": [ - "Cmaj7", - "Dm7", - "Em7", - "Fmaj7", - "G7", - "Am7", - "Bm7b5", - ], - "chordsHarmonicFunction": [ - "T", - "SD", - "T", - "SD", - "D", - "T", - "D", - ], - "grades": [ - "I", - "II", - "III", - "IV", - "V", - "VI", - "VII", - ], - "intervals": [ - "1P", - "2M", - "3M", - "4P", - "5P", - "6M", - "7M", - ], - "keySignature": "", - "minorRelative": "A", - "scale": [ - "C", - "D", - "E", - "F", - "G", - "A", - "B", - ], - "secondaryDominants": [ - "", - "A7", - "B7", - "C7", - "D7", - "E7", - "", - ], - "secondaryDominantsMinorRelative": [ - "", - "Em7b5", - "F#m7", - "Gm7", - "Am7", - "Bm7b5", - "", - ], - "substituteDominants": [ - "", - "Eb7", - "F7", - "Gb7", - "Ab7", - "Bb7", - "", - ], - "substituteDominantsMinorRelative": [ - "", - "Em7", - "Cm7", - "Dbm7", - "Am7", - "Fm7", - "", - ], - "tonic": "C", - "triads": [ - "C", - "Dm", - "Em", - "F", - "G", - "Am", - "Bdim", - ], - "type": "major", - } - `); + test("C major", () => { + expect(Key.majorKey("C")).toMatchSnapshot(); + }); + test("C major chords", () => { + expect(Key.majorKeyChords("C")).toMatchSnapshot(); + const chords = Key.majorKeyChords("C"); + expect(chords.find((chord) => chord.name === "Em7")).toEqual({ + name: "Em7", + roles: ["T", "ii/II"], + }); + }); + + test.only("C minor chords", () => { + expect(Key.minorKeyChords("C")).toMatchSnapshot(); + }); + test("majorKeys", () => { + expect(Key.majorKey("A")).toMatchSnapshot(); + expect(Key.majorKey("Bb")).toMatchSnapshot(); + expect(Key.majorKey("E")).toMatchSnapshot(); }); test("empty major key ", () => { @@ -237,213 +147,9 @@ describe("@tonal/key", () => { }); test("minorKey", () => { - expect(Key.minorKey("C")).toMatchInlineSnapshot(` - { - "alteration": -3, - "harmonic": { - "chordScales": [ - "C harmonic minor", - "D locrian 6", - "Eb major augmented", - "F lydian diminished", - "G phrygian dominant", - "Ab lydian #9", - "B ultralocrian", - ], - "chords": [ - "CmMaj7", - "Dm7b5", - "Eb+maj7", - "Fm7", - "G7", - "Abmaj7", - "Bo7", - ], - "chordsHarmonicFunction": [ - "T", - "SD", - "T", - "SD", - "D", - "SD", - "D", - ], - "grades": [ - "I", - "II", - "bIII", - "IV", - "V", - "bVI", - "VII", - ], - "intervals": [ - "1P", - "2M", - "3m", - "4P", - "5P", - "6m", - "7M", - ], - "scale": [ - "C", - "D", - "Eb", - "F", - "G", - "Ab", - "B", - ], - "tonic": "C", - "triads": [ - "Cm", - "Ddim", - "Ebaug", - "Fm", - "G", - "Ab", - "Bdim", - ], - }, - "keySignature": "bbb", - "melodic": { - "chordScales": [ - "C melodic minor", - "D dorian b2", - "Eb lydian augmented", - "F lydian dominant", - "G mixolydian b6", - "A locrian #2", - "B altered", - ], - "chords": [ - "Cm6", - "Dm7", - "Eb+maj7", - "F7", - "G7", - "Am7b5", - "Bm7b5", - ], - "chordsHarmonicFunction": [ - "T", - "SD", - "T", - "SD", - "D", - "", - "", - ], - "grades": [ - "I", - "II", - "bIII", - "IV", - "V", - "VI", - "VII", - ], - "intervals": [ - "1P", - "2M", - "3m", - "4P", - "5P", - "6M", - "7M", - ], - "scale": [ - "C", - "D", - "Eb", - "F", - "G", - "A", - "B", - ], - "tonic": "C", - "triads": [ - "Cm", - "Dm", - "Ebaug", - "F", - "G", - "Adim", - "Bdim", - ], - }, - "natural": { - "chordScales": [ - "C minor", - "D locrian", - "Eb major", - "F dorian", - "G phrygian", - "Ab lydian", - "Bb mixolydian", - ], - "chords": [ - "Cm7", - "Dm7b5", - "Ebmaj7", - "Fm7", - "Gm7", - "Abmaj7", - "Bb7", - ], - "chordsHarmonicFunction": [ - "T", - "SD", - "T", - "SD", - "D", - "SD", - "SD", - ], - "grades": [ - "I", - "II", - "bIII", - "IV", - "V", - "bVI", - "bVII", - ], - "intervals": [ - "1P", - "2M", - "3m", - "4P", - "5P", - "6m", - "7m", - ], - "scale": [ - "C", - "D", - "Eb", - "F", - "G", - "Ab", - "Bb", - ], - "tonic": "C", - "triads": [ - "Cm", - "Ddim", - "Eb", - "Fm", - "Gm", - "Ab", - "Bb", - ], - }, - "relativeMajor": "Eb", - "tonic": "C", - "type": "minor", - } - `); + expect(Key.minorKey("C")).toMatchSnapshot(); + expect(Key.minorKey("Bb")).toMatchSnapshot(); + expect(Key.minorKey("B")).toMatchSnapshot(); }); test("empty minor key ", () => { diff --git a/packages/modules/CHANGELOG.md b/packages/modules/CHANGELOG.md index 00878585..f278ef50 100644 --- a/packages/modules/CHANGELOG.md +++ b/packages/modules/CHANGELOG.md @@ -1,5 +1,12 @@ # @tonaljs/modules +## 4.8.8 + +### Patch Changes + +- Updated dependencies [33693a1] + - tonal@6.3.0 + ## 4.8.7 ### Patch Changes diff --git a/packages/modules/package.json b/packages/modules/package.json index 0f302a8e..58f48f70 100644 --- a/packages/modules/package.json +++ b/packages/modules/package.json @@ -1,6 +1,6 @@ { "name": "@tonaljs/modules", - "version": "4.8.7", + "version": "4.8.8", "description": "deprecated", "keywords": [], "main": "dist/index.js", @@ -10,7 +10,7 @@ ], "types": "dist/index.d.ts", "dependencies": { - "tonal": "6.2.0" + "tonal": "6.3.0" }, "author": "danigb@gmail.com", "license": "MIT", diff --git a/packages/tonal/__snapshots__/test.ts.snap b/packages/tonal/__snapshots__/test.ts.snap index 9d1dedbe..bdc1650f 100644 --- a/packages/tonal/__snapshots__/test.ts.snap +++ b/packages/tonal/__snapshots__/test.ts.snap @@ -112,8 +112,10 @@ exports[`tonal Modules exports functions 1`] = ` ], "Key": [ "majorKey", + "majorKeyChords", "majorTonicFromKeySignature", "minorKey", + "minorKeyChords", ], "Midi": [ "chroma", diff --git a/packages/tonal/browser/tonal.min.js b/packages/tonal/browser/tonal.min.js index 030a1b2c..83a8f207 100644 --- a/packages/tonal/browser/tonal.min.js +++ b/packages/tonal/browser/tonal.min.js @@ -1,2 +1,2 @@ -"use strict";var Tonal=(()=>{var Ot=Object.defineProperty;var Po=Object.getOwnPropertyDescriptor;var Mo=Object.getOwnPropertyNames;var ho=Object.prototype.hasOwnProperty;var f=(t,n)=>{for(var e in n)Ot(t,e,{get:n[e],enumerable:!0})},vo=(t,n,e,r)=>{if(n&&typeof n=="object"||typeof n=="function")for(let o of Mo(n))!ho.call(t,o)&&o!==e&&Ot(t,o,{get:()=>n[o],enumerable:!(r=Po(n,o))||r.enumerable});return t};var yo=t=>vo(Ot({},"__esModule",{value:!0}),t);var Mi={};f(Mi,{AbcNotation:()=>Ut,Array:()=>Ht,Chord:()=>rn,ChordDictionary:()=>pi,ChordType:()=>dt,Collection:()=>Xt,Core:()=>Rt,DurationValue:()=>on,Interval:()=>tn,Key:()=>Pn,Midi:()=>sn,Mode:()=>An,Note:()=>fn,PcSet:()=>di,Pcset:()=>ft,Progression:()=>gn,Range:()=>Sn,RhythmPattern:()=>jn,RomanNumeral:()=>dn,Scale:()=>En,ScaleDictionary:()=>Pi,ScaleType:()=>gt,TimeSignature:()=>Dn,Tonal:()=>fi,VoiceLeading:()=>wn,Voicing:()=>qn,VoicingDictionary:()=>Rn,accToAlt:()=>L,altToAcc:()=>F,chroma:()=>zn,coordToInterval:()=>q,coordToNote:()=>ct,coordinates:()=>K,deprecate:()=>Ln,distance:()=>y,fillStr:()=>co,height:()=>kt,interval:()=>l,isNamed:()=>uo,isNamedPitch:()=>C,isPitch:()=>V,midi:()=>Bn,note:()=>s,pitch:()=>X,stepToLetter:()=>Gt,tokenizeInterval:()=>qt,tokenizeNote:()=>Q,tonicIntervalsTransposer:()=>R,transpose:()=>d});var Ut={};f(Ut,{abcToScientificNotation:()=>nt,default:()=>Vo,distance:()=>ee,scientificToAbcNotation:()=>Bt,tokenize:()=>zt,transpose:()=>ne});function C(t){return t!==null&&typeof t=="object"&&"name"in t&&typeof t.name=="string"}var Gn=[0,2,4,5,7,9,11],zn=({step:t,alt:n})=>(Gn[t]+n+120)%12,kt=({step:t,alt:n,oct:e,dir:r=1})=>r*(Gn[t]+n+12*(e===void 0?-100:e)),Bn=t=>{let n=kt(t);return t.oct!==void 0&&n>=-12&&n<=115?n+12:null};function V(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 Un=[0,2,4,-1,1,3,5],Hn=Un.map(t=>Math.floor(t*7/12));function K(t){let{step:n,alt:e,oct:r,dir:o=1}=t,a=Un[n]+7*e;if(r===void 0)return[o*a];let i=r-Hn[n]-4*e;return[o*a,o*i]}var bo=[3,0,4,1,5,2,6];function X(t){let[n,e,r]=t,o=bo[Ao(n)],a=Math.floor((n+1)/7);if(e===void 0)return{step:o,alt:a,dir:r};let i=e+4*a+Hn[o];return{step:o,alt:a,oct:i,dir:r}}function Ao(t){let n=(t+1)%7;return n<0?7+n:n}var Kn=(t,n)=>Array(Math.abs(n)+1).join(t),$t=Object.freeze({empty:!0,name:"",num:NaN,q:"",type:"",step:NaN,alt:NaN,dir:NaN,simple:NaN,semitones:NaN,chroma:NaN,coord:[],oct:NaN}),go="([-+]?\\d+)(d{1,4}|m|M|P|A{1,4})",No="(AA|A|P|M|m|d|dd)([-+]?\\d+)",Io=new RegExp("^"+go+"|"+No+"$");function qt(t){let n=Io.exec(`${t}`);return n===null?["",""]:n[1]?[n[1],n[2]]:[n[4],n[3]]}var Xn={};function l(t){return typeof t=="string"?Xn[t]||(Xn[t]=So(t)):V(t)?l(To(t)):C(t)?l(t.name):$t}var Qn=[0,2,4,5,7,9,11],Jn="PMMPPMM";function So(t){let n=qt(t);if(n[0]==="")return $t;let e=+n[0],r=n[1],o=(Math.abs(e)-1)%7,a=Jn[o];if(a==="M"&&r==="P")return $t;let i=a==="M"?"majorable":"perfectable",m=""+e+r,c=e<0?-1:1,u=e===8||e===-8?e:c*(o+1),M=jo(i,r),v=Math.floor((Math.abs(e)-1)/7),p=c*(Qn[o]+M+12*v),x=(c*(Qn[o]+M)%12+12)%12,h=K({step:o,alt:M,oct:v,dir:c});return{empty:!1,name:m,num:e,q:r,step:o,alt:M,dir:c,type:i,simple:u,semitones:p,chroma:x,coord:h,oct:v}}function q(t,n){let[e,r=0]=t,o=e*7+r*12<0,a=n||o?[-e,-r,-1]:[e,r,1];return l(X(a))}function jo(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 To(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?"-":"",c=Jn[n]==="M"?"majorable":"perfectable";return m+i+xo(c,e)}function xo(t,n){return n===0?t==="majorable"?"M":"P":n===-1&&t==="majorable"?"m":n>0?Kn("A",n):Kn("d",t==="perfectable"?n:n+1)}var Zn=(t,n)=>Array(Math.abs(n)+1).join(t),Yn=Object.freeze({empty:!0,name:"",letter:"",acc:"",pc:"",step:NaN,alt:NaN,chroma:NaN,height:NaN,coord:[],midi:null,freq:null}),Wn=new Map,Gt=t=>"CDEFGAB".charAt(t),F=t=>t<0?Zn("b",-t):Zn("#",t),L=t=>t[0]==="b"?-t.length:t.length;function s(t){let n=JSON.stringify(t),e=Wn.get(n);if(e)return e;let r=typeof t=="string"?Do(t):V(t)?s(_o(t)):C(t)?s(t.name):Yn;return Wn.set(n,r),r}var Co=/^([a-gA-G]?)(#{1,}|b{1,}|x{1,}|)(-?\d*)\s*(.*)$/;function Q(t){let n=Co.exec(t);return n?[n[1].toUpperCase(),n[2].replace(/x/g,"##"),n[3],n[4]]:["","","",""]}function ct(t){return s(X(t))}var Eo=(t,n)=>(t%n+n)%n,Lt=[0,2,4,5,7,9,11];function Do(t){let n=Q(t);if(n[0]===""||n[3]!=="")return Yn;let e=n[0],r=n[1],o=n[2],a=(e.charCodeAt(0)+3)%7,i=L(r),m=o.length?+o:void 0,c=K({step:a,alt:i,oct:m}),u=e+r+o,M=e+r,v=(Lt[a]+i+120)%12,p=m===void 0?Eo(Lt[a]+i,12)-12*99:Lt[a]+i+12*(m+1),x=p>=0&&p<=127?p:null,h=m===void 0?null:Math.pow(2,(p-69)/12)*440;return{empty:!1,acc:r,alt:i,chroma:v,coord:c,freq:h,height:p,letter:e,midi:x,name:u,oct:m,pc:M,step:a}}function _o(t){let{step:n,alt:e,oct:r}=t,o=Gt(n);if(!o)return"";let a=o+F(e);return r||r===0?a+r:a}function d(t,n){let e=s(t),r=Array.isArray(n)?n:l(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 ct(a).name}function R(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=d(n,[0,a]);return d(i,t[o])}}function y(t,n){let e=s(t),r=s(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),c=r.height===e.height&&r.midi!==null&&e.oct===r.oct&&e.step>r.step;return q([i,m],c).name}var te=(t,n)=>Array(n+1).join(t),wo=/^(_{1,}|=|\^{1,}|)([abcdefgABCDEFG])([,']*)$/;function zt(t){let n=wo.exec(t);return n?[n[1],n[2],n[3]]:["","",""]}function nt(t){let[n,e,r]=zt(t);if(e==="")return"";let o=4;for(let i=0;i96?e.toUpperCase()+a+(o+1):e+a+o}function Bt(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,"^"),i=o>4?e.toLowerCase():e,m=o===5?"":o>4?te("'",o-5):te(",",4-o);return a+i+m}function ne(t,n){return Bt(d(nt(t),n))}function ee(t,n){return y(nt(t),nt(n))}var Vo={abcToScientificNotation:nt,scientificToAbcNotation:Bt,tokenize:zt,transpose:ne,distance:ee};var Ht={};f(Ht,{compact:()=>$o,permutations:()=>oe,range:()=>Oo,rotate:()=>ko,shuffle:()=>Lo,sortedNoteNames:()=>re,sortedUniqNoteNames:()=>qo});function Fo(t,n){let e=[];for(;n--;e[n]=n+t);return e}function Ro(t,n){let e=[];for(;n--;e[n]=t-n);return e}function Oo(t,n){return tn===0||n)}function re(t){return t.map(e=>s(e)).filter(e=>!e.empty).sort((e,r)=>e.height-r.height).map(e=>e.name)}function qo(t){return re(t).filter((n,e,r)=>e===0||n!==r[e-1])}function Lo(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 oe(t){return t.length===0?[[]]:oe(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 rn={};f(rn,{chord:()=>$e,chordScales:()=>Le,default:()=>at,degrees:()=>Ue,detect:()=>pt,extended:()=>Ge,get:()=>w,getChord:()=>ot,notes:()=>Be,reduced:()=>ze,steps:()=>He,tokenize:()=>Y,transpose:()=>qe});var dt={};f(dt,{add:()=>Jt,addAlias:()=>Ae,all:()=>D,chordType:()=>Pe,default:()=>aa,entries:()=>ye,get:()=>rt,keys:()=>ve,names:()=>Me,removeAll:()=>be,symbols:()=>he});var ft={};f(ft,{EmptyPcset:()=>I,chroma:()=>ut,chromas:()=>fe,default:()=>Zo,filter:()=>pe,get:()=>P,includes:()=>Jo,intervals:()=>ce,isChroma:()=>et,isEqual:()=>de,isNoteIncludedIn:()=>lt,isSubsetOf:()=>G,isSupersetOf:()=>z,modes:()=>Z,notes:()=>le,num:()=>ue,pcset:()=>se});var Xt={};f(Xt,{compact:()=>J,default:()=>Bo,permutations:()=>Kt,range:()=>O,rotate:()=>E,shuffle:()=>ae});function Go(t,n){let e=[];for(;n--;e[n]=n+t);return e}function zo(t,n){let e=[];for(;n--;e[n]=t-n);return e}function O(t,n){return tn===0||n)}function ae(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 Kt(t){return t.length===0?[[]]:Kt(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 Bo={compact:J,permutations:Kt,range:O,rotate:E,shuffle:ae};var I={empty:!0,name:"",setNum:0,chroma:"000000000000",normalized:"000000000000",intervals:[]},Qt=t=>Number(t).toString(2).padStart(12,"0"),ie=t=>parseInt(t,2),Uo=/^[01]{12}$/;function et(t){return Uo.test(t)}var Ho=t=>typeof t=="number"&&t>=0&&t<=4095,Ko=t=>t&&et(t.chroma),me={[I.chroma]:I};function P(t){let n=et(t)?t:Ho(t)?Qt(t):Array.isArray(t)?ta(t):Ko(t)?t.chroma:I.chroma;return me[n]=me[n]||Yo(n)}var se=P,ut=t=>P(t).chroma,ce=t=>P(t).intervals,ue=t=>P(t).setNum,Xo=["1P","2m","2M","3m","3M","4P","5d","5P","6m","6M","7m","7M"];function Qo(t){let n=[];for(let e=0;e<12;e++)t.charAt(e)==="1"&&n.push(Xo[e]);return n}function le(t){return P(t).intervals.map(n=>d("C",n))}function fe(){return O(2048,4095).map(Qt)}function Z(t,n=!0){let r=P(t).chroma.split("");return J(r.map((o,a)=>{let i=E(a,r);return n&&i[0]==="0"?null:i.join("")}))}function de(t,n){return P(t).setNum===P(n).setNum}function G(t){let n=P(t).setNum;return e=>{let r=P(e).setNum;return n&&n!==r&&(r&n)===r}}function z(t){let n=P(t).setNum;return e=>{let r=P(e).setNum;return n&&n!==r&&(r|n)===r}}function lt(t){let n=P(t);return e=>{let r=s(e);return n&&!r.empty&&n.chroma.charAt(r.chroma)==="1"}}var Jo=lt;function pe(t){let n=lt(t);return e=>e.filter(n)}var Zo={get:P,chroma:ut,num:ue,intervals:ce,chromas:fe,isSupersetOf:z,isSubsetOf:G,isNoteIncludedIn:lt,isEqual:de,filter:pe,modes:Z,notes:le,pcset:se};function Wo(t){let n=t.split("");return n.map((e,r)=>E(r,n).join(""))}function Yo(t){let n=ie(t),e=Wo(t).map(ie).filter(a=>a>=2048).sort()[0],r=Qt(e),o=Qo(t);return{empty:!1,name:"",setNum:n,chroma:t,normalized:r,intervals:o}}function ta(t){if(t.length===0)return I.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 he(){return W.map(t=>t.aliases[0]).filter(t=>t)}function ve(){return Object.keys(B)}function D(){return W.slice()}var ye=D;function be(){W=[],B={}}function Jt(t,n,e){let r=oa(t),o={...P(t),name:e||"",quality:r,intervals:t,aliases:n};W.push(o),o.name&&(B[o.name]=o),B[o.setNum]=o,B[o.chroma]=o,o.aliases.forEach(a=>Ae(o,a))}function Ae(t,n){B[n]=t}function oa(t){let n=e=>t.indexOf(e)!==-1;return n("5A")?"Augmented":n("3M")?"Major":n("5d")?"Diminished":n("3m")?"Minor":"Unknown"}ea.forEach(([t,n,e])=>Jt(t.split(" "),e.split(" "),n));W.sort((t,n)=>t.setNum-n.setNum);var aa={names:Me,symbols:he,get:rt,all:D,add:Jt,removeAll:be,keys:ve,entries:ye,chordType:Pe};var ia=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 pt(t,n={}){let e=t.map(o=>s(o).pc).filter(o=>o);return s.length===0?[]:da(e,1,n).filter(o=>o.weight).sort((o,a)=>a.weight-o.weight).map(o=>o.name)}var Pt={anyThirds:384,perfectFifth:16,nonPerfectFifths:40,anySeventh:3},Mt=t=>n=>!!(n&t),ma=Mt(Pt.anyThirds),sa=Mt(Pt.perfectFifth),ca=Mt(Pt.anySeventh),ua=Mt(Pt.nonPerfectFifths);function la(t){let n=parseInt(t.chroma,2);return ma(n)&&sa(n)&&ca(n)}function fa(t){let n=parseInt(t,2);return ua(n)?t:(n|16).toString(2)}function da(t,n,e){let r=t[0],o=s(r).chroma,a=ia(t),i=Z(t,!1),m=[];return i.forEach((c,u)=>{let M=e.assumePerfectFifth&&fa(c);D().filter(p=>e.assumePerfectFifth&&la(p)?p.chroma===M:p.chroma===c).forEach(p=>{let x=p.aliases[0],h=a(u);u!==o?m.push({weight:.5*n,name:`${h}${x}/${r}`}):m.push({weight:1*n,name:`${h}${x}`})})}),m}var tn={};f(tn,{add:()=>Wt,addTo:()=>Ee,default:()=>Yt,distance:()=>Ce,fromSemitones:()=>xe,get:()=>Zt,invert:()=>Te,name:()=>Ne,names:()=>ge,num:()=>je,quality:()=>Se,semitones:()=>Ie,simplify:()=>ht,subtract:()=>vt,transposeFifths:()=>yt});function ge(){return"1P 2M 3M 4P 5P 6m 7m".split(" ")}var Zt=l,Ne=t=>l(t).name,Ie=t=>l(t).semitones,Se=t=>l(t).q,je=t=>l(t).num;function ht(t){let n=l(t);return n.empty?"":n.simple+n.q}function Te(t){let n=l(t);if(n.empty)return"";let e=(7-n.step)%7,r=n.type==="perfectable"?-n.alt:-(n.alt+1);return l({step:e,alt:r,oct:n.oct,dir:n.dir}).name}var pa=[1,2,2,3,3,4,5,5,6,6,7,7],Pa="P m M m M P d P m M m M".split(" ");function xe(t){let n=t<0?-1:1,e=Math.abs(t),r=e%12,o=Math.floor(e/12);return n*(pa[r]+7*o)+Pa[r]}var Ce=y,Wt=De((t,n)=>[t[0]+n[0],t[1]+n[1]]),Ee=t=>n=>Wt(t,n),vt=De((t,n)=>[t[0]-n[0],t[1]-n[1]]);function yt(t,n){let e=Zt(t);if(e.empty)return"";let[r,o,a]=e.coord;return q([r+n,o,a]).name}var Yt={names:ge,get:Zt,name:Ne,num:je,semitones:Ie,quality:Se,fromSemitones:xe,distance:Ce,invert:Te,simplify:ht,add:Wt,addTo:Ee,subtract:vt,transposeFifths:yt};function De(t){return(n,e)=>{let r=l(n).coord,o=l(e).coord;if(r&&o){let a=t(r,o);return q(a).name}}}var gt={};f(gt,{NoScaleType:()=>_e,add:()=>nn,addAlias:()=>Oe,all:()=>_,default:()=>va,entries:()=>Ve,get:()=>H,keys:()=>Fe,names:()=>At,removeAll:()=>Re,scaleType:()=>we});var Ma=[["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"]],ha=Ma,_e={...I,intervals:[],aliases:[]},bt=[],U={};function At(){return bt.map(t=>t.name)}function H(t){return U[t]||_e}var we=H;function _(){return bt.slice()}var Ve=_;function Fe(){return Object.keys(U)}function Re(){bt=[],U={}}function nn(t,n,e=[]){let r={...P(t),name:n,intervals:t,aliases:e};return bt.push(r),U[r.name]=r,U[r.setNum]=r,U[r.chroma]=r,r.aliases.forEach(o=>Oe(r,o)),r}function Oe(t,n){U[n]=t}ha.forEach(([t,n,...e])=>nn(t.split(" "),n,e));var va={names:At,get:H,all:_,add:nn,removeAll:Re,keys:Fe,entries:Ve,scaleType:we};var ke={empty:!0,name:"",symbol:"",root:"",bass:"",rootDegree:0,type:"",tonic:null,setNum:NaN,quality:"Unknown",chroma:"",normalized:"",aliases:[],notes:[],intervals:[]};function Y(t){let[n,e,r,o]=Q(t);return n===""?en("",t):n==="A"&&o==="ug"?en("","aug"):en(n+e,r+o)}function en(t,n){let e=n.split("/");if(e.length===1)return[t,e[0],""];let[r,o,a,i]=Q(e[1]);return r!==""&&a===""&&i===""?[t,e[0],r+o]:[t,n,""]}function w(t){if(Array.isArray(t))return ot(t[1]||"",t[0],t[2]);if(t==="")return ke;{let[n,e,r]=Y(t),o=ot(e,n,r);return o.empty?ot(t):o}}function ot(t,n,e){let r=rt(t),o=s(n||""),a=s(e||"");if(r.empty||n&&o.empty||e&&a.empty)return ke;let i=y(o.pc,a.pc),m=r.intervals.indexOf(i),c=m>=0,u=c?a:s(""),M=m===-1?NaN:m+1,v=a.pc&&a.pc!==o.pc,p=Array.from(r.intervals);if(c)for(let $=1;$d(o.pc,$));t=r.aliases.indexOf(t)!==-1?t:r.aliases[0];let h=`${o.empty?"":o.pc}${t}${c&&M>1?"/"+u.pc:v?"/"+a.pc:""}`,st=`${n?o.pc+" ":""}${r.name}${c&&M>1?" over "+u.pc:v?" over "+a.pc:""}`;return{...r,name:st,symbol:h,tonic:o.pc,type:r.name,root:u.pc,bass:v?a.pc:"",intervals:p,rootDegree:M,notes:x}}var $e=w;function qe(t,n){let[e,r,o]=Y(t);if(!e)return t;let a=d(o,n),i=a?"/"+a:"";return d(e,n)+r+i}function Le(t){let n=w(t),e=z(n.chroma);return _().filter(r=>e(r.chroma)).map(r=>r.name)}function Ge(t){let n=w(t),e=z(n.chroma);return D().filter(r=>e(r.chroma)).map(r=>n.tonic+r.aliases[0])}function ze(t){let n=w(t),e=G(n.chroma);return D().filter(r=>e(r.chroma)).map(r=>n.tonic+r.aliases[0])}function Be(t,n){let e=w(t),r=n||e.tonic;return!r||e.empty?[]:e.intervals.map(o=>d(r,o))}function Ue(t,n){let e=w(t),r=n||e.tonic,o=R(e.intervals,r);return a=>a?o(a>0?a-1:a):""}function He(t,n){let e=w(t),r=n||e.tonic;return R(e.intervals,r)}var at={getChord:ot,get:w,detect:pt,chordScales:Le,extended:Ge,reduced:ze,tokenize:Y,transpose:qe,degrees:Ue,steps:He,notes:Be,chord:$e};var on={};f(on,{default:()=>Na,fraction:()=>Je,get:()=>It,names:()=>Ke,shorthands:()=>Xe,value:()=>Qe});var ya=[[.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"]]],ba=ya,Nt=[];ba.forEach(([t,n,e])=>Ia(t,n,e));var Aa={empty:!0,name:"",value:0,fraction:[0,0],shorthand:"",dots:"",names:[]};function Ke(){return Nt.reduce((t,n)=>(n.names.forEach(e=>t.push(e)),t),[])}function Xe(){return Nt.map(t=>t.shorthand)}var ga=/^([^.]+)(\.*)$/;function It(t){let[n,e,r]=ga.exec(t)||[],o=Nt.find(m=>m.shorthand===e||m.names.includes(e));if(!o)return Aa;let a=Sa(o.fraction,r.length),i=a[0]/a[1];return{...o,name:t,dots:r,value:i,fraction:a}}var Qe=t=>It(t).value,Je=t=>It(t).fraction,Na={names:Ke,shorthands:Xe,get:It,value:Qe,fraction:Je};function Ia(t,n,e){Nt.push({empty:!1,dots:"",name:"",value:1/t,fraction:t<1?[1/t,1]:[1,t],shorthand:n,names:e})}function Sa(t,n){let e=Math.pow(2,n),r=t[0]*e,o=t[1]*e,a=r;for(let i=0;iUa,majorKey:()=>Cr,majorTonicFromKeySignature:()=>Dr,minorKey:()=>Er});var fn={};f(fn,{accidentals:()=>ar,ascending:()=>Ct,chroma:()=>cr,default:()=>A,descending:()=>yr,distance:()=>dr,enharmonic:()=>Dt,freq:()=>sr,fromFreq:()=>ur,fromFreqSharps:()=>lr,fromMidi:()=>xt,fromMidiSharps:()=>fr,get:()=>b,midi:()=>mr,name:()=>rr,names:()=>er,octave:()=>ir,pitchClass:()=>or,simplify:()=>br,sortedNames:()=>ln,sortedUniqNames:()=>Et,tr:()=>pr,trBy:()=>Pr,trFifths:()=>hr,trFrom:()=>Mr,transpose:()=>j,transposeBy:()=>cn,transposeFifths:()=>tt,transposeFrom:()=>un,transposeOctaves:()=>vr});var sn={};f(sn,{chroma:()=>jt,default:()=>_a,freqToMidi:()=>it,isMidi:()=>an,midiToFreq:()=>Ze,midiToNoteName:()=>S,pcset:()=>Tt,pcsetDegrees:()=>Ye,pcsetNearest:()=>We,pcsetSteps:()=>mn,toMidi:()=>St});function an(t){return+t>=0&&+t<=127}function St(t){if(an(t))return+t;let n=s(t);return n.empty?null:n.midi}function Ze(t,n=440){return Math.pow(2,(t-69)/12)*n}var ja=Math.log(2),Ta=Math.log(440);function it(t){let n=12*(Math.log(t)-Ta)/ja+69;return Math.round(n*100)/100}var xa="C C# D D# E F F# G G# A A# B".split(" "),Ca="C Db D Eb E F Gb G Ab A Bb B".split(" ");function S(t,n={}){if(isNaN(t)||t===-1/0||t===1/0)return"";t=Math.round(t);let r=(n.sharps===!0?xa:Ca)[t%12];if(n.pitchClass)return r;let o=Math.floor(t/12)-1;return r+o}function jt(t){return t%12}function Ea(t){return t.split("").reduce((n,e,r)=>(r<12&&e==="1"&&n.push(r),n),[])}function Da(t){return t.map(jt).sort((n,e)=>n-e).filter((n,e,r)=>e===0||n!==r[e-1])}function Tt(t){return Array.isArray(t)?Da(t):Ea(t)}function We(t){let n=Tt(t);return e=>{let r=jt(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 mn(t,n){let e=Tt(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 Ye(t,n){let e=mn(t,n);return r=>{if(r!==0)return e(r>0?r-1:r)}}var _a={chroma:jt,freqToMidi:it,isMidi:an,midiToFreq:Ze,midiToNoteName:S,pcsetNearest:We,pcset:Tt,pcsetDegrees:Ye,pcsetSteps:mn,toMidi:St};var wa=["C","D","E","F","G","A","B"],tr=t=>t.name,nr=t=>t.map(s).filter(n=>!n.empty);function er(t){return t===void 0?wa.slice():Array.isArray(t)?nr(t).map(tr):[]}var b=s,rr=t=>b(t).name,or=t=>b(t).pc,ar=t=>b(t).acc,ir=t=>b(t).oct,mr=t=>b(t).midi,sr=t=>b(t).freq,cr=t=>b(t).chroma;function xt(t){return S(t)}function ur(t){return S(it(t))}function lr(t){return S(it(t),{sharps:!0})}function fr(t){return S(t,{sharps:!0})}var dr=y,j=d,pr=d,cn=t=>n=>j(n,t),Pr=cn,un=t=>n=>j(t,n),Mr=un;function tt(t,n){return j(t,[n,0])}var hr=tt;function vr(t,n){return j(t,[0,n])}var Ct=(t,n)=>t.height-n.height,yr=(t,n)=>n.height-t.height;function ln(t,n){return n=n||Ct,nr(t).sort(n).map(tr)}function Et(t){return ln(t,Ct).filter((n,e,r)=>e===0||n!==r[e-1])}var br=t=>{let n=b(t);return n.empty?"":S(n.midi||n.chroma,{sharps:n.alt>0,pitchClass:n.midi===null})};function Dt(t,n){let e=b(t);if(e.empty)return"";let r=b(n||S(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 A={names:er,get:b,name:rr,pitchClass:or,accidentals:ar,octave:ir,midi:mr,ascending:Ct,descending:yr,distance:dr,sortedNames:ln,sortedUniqNames:Et,fromMidi:xt,fromMidiSharps:fr,freq:sr,fromFreq:ur,fromFreqSharps:lr,chroma:cr,transpose:j,tr:pr,transposeBy:cn,trBy:Pr,transposeFrom:un,trFrom:Mr,transposeFifths:tt,transposeOctaves:vr,trFifths:hr,simplify:br,enharmonic:Dt};var dn={};f(dn,{default:()=>ka,get:()=>g,names:()=>Ir,romanNumeral:()=>Nr,tokenize:()=>Sr});var gr={empty:!0,name:"",chordType:""},Ar={};function g(t){return typeof t=="string"?Ar[t]||(Ar[t]=Oa(t)):typeof t=="number"?g(_t[t]||""):V(t)?Va(t):C(t)?g(t.name):gr}var Nr=g;function Ir(t=!0){return(t?_t:Ra).slice()}function Va(t){return g(F(t.alt)+_t[t.step])}var Fa=/^(#{1,}|b{1,}|x{1,}|)(IV|I{1,3}|VI{0,2}|iv|i{1,3}|vi{0,2})([^IViv]*)$/;function Sr(t){return Fa.exec(t)||["","","",""]}var jr="I II III IV V VI VII",_t=jr.split(" "),Ra=jr.toLowerCase().split(" ");function Oa(t){let[n,e,r,o]=Sr(t);if(!r)return gr;let a=r.toUpperCase(),i=_t.indexOf(a),m=L(e),c=1;return{empty:!1,name:n,roman:r,interval:l({step:i,alt:m,dir:c}).name,acc:e,chordType:o,alt:m,step:i,major:r===a,oct:0,dir:c}}var ka={names:Ir,get:g,romanNumeral:Nr};var N=Object.freeze([]),Tr={type:"major",tonic:"",alteration:0,keySignature:""},wt={tonic:"",grades:N,intervals:N,scale:N,triads:N,chords:N,chordsHarmonicFunction:N,chordScales:N},$a={...Tr,...wt,type:"major",minorRelative:"",scale:N,secondaryDominants:N,secondaryDominantsMinorRelative:N,substituteDominants:N,substituteDominantsMinorRelative:N},qa={...Tr,type:"minor",relativeMajor:"",natural:wt,harmonic:wt,melodic:wt},pn=(t,n,e="")=>n.map((r,o)=>`${t[o]}${e}${r}`);function Vt(t,n,e,r,o){return a=>{let i=t.map(c=>g(c).interval||""),m=i.map(c=>j(a,c));return{tonic:a,grades:t,intervals:i,scale:m,triads:pn(m,n),chords:pn(m,e),chordsHarmonicFunction:r.slice(),chordScales:pn(m,o," ")}}}var xr=(t,n)=>{let e=s(t),r=s(n);return e.empty||r.empty?0:r.coord[0]-e.coord[0]},La=Vt("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(",")),Ga=Vt("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(",")),za=Vt("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(",")),Ba=Vt("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 Cr(t){let n=s(t).pc;if(!n)return $a;let e=La(n),r=xr("C",n),o=a=>{let i=g(a);return i.empty?"":j(t,i.interval)+i.chordType};return{...e,type:"major",minorRelative:j(n,"-3m"),alteration:r,keySignature:F(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 Er(t){let n=s(t).pc;if(!n)return qa;let e=xr("C",n)-3;return{type:"minor",tonic:n,relativeMajor:j(n,"3m"),alteration:e,keySignature:F(e),natural:Ga(n),harmonic:za(n),melodic:Ba(n)}}function Dr(t){return typeof t=="number"?tt("C",t):typeof t=="string"&&/^b+|#+$/.test(t)?tt("C",L(t)):null}var Ua={majorKey:Cr,majorTonicFromKeySignature:Dr,minorKey:Er};var An={};f(An,{all:()=>yn,default:()=>Ka,distance:()=>bn,entries:()=>Vr,get:()=>k,mode:()=>wr,names:()=>Fr,notes:()=>Rr,relativeTonic:()=>qr,seventhChords:()=>$r,triads:()=>kr});var hn=[[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"]],_r={...I,name:"",alt:0,modeNum:NaN,triad:"",seventh:"",aliases:[]},vn=hn.map(Ha),Mn={};vn.forEach(t=>{Mn[t.name]=t,t.aliases.forEach(n=>{Mn[n]=t})});function k(t){return typeof t=="string"?Mn[t.toLowerCase()]||_r:t&&t.name?k(t.name):_r}var wr=k;function yn(){return vn.slice()}var Vr=yn;function Fr(){return vn.map(t=>t.name)}function Ha(t){let[n,e,r,o,a,i,m]=t,c=m?[m]:[],u=Number(e).toString(2);return{empty:!1,intervals:H(o).intervals,modeNum:n,chroma:u,normalized:u,name:o,setNum:e,alt:r,triad:a,seventh:i,aliases:c}}function Rr(t,n){return k(t).intervals.map(e=>d(n,e))}function Or(t){return(n,e)=>{let r=k(n);if(r.empty)return[];let o=E(r.modeNum,t),a=r.intervals.map(i=>d(e,i));return o.map((i,m)=>a[m]+i)}}var kr=Or(hn.map(t=>t[4])),$r=Or(hn.map(t=>t[5]));function bn(t,n){let e=k(n),r=k(t);return e.empty||r.empty?"":ht(yt("1P",r.alt-e.alt))}function qr(t,n,e){return d(e,bn(t,n))}var Ka={get:k,names:Fr,all:yn,distance:bn,relativeTonic:qr,notes:Rr,triads:kr,seventhChords:$r,entries:Vr,mode:wr};var gn={};f(gn,{default:()=>Xa,fromRomanNumerals:()=>Lr,toRomanNumerals:()=>Gr});function Lr(t,n){return n.map(g).map(r=>d(t,l(r))+r.chordType)}function Gr(t,n){return n.map(e=>{let[r,o]=Y(e),a=y(t,r);return g(l(a)).name+o})}var Xa={fromRomanNumerals:Lr,toRomanNumerals:Gr};var Sn={};f(Sn,{chromatic:()=>zr,default:()=>In,numeric:()=>Nn});function Nn(t){let n=J(t.map(e=>typeof e=="number"?e:St(e)));return!t.length||n.length!==t.length?[]:n.reduce((e,r)=>{let o=e[e.length-1];return e.concat(O(o,r).slice(1))},[n[0]])}function zr(t,n){return Nn(t).map(e=>S(e,n))}var In={numeric:Nn,chromatic:zr};var jn={};f(jn,{binary:()=>Qa,euclid:()=>ni,hex:()=>Ja,onsets:()=>Za,probability:()=>Ya,random:()=>Wa,rotate:()=>ti});function Qa(...t){return t.reduce((n,e)=>(e.toString(2).split("").forEach(r=>{n.push(parseInt(r))}),n),[])}function Ja(t){let n=[];for(let e=0;e{n.push(a==="1"?1:0)})}return n}function Za(...t){return t.reduce((n,e)=>{n.push(1);for(let r=0;r=n?1:0);return r}function Ya(t,n=Math.random){return t.map(e=>n()<=e?1:0)}function ti(t,n){let e=t.length,r=[];for(let o=0;ooi,degrees:()=>Zr,detect:()=>Hr,extended:()=>xn,get:()=>T,modeNames:()=>Qr,names:()=>Br,rangeOf:()=>Jr,reduced:()=>Xr,scale:()=>Ur,scaleChords:()=>Kr,scaleNotes:()=>Cn,steps:()=>Wr,tokenize:()=>Tn});var ei={empty:!0,name:"",type:"",tonic:null,setNum:NaN,chroma:"",normalized:"",aliases:[],notes:[],intervals:[]};function Tn(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).toLowerCase();return[e.name,r.length?r:""]}var Br=At;function T(t){let n=Array.isArray(t)?t:Tn(t),e=s(n[0]).name,r=H(n[1]);if(r.empty)return ei;let o=r.name,a=e?r.intervals.map(m=>d(e,m)):[],i=e?e+" "+o:o;return{...r,name:i,type:o,tonic:e,notes:a}}var Ur=T;function Hr(t,n={}){let e=ut(t),r=s(n.tonic??t[0]??""),o=r.chroma;if(o===void 0)return[];let a=e.split("");a[o]="1";let i=E(o,a).join(""),m=_().find(u=>u.chroma===i),c=[];return m&&c.push(r.name+" "+m.name),n.match==="exact"||xn(i).forEach(u=>{c.push(r.name+" "+u)}),c}function Kr(t){let n=T(t),e=G(n.chroma);return D().filter(r=>e(r.chroma)).map(r=>r.aliases[0])}function xn(t){let n=et(t)?t:T(t).chroma,e=z(n);return _().filter(r=>e(r.chroma)).map(r=>r.name)}function Xr(t){let n=G(T(t).chroma);return _().filter(e=>n(e.chroma)).map(e=>e.name)}function Cn(t){let n=t.map(o=>s(o).pc).filter(o=>o),e=n[0],r=Et(n);return E(r.indexOf(e),r)}function Qr(t){let n=T(t);if(n.empty)return[];let e=n.tonic?n.notes:n.intervals;return Z(n.chroma).map((r,o)=>{let a=T(r).name;return a?[e[o],a]:["",""]}).filter(r=>r[0])}function ri(t){let n=Array.isArray(t)?Cn(t):T(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 i=a%12,m=e.indexOf(i);if(m!==-1)return Dt(o.name,n[m])}}function Jr(t){let n=ri(t);return(e,r)=>{let o=s(e).height,a=s(r).height;return o===void 0||a===void 0?[]:O(o,a).map(n).filter(i=>i)}}function Zr(t){let{intervals:n,tonic:e}=T(t),r=R(n,e);return o=>o?r(o>0?o-1:o):""}function Wr(t){let{intervals:n,tonic:e}=T(t);return R(n,e)}var oi={degrees:Zr,detect:Hr,extended:xn,get:T,modeNames:Qr,names:Br,rangeOf:Jr,reduced:Xr,scaleChords:Kr,scaleNotes:Cn,steps:Wr,tokenize:Tn,scale:Ur};var Dn={};f(Dn,{default:()=>si,get:()=>no,names:()=>to,parse:()=>Ft});var ai={empty:!0,name:"",upper:void 0,lower:void 0,type:void 0,additive:[]},ii=["4/4","3/4","2/4","2/2","12/8","9/8","6/8","3/8"];function to(){return ii.slice()}var mi=/^(\d*\d(?:\+\d)*)\/(\d+)$/,Yr=new Map;function no(t){let n=JSON.stringify(t),e=Yr.get(n);if(e)return e;let r=ui(Ft(t));return Yr.set(n,r),r}function Ft(t){if(typeof t=="string"){let[a,i,m]=mi.exec(t)||[];return Ft([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 si={names:to,parse:Ft,get:no},ci=t=>Math.log(t)/Math.log(2)%1===0;function ui([t,n]){let e=Array.isArray(t)?t.reduce((m,c)=>m+c,0):t,r=n;if(e===0||r===0)return ai;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":ci(r)?"irregular":"irrational";return{empty:!1,name:o,type:i,upper:e,lower:r,additive:a}}var wn={};f(wn,{default:()=>_n,topNoteDiff:()=>eo});var eo=(t,n)=>{if(!n||!n.length)return t[0];let e=o=>A.midi(o[o.length-1])||0,r=o=>Math.abs(e(n)-e(o));return t.sort((o,a)=>r(o)-r(a))[0]},_n={topNoteDiff:eo};var qn={};f(qn,{default:()=>li,get:()=>kn,search:()=>$n,sequence:()=>so});var Rn={};f(Rn,{all:()=>oo,default:()=>mt,defaultDictionary:()=>Fn,lefthand:()=>Vn,lookup:()=>ao,triads:()=>ro});var ro={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"]},Vn={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"]},oo={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"]},Fn=Vn;function ao(t,n=Fn){if(n[t])return n[t];let{aliases:e}=at.get("C"+t),r=Object.keys(n).find(o=>e.includes(o))||"";if(r!==void 0)return n[r]}var mt={lookup:ao,lefthand:Vn,triads:ro,all:oo,defaultDictionary:Fn};var On=["C3","C5"],io=mt.all,mo=_n.topNoteDiff;function kn(t,n=On,e=io,r=mo,o){let a=$n(t,n,e);return!o||!o.length?a[0]:r(a,o)}function $n(t,n=On,e=mt.triads){let[r,o]=at.tokenize(t),a=mt.lookup(o,e);if(!a)return[];let i=a.map(c=>c.split(" ")),m=In.chromatic(n);return i.reduce((c,u)=>{let M=u.map(h=>Yt.subtract(h,u[0])||""),v=A.transpose(r,u[0]),x=m.filter(h=>A.chroma(h)===A.chroma(v)).filter(h=>(A.midi(A.transpose(h,M[M.length-1]))||0)<=(A.midi(n[1])||0)).map(h=>A.enharmonic(h,v)).map(h=>M.map(st=>A.transpose(h,st)));return c.concat(x)},[])}function so(t,n=On,e=io,r=mo,o){let{voicings:a}=t.reduce(({voicings:i,lastVoicing:m},c)=>{let u=kn(c,n,e,r,m);return m=u,i.push(u),{voicings:i,lastVoicing:m}},{voicings:[],lastVoicing:o});return a}var li={get:kn,search:$n,sequence:so};var Rt={};f(Rt,{accToAlt:()=>L,altToAcc:()=>F,chroma:()=>zn,coordToInterval:()=>q,coordToNote:()=>ct,coordinates:()=>K,deprecate:()=>Ln,distance:()=>y,fillStr:()=>co,height:()=>kt,interval:()=>l,isNamed:()=>uo,isNamedPitch:()=>C,isPitch:()=>V,midi:()=>Bn,note:()=>s,pitch:()=>X,stepToLetter:()=>Gt,tokenizeInterval:()=>qt,tokenizeNote:()=>Q,tonicIntervalsTransposer:()=>R,transpose:()=>d});var co=(t,n)=>Array(Math.abs(n)+1).join(t);function Ln(t,n,e){return function(...r){return console.warn(`${t} is deprecated. Use ${n}.`),e.apply(this,r)}}var uo=Ln("isNamed","isNamedPitch",C);var fi=Rt,di=ft,pi=dt,Pi=gt;return yo(Mi);})(); +"use strict";var Tonal=(()=>{var Vt=Object.defineProperty;var ho=Object.getOwnPropertyDescriptor;var vo=Object.getOwnPropertyNames;var yo=Object.prototype.hasOwnProperty;var d=(t,n)=>{for(var e in n)Vt(t,e,{get:n[e],enumerable:!0})},bo=(t,n,e,r)=>{if(n&&typeof n=="object"||typeof n=="function")for(let o of vo(n))!yo.call(t,o)&&o!==e&&Vt(t,o,{get:()=>n[o],enumerable:!(r=ho(n,o))||r.enumerable});return t};var go=t=>bo(Vt({},"__esModule",{value:!0}),t);var bi={};d(bi,{AbcNotation:()=>Kt,Array:()=>Ut,Chord:()=>on,ChordDictionary:()=>vi,ChordType:()=>dt,Collection:()=>Qt,Core:()=>$t,DurationValue:()=>an,Interval:()=>nn,Key:()=>vn,Midi:()=>cn,Mode:()=>Sn,Note:()=>dn,PcSet:()=>hi,Pcset:()=>ft,Progression:()=>In,Range:()=>Tn,RhythmPattern:()=>Cn,RomanNumeral:()=>pn,Scale:()=>Rn,ScaleDictionary:()=>yi,ScaleType:()=>At,TimeSignature:()=>wn,Tonal:()=>Mi,VoiceLeading:()=>On,Voicing:()=>zn,VoicingDictionary:()=>kn,accToAlt:()=>L,altToAcc:()=>F,chroma:()=>Kn,coordToInterval:()=>q,coordToNote:()=>ct,coordinates:()=>U,deprecate:()=>Bn,distance:()=>g,fillStr:()=>lo,height:()=>kt,interval:()=>f,isNamed:()=>fo,isNamedPitch:()=>C,isPitch:()=>w,midi:()=>Un,note:()=>s,pitch:()=>X,stepToLetter:()=>zt,tokenizeInterval:()=>Lt,tokenizeNote:()=>Q,tonicIntervalsTransposer:()=>O,transpose:()=>p});var Kt={};d(Kt,{abcToScientificNotation:()=>et,default:()=>Oo,distance:()=>ae,scientificToAbcNotation:()=>Ht,tokenize:()=>Bt,transpose:()=>oe});function C(t){return t!==null&&typeof t=="object"&&"name"in t&&typeof t.name=="string"}var Hn=[0,2,4,5,7,9,11],Kn=({step:t,alt:n})=>(Hn[t]+n+120)%12,kt=({step:t,alt:n,oct:e,dir:r=1})=>r*(Hn[t]+n+12*(e===void 0?-100:e)),Un=t=>{let n=kt(t);return t.oct!==void 0&&n>=-12&&n<=115?n+12:null};function w(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 Xn=[0,2,4,-1,1,3,5],Qn=Xn.map(t=>Math.floor(t*7/12));function U(t){let{step:n,alt:e,oct:r,dir:o=1}=t,a=Xn[n]+7*e;if(r===void 0)return[o*a];let i=r-Qn[n]-4*e;return[o*a,o*i]}var Ao=[3,0,4,1,5,2,6];function X(t){let[n,e,r]=t,o=Ao[No(n)],a=Math.floor((n+1)/7);if(e===void 0)return{step:o,alt:a,dir:r};let i=e+4*a+Qn[o];return{step:o,alt:a,oct:i,dir:r}}function No(t){let n=(t+1)%7;return n<0?7+n:n}var Jn=(t,n)=>Array(Math.abs(n)+1).join(t),qt=Object.freeze({empty:!0,name:"",num:NaN,q:"",type:"",step:NaN,alt:NaN,dir:NaN,simple:NaN,semitones:NaN,chroma:NaN,coord:[],oct:NaN}),So="([-+]?\\d+)(d{1,4}|m|M|P|A{1,4})",Io="(AA|A|P|M|m|d|dd)([-+]?\\d+)",jo=new RegExp("^"+So+"|"+Io+"$");function Lt(t){let n=jo.exec(`${t}`);return n===null?["",""]:n[1]?[n[1],n[2]]:[n[4],n[3]]}var Wn={};function f(t){return typeof t=="string"?Wn[t]||(Wn[t]=xo(t)):w(t)?f(Co(t)):C(t)?f(t.name):qt}var Zn=[0,2,4,5,7,9,11],Yn="PMMPPMM";function xo(t){let n=Lt(t);if(n[0]==="")return qt;let e=+n[0],r=n[1],o=(Math.abs(e)-1)%7,a=Yn[o];if(a==="M"&&r==="P")return qt;let i=a==="M"?"majorable":"perfectable",m=""+e+r,c=e<0?-1:1,u=e===8||e===-8?e:c*(o+1),M=To(i,r),y=Math.floor((Math.abs(e)-1)/7),l=c*(Zn[o]+M+12*y),P=(c*(Zn[o]+M)%12+12)%12,h=U({step:o,alt:M,oct:y,dir:c});return{empty:!1,name:m,num:e,q:r,step:o,alt:M,dir:c,type:i,simple:u,semitones:l,chroma:P,coord:h,oct:y}}function q(t,n){let[e,r=0]=t,o=e*7+r*12<0,a=n||o?[-e,-r,-1]:[e,r,1];return f(X(a))}function To(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 Co(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?"-":"",c=Yn[n]==="M"?"majorable":"perfectable";return m+i+Eo(c,e)}function Eo(t,n){return n===0?t==="majorable"?"M":"P":n===-1&&t==="majorable"?"m":n>0?Jn("A",n):Jn("d",t==="perfectable"?n:n+1)}var te=(t,n)=>Array(Math.abs(n)+1).join(t),ee=Object.freeze({empty:!0,name:"",letter:"",acc:"",pc:"",step:NaN,alt:NaN,chroma:NaN,height:NaN,coord:[],midi:null,freq:null}),ne=new Map,zt=t=>"CDEFGAB".charAt(t),F=t=>t<0?te("b",-t):te("#",t),L=t=>t[0]==="b"?-t.length:t.length;function s(t){let n=JSON.stringify(t),e=ne.get(n);if(e)return e;let r=typeof t=="string"?Ro(t):w(t)?s(wo(t)):C(t)?s(t.name):ee;return ne.set(n,r),r}var Do=/^([a-gA-G]?)(#{1,}|b{1,}|x{1,}|)(-?\d*)\s*(.*)$/;function Q(t){let n=Do.exec(t);return n?[n[1].toUpperCase(),n[2].replace(/x/g,"##"),n[3],n[4]]:["","","",""]}function ct(t){return s(X(t))}var _o=(t,n)=>(t%n+n)%n,Gt=[0,2,4,5,7,9,11];function Ro(t){let n=Q(t);if(n[0]===""||n[3]!=="")return ee;let e=n[0],r=n[1],o=n[2],a=(e.charCodeAt(0)+3)%7,i=L(r),m=o.length?+o:void 0,c=U({step:a,alt:i,oct:m}),u=e+r+o,M=e+r,y=(Gt[a]+i+120)%12,l=m===void 0?_o(Gt[a]+i,12)-12*99:Gt[a]+i+12*(m+1),P=l>=0&&l<=127?l:null,h=m===void 0?null:Math.pow(2,(l-69)/12)*440;return{empty:!1,acc:r,alt:i,chroma:y,coord:c,freq:h,height:l,letter:e,midi:P,name:u,oct:m,pc:M,step:a}}function wo(t){let{step:n,alt:e,oct:r}=t,o=zt(n);if(!o)return"";let a=o+F(e);return r||r===0?a+r:a}function p(t,n){let e=s(t),r=Array.isArray(n)?n:f(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 ct(a).name}function O(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=p(n,[0,a]);return p(i,t[o])}}function g(t,n){let e=s(t),r=s(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),c=r.height===e.height&&r.midi!==null&&e.oct===r.oct&&e.step>r.step;return q([i,m],c).name}var re=(t,n)=>Array(n+1).join(t),Fo=/^(_{1,}|=|\^{1,}|)([abcdefgABCDEFG])([,']*)$/;function Bt(t){let n=Fo.exec(t);return n?[n[1],n[2],n[3]]:["","",""]}function et(t){let[n,e,r]=Bt(t);if(e==="")return"";let o=4;for(let i=0;i96?e.toUpperCase()+a+(o+1):e+a+o}function Ht(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,"^"),i=o>4?e.toLowerCase():e,m=o===5?"":o>4?re("'",o-5):re(",",4-o);return a+i+m}function oe(t,n){return Ht(p(et(t),n))}function ae(t,n){return g(et(t),et(n))}var Oo={abcToScientificNotation:et,scientificToAbcNotation:Ht,tokenize:Bt,transpose:oe,distance:ae};var Ut={};d(Ut,{compact:()=>Lo,permutations:()=>me,range:()=>ko,rotate:()=>qo,shuffle:()=>zo,sortedNoteNames:()=>ie,sortedUniqNoteNames:()=>Go});function $o(t,n){let e=[];for(;n--;e[n]=n+t);return e}function Vo(t,n){let e=[];for(;n--;e[n]=t-n);return e}function ko(t,n){return tn===0||n)}function ie(t){return t.map(e=>s(e)).filter(e=>!e.empty).sort((e,r)=>e.height-r.height).map(e=>e.name)}function Go(t){return ie(t).filter((n,e,r)=>e===0||n!==r[e-1])}function zo(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 me(t){return t.length===0?[[]]:me(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 on={};d(on,{chord:()=>Ge,chordScales:()=>Be,default:()=>it,degrees:()=>Xe,detect:()=>pt,extended:()=>He,get:()=>R,getChord:()=>at,notes:()=>Ue,reduced:()=>Ke,steps:()=>Qe,tokenize:()=>Y,transpose:()=>ze});var dt={};d(dt,{add:()=>Wt,addAlias:()=>Se,all:()=>D,chordType:()=>ve,default:()=>ma,entries:()=>Ae,get:()=>ot,keys:()=>ge,names:()=>ye,removeAll:()=>Ne,symbols:()=>be});var ft={};d(ft,{EmptyPcset:()=>I,chroma:()=>ut,chromas:()=>Pe,default:()=>Yo,filter:()=>he,get:()=>v,includes:()=>Zo,intervals:()=>fe,isChroma:()=>rt,isEqual:()=>Me,isNoteIncludedIn:()=>lt,isSubsetOf:()=>G,isSupersetOf:()=>z,modes:()=>W,notes:()=>pe,num:()=>de,pcset:()=>le});var Qt={};d(Qt,{compact:()=>J,default:()=>Ko,permutations:()=>Xt,range:()=>$,rotate:()=>E,shuffle:()=>se});function Bo(t,n){let e=[];for(;n--;e[n]=n+t);return e}function Ho(t,n){let e=[];for(;n--;e[n]=t-n);return e}function $(t,n){return tn===0||n)}function se(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 Xt(t){return t.length===0?[[]]:Xt(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 Ko={compact:J,permutations:Xt,range:$,rotate:E,shuffle:se};var I={empty:!0,name:"",setNum:0,chroma:"000000000000",normalized:"000000000000",intervals:[]},Jt=t=>Number(t).toString(2).padStart(12,"0"),ce=t=>parseInt(t,2),Uo=/^[01]{12}$/;function rt(t){return Uo.test(t)}var Xo=t=>typeof t=="number"&&t>=0&&t<=4095,Qo=t=>t&&rt(t.chroma),ue={[I.chroma]:I};function v(t){let n=rt(t)?t:Xo(t)?Jt(t):Array.isArray(t)?ea(t):Qo(t)?t.chroma:I.chroma;return ue[n]=ue[n]||na(n)}var le=v,ut=t=>v(t).chroma,fe=t=>v(t).intervals,de=t=>v(t).setNum,Jo=["1P","2m","2M","3m","3M","4P","5d","5P","6m","6M","7m","7M"];function Wo(t){let n=[];for(let e=0;e<12;e++)t.charAt(e)==="1"&&n.push(Jo[e]);return n}function pe(t){return v(t).intervals.map(n=>p("C",n))}function Pe(){return $(2048,4095).map(Jt)}function W(t,n=!0){let r=v(t).chroma.split("");return J(r.map((o,a)=>{let i=E(a,r);return n&&i[0]==="0"?null:i.join("")}))}function Me(t,n){return v(t).setNum===v(n).setNum}function G(t){let n=v(t).setNum;return e=>{let r=v(e).setNum;return n&&n!==r&&(r&n)===r}}function z(t){let n=v(t).setNum;return e=>{let r=v(e).setNum;return n&&n!==r&&(r|n)===r}}function lt(t){let n=v(t);return e=>{let r=s(e);return n&&!r.empty&&n.chroma.charAt(r.chroma)==="1"}}var Zo=lt;function he(t){let n=lt(t);return e=>e.filter(n)}var Yo={get:v,chroma:ut,num:de,intervals:fe,chromas:Pe,isSupersetOf:z,isSubsetOf:G,isNoteIncludedIn:lt,isEqual:Me,filter:he,modes:W,notes:pe,pcset:le};function ta(t){let n=t.split("");return n.map((e,r)=>E(r,n).join(""))}function na(t){let n=ce(t),e=ta(t).map(ce).filter(a=>a>=2048).sort()[0],r=Jt(e),o=Wo(t);return{empty:!1,name:"",setNum:n,chroma:t,normalized:r,intervals:o}}function ea(t){if(t.length===0)return I.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 be(){return Z.map(t=>t.aliases[0]).filter(t=>t)}function ge(){return Object.keys(B)}function D(){return Z.slice()}var Ae=D;function Ne(){Z=[],B={}}function Wt(t,n,e){let r=ia(t),o={...v(t),name:e||"",quality:r,intervals:t,aliases:n};Z.push(o),o.name&&(B[o.name]=o),B[o.setNum]=o,B[o.chroma]=o,o.aliases.forEach(a=>Se(o,a))}function Se(t,n){B[n]=t}function ia(t){let n=e=>t.indexOf(e)!==-1;return n("5A")?"Augmented":n("3M")?"Major":n("5d")?"Diminished":n("3m")?"Minor":"Unknown"}oa.forEach(([t,n,e])=>Wt(t.split(" "),e.split(" "),n));Z.sort((t,n)=>t.setNum-n.setNum);var ma={names:ye,symbols:be,get:ot,all:D,add:Wt,removeAll:Ne,keys:ge,entries:Ae,chordType:ve};var sa=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 pt(t,n={}){let e=t.map(o=>s(o).pc).filter(o=>o);return s.length===0?[]:Pa(e,1,n).filter(o=>o.weight).sort((o,a)=>a.weight-o.weight).map(o=>o.name)}var Pt={anyThirds:384,perfectFifth:16,nonPerfectFifths:40,anySeventh:3},Mt=t=>n=>!!(n&t),ca=Mt(Pt.anyThirds),ua=Mt(Pt.perfectFifth),la=Mt(Pt.anySeventh),fa=Mt(Pt.nonPerfectFifths);function da(t){let n=parseInt(t.chroma,2);return ca(n)&&ua(n)&&la(n)}function pa(t){let n=parseInt(t,2);return fa(n)?t:(n|16).toString(2)}function Pa(t,n,e){let r=t[0],o=s(r).chroma,a=sa(t),i=W(t,!1),m=[];return i.forEach((c,u)=>{let M=e.assumePerfectFifth&&pa(c);D().filter(l=>e.assumePerfectFifth&&da(l)?l.chroma===M:l.chroma===c).forEach(l=>{let P=l.aliases[0],h=a(u);u!==o?m.push({weight:.5*n,name:`${h}${P}/${r}`}):m.push({weight:1*n,name:`${h}${P}`})})}),m}var nn={};d(nn,{add:()=>Yt,addTo:()=>Re,default:()=>tn,distance:()=>_e,fromSemitones:()=>De,get:()=>Zt,invert:()=>Ee,name:()=>je,names:()=>Ie,num:()=>Ce,quality:()=>Te,semitones:()=>xe,simplify:()=>ht,subtract:()=>vt,transposeFifths:()=>yt});function Ie(){return"1P 2M 3M 4P 5P 6m 7m".split(" ")}var Zt=f,je=t=>f(t).name,xe=t=>f(t).semitones,Te=t=>f(t).q,Ce=t=>f(t).num;function ht(t){let n=f(t);return n.empty?"":n.simple+n.q}function Ee(t){let n=f(t);if(n.empty)return"";let e=(7-n.step)%7,r=n.type==="perfectable"?-n.alt:-(n.alt+1);return f({step:e,alt:r,oct:n.oct,dir:n.dir}).name}var Ma=[1,2,2,3,3,4,5,5,6,6,7,7],ha="P m M m M P d P m M m M".split(" ");function De(t){let n=t<0?-1:1,e=Math.abs(t),r=e%12,o=Math.floor(e/12);return n*(Ma[r]+7*o)+ha[r]}var _e=g,Yt=we((t,n)=>[t[0]+n[0],t[1]+n[1]]),Re=t=>n=>Yt(t,n),vt=we((t,n)=>[t[0]-n[0],t[1]-n[1]]);function yt(t,n){let e=Zt(t);if(e.empty)return"";let[r,o,a]=e.coord;return q([r+n,o,a]).name}var tn={names:Ie,get:Zt,name:je,num:Ce,semitones:xe,quality:Te,fromSemitones:De,distance:_e,invert:Ee,simplify:ht,add:Yt,addTo:Re,subtract:vt,transposeFifths:yt};function we(t){return(n,e)=>{let r=f(n).coord,o=f(e).coord;if(r&&o){let a=t(r,o);return q(a).name}}}var At={};d(At,{NoScaleType:()=>Fe,add:()=>en,addAlias:()=>qe,all:()=>_,default:()=>ba,entries:()=>$e,get:()=>K,keys:()=>Ve,names:()=>gt,removeAll:()=>ke,scaleType:()=>Oe});var va=[["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"]],ya=va,Fe={...I,intervals:[],aliases:[]},bt=[],H={};function gt(){return bt.map(t=>t.name)}function K(t){return H[t]||Fe}var Oe=K;function _(){return bt.slice()}var $e=_;function Ve(){return Object.keys(H)}function ke(){bt=[],H={}}function en(t,n,e=[]){let r={...v(t),name:n,intervals:t,aliases:e};return bt.push(r),H[r.name]=r,H[r.setNum]=r,H[r.chroma]=r,r.aliases.forEach(o=>qe(r,o)),r}function qe(t,n){H[n]=t}ya.forEach(([t,n,...e])=>en(t.split(" "),n,e));var ba={names:gt,get:K,all:_,add:en,removeAll:ke,keys:Ve,entries:$e,scaleType:Oe};var Le={empty:!0,name:"",symbol:"",root:"",bass:"",rootDegree:0,type:"",tonic:null,setNum:NaN,quality:"Unknown",chroma:"",normalized:"",aliases:[],notes:[],intervals:[]};function Y(t){let[n,e,r,o]=Q(t);return n===""?rn("",t):n==="A"&&o==="ug"?rn("","aug"):rn(n+e,r+o)}function rn(t,n){let e=n.split("/");if(e.length===1)return[t,e[0],""];let[r,o,a,i]=Q(e[1]);return r!==""&&a===""&&i===""?[t,e[0],r+o]:[t,n,""]}function R(t){if(Array.isArray(t))return at(t[1]||"",t[0],t[2]);if(t==="")return Le;{let[n,e,r]=Y(t),o=at(e,n,r);return o.empty?at(t):o}}function at(t,n,e){let r=ot(t),o=s(n||""),a=s(e||"");if(r.empty||n&&o.empty||e&&a.empty)return Le;let i=g(o.pc,a.pc),m=r.intervals.indexOf(i),c=m>=0,u=c?a:s(""),M=m===-1?NaN:m+1,y=a.pc&&a.pc!==o.pc,l=Array.from(r.intervals);if(c)for(let k=1;kp(o.pc,k));t=r.aliases.indexOf(t)!==-1?t:r.aliases[0];let h=`${o.empty?"":o.pc}${t}${c&&M>1?"/"+u.pc:y?"/"+a.pc:""}`,nt=`${n?o.pc+" ":""}${r.name}${c&&M>1?" over "+u.pc:y?" over "+a.pc:""}`;return{...r,name:nt,symbol:h,tonic:o.pc,type:r.name,root:u.pc,bass:y?a.pc:"",intervals:l,rootDegree:M,notes:P}}var Ge=R;function ze(t,n){let[e,r,o]=Y(t);if(!e)return t;let a=p(o,n),i=a?"/"+a:"";return p(e,n)+r+i}function Be(t){let n=R(t),e=z(n.chroma);return _().filter(r=>e(r.chroma)).map(r=>r.name)}function He(t){let n=R(t),e=z(n.chroma);return D().filter(r=>e(r.chroma)).map(r=>n.tonic+r.aliases[0])}function Ke(t){let n=R(t),e=G(n.chroma);return D().filter(r=>e(r.chroma)).map(r=>n.tonic+r.aliases[0])}function Ue(t,n){let e=R(t),r=n||e.tonic;return!r||e.empty?[]:e.intervals.map(o=>p(r,o))}function Xe(t,n){let e=R(t),r=n||e.tonic,o=O(e.intervals,r);return a=>a?o(a>0?a-1:a):""}function Qe(t,n){let e=R(t),r=n||e.tonic;return O(e.intervals,r)}var it={getChord:at,get:R,detect:pt,chordScales:Be,extended:He,reduced:Ke,tokenize:Y,transpose:ze,degrees:Xe,steps:Qe,notes:Ue,chord:Ge};var an={};d(an,{default:()=>Ia,fraction:()=>Ye,get:()=>St,names:()=>Je,shorthands:()=>We,value:()=>Ze});var ga=[[.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"]]],Aa=ga,Nt=[];Aa.forEach(([t,n,e])=>ja(t,n,e));var Na={empty:!0,name:"",value:0,fraction:[0,0],shorthand:"",dots:"",names:[]};function Je(){return Nt.reduce((t,n)=>(n.names.forEach(e=>t.push(e)),t),[])}function We(){return Nt.map(t=>t.shorthand)}var Sa=/^([^.]+)(\.*)$/;function St(t){let[n,e,r]=Sa.exec(t)||[],o=Nt.find(m=>m.shorthand===e||m.names.includes(e));if(!o)return Na;let a=xa(o.fraction,r.length),i=a[0]/a[1];return{...o,name:t,dots:r,value:i,fraction:a}}var Ze=t=>St(t).value,Ye=t=>St(t).fraction,Ia={names:Je,shorthands:We,get:St,value:Ze,fraction:Ye};function ja(t,n,e){Nt.push({empty:!1,dots:"",name:"",value:1/t,fraction:t<1?[1/t,1]:[1,t],shorthand:n,names:e})}function xa(t,n){let e=Math.pow(2,n),r=t[0]*e,o=t[1]*e,a=r;for(let i=0;iQa,majorKey:()=>Mn,majorKeyChords:()=>Ua,majorTonicFromKeySignature:()=>Rr,minorKey:()=>hn,minorKeyChords:()=>Xa});var dn={};d(dn,{accidentals:()=>sr,ascending:()=>Ct,chroma:()=>fr,default:()=>S,descending:()=>Ar,distance:()=>Mr,enharmonic:()=>Dt,freq:()=>lr,fromFreq:()=>dr,fromFreqSharps:()=>pr,fromMidi:()=>Tt,fromMidiSharps:()=>Pr,get:()=>N,midi:()=>ur,name:()=>ir,names:()=>ar,octave:()=>cr,pitchClass:()=>mr,simplify:()=>Nr,sortedNames:()=>fn,sortedUniqNames:()=>Et,tr:()=>hr,trBy:()=>vr,trFifths:()=>br,trFrom:()=>yr,transpose:()=>A,transposeBy:()=>un,transposeFifths:()=>tt,transposeFrom:()=>ln,transposeOctaves:()=>gr});var cn={};d(cn,{chroma:()=>jt,default:()=>wa,freqToMidi:()=>mt,isMidi:()=>mn,midiToFreq:()=>tr,midiToNoteName:()=>j,pcset:()=>xt,pcsetDegrees:()=>er,pcsetNearest:()=>nr,pcsetSteps:()=>sn,toMidi:()=>It});function mn(t){return+t>=0&&+t<=127}function It(t){if(mn(t))return+t;let n=s(t);return n.empty?null:n.midi}function tr(t,n=440){return Math.pow(2,(t-69)/12)*n}var Ta=Math.log(2),Ca=Math.log(440);function mt(t){let n=12*(Math.log(t)-Ca)/Ta+69;return Math.round(n*100)/100}var Ea="C C# D D# E F F# G G# A A# B".split(" "),Da="C Db D Eb E F Gb G Ab A Bb B".split(" ");function j(t,n={}){if(isNaN(t)||t===-1/0||t===1/0)return"";t=Math.round(t);let r=(n.sharps===!0?Ea:Da)[t%12];if(n.pitchClass)return r;let o=Math.floor(t/12)-1;return r+o}function jt(t){return t%12}function _a(t){return t.split("").reduce((n,e,r)=>(r<12&&e==="1"&&n.push(r),n),[])}function Ra(t){return t.map(jt).sort((n,e)=>n-e).filter((n,e,r)=>e===0||n!==r[e-1])}function xt(t){return Array.isArray(t)?Ra(t):_a(t)}function nr(t){let n=xt(t);return e=>{let r=jt(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 sn(t,n){let e=xt(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 er(t,n){let e=sn(t,n);return r=>{if(r!==0)return e(r>0?r-1:r)}}var wa={chroma:jt,freqToMidi:mt,isMidi:mn,midiToFreq:tr,midiToNoteName:j,pcsetNearest:nr,pcset:xt,pcsetDegrees:er,pcsetSteps:sn,toMidi:It};var Fa=["C","D","E","F","G","A","B"],rr=t=>t.name,or=t=>t.map(s).filter(n=>!n.empty);function ar(t){return t===void 0?Fa.slice():Array.isArray(t)?or(t).map(rr):[]}var N=s,ir=t=>N(t).name,mr=t=>N(t).pc,sr=t=>N(t).acc,cr=t=>N(t).oct,ur=t=>N(t).midi,lr=t=>N(t).freq,fr=t=>N(t).chroma;function Tt(t){return j(t)}function dr(t){return j(mt(t))}function pr(t){return j(mt(t),{sharps:!0})}function Pr(t){return j(t,{sharps:!0})}var Mr=g,A=p,hr=p,un=t=>n=>A(n,t),vr=un,ln=t=>n=>A(t,n),yr=ln;function tt(t,n){return A(t,[n,0])}var br=tt;function gr(t,n){return A(t,[0,n])}var Ct=(t,n)=>t.height-n.height,Ar=(t,n)=>n.height-t.height;function fn(t,n){return n=n||Ct,or(t).sort(n).map(rr)}function Et(t){return fn(t,Ct).filter((n,e,r)=>e===0||n!==r[e-1])}var Nr=t=>{let n=N(t);return n.empty?"":j(n.midi||n.chroma,{sharps:n.alt>0,pitchClass:n.midi===null})};function Dt(t,n){let e=N(t);if(e.empty)return"";let r=N(n||j(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 S={names:ar,get:N,name:ir,pitchClass:mr,accidentals:sr,octave:cr,midi:ur,ascending:Ct,descending:Ar,distance:Mr,sortedNames:fn,sortedUniqNames:Et,fromMidi:Tt,fromMidiSharps:Pr,freq:lr,fromFreq:dr,fromFreqSharps:pr,chroma:fr,transpose:A,tr:hr,transposeBy:un,trBy:vr,transposeFrom:ln,trFrom:yr,transposeFifths:tt,transposeOctaves:gr,trFifths:br,simplify:Nr,enharmonic:Dt};var pn={};d(pn,{default:()=>qa,get:()=>x,names:()=>xr,romanNumeral:()=>jr,tokenize:()=>Tr});var Ir={empty:!0,name:"",chordType:""},Sr={};function x(t){return typeof t=="string"?Sr[t]||(Sr[t]=ka(t)):typeof t=="number"?x(_t[t]||""):w(t)?Oa(t):C(t)?x(t.name):Ir}var jr=x;function xr(t=!0){return(t?_t:Va).slice()}function Oa(t){return x(F(t.alt)+_t[t.step])}var $a=/^(#{1,}|b{1,}|x{1,}|)(IV|I{1,3}|VI{0,2}|iv|i{1,3}|vi{0,2})([^IViv]*)$/;function Tr(t){return $a.exec(t)||["","","",""]}var Cr="I II III IV V VI VII",_t=Cr.split(" "),Va=Cr.toLowerCase().split(" ");function ka(t){let[n,e,r,o]=Tr(t);if(!r)return Ir;let a=r.toUpperCase(),i=_t.indexOf(a),m=L(e),c=1;return{empty:!1,name:n,roman:r,interval:f({step:i,alt:m,dir:c}).name,acc:e,chordType:o,alt:m,step:i,major:r===a,oct:0,dir:c}}var qa={names:xr,get:x,romanNumeral:jr};var b=Object.freeze([]),Dr={type:"major",tonic:"",alteration:0,keySignature:""},Rt={tonic:"",grades:b,intervals:b,scale:b,triads:b,chords:b,chordsHarmonicFunction:b,chordScales:b,secondaryDominants:b,secondaryDominantSupertonics:b,substituteDominantsMinorRelative:b,substituteDominants:b,substituteDominantSupertonics:b,secondaryDominantsMinorRelative:b},La={...Dr,...Rt,type:"major",minorRelative:"",scale:b,substituteDominants:b,secondaryDominantSupertonics:b,substituteDominantsMinorRelative:b},Ga={...Dr,type:"minor",relativeMajor:"",natural:Rt,harmonic:Rt,melodic:Rt},Pn=(t,n,e="")=>n.map((r,o)=>`${t[o]}${e}${r}`);function Ft(t,n,e,r,o){return a=>{let i=t.map(P=>x(P).interval||""),m=i.map(P=>A(a,P)),c=Pn(m,e),u=m.map(P=>A(P,"5P")).map(P=>m.includes(P)&&!c.includes(P+"7")?P+"7":""),M=Er(u,n),y=u.map(P=>{if(!P)return"";let h=P.slice(0,-1);return A(h,"5d")+"7"}),l=Er(y,n);return{tonic:a,grades:t,intervals:i,scale:m,triads:Pn(m,n),chords:c,chordsHarmonicFunction:r.slice(),chordScales:Pn(m,o," "),secondaryDominants:u,secondaryDominantSupertonics:M,substituteDominants:y,substituteDominantSupertonics:l,secondaryDominantsMinorRelative:M,substituteDominantsMinorRelative:l}}}var Er=(t,n)=>t.map((e,r)=>{if(!e)return"";let o=e.slice(0,-1),a=A(o,"5P");return n[r].endsWith("m")?a+"m7":a+"m7b5"}),_r=(t,n)=>{let e=s(t),r=s(n);return e.empty||r.empty?0:r.coord[0]-e.coord[0]},za=Ft("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(",")),Ba=Ft("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(",")),Ha=Ft("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(",")),Ka=Ft("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 Mn(t){let n=s(t).pc;if(!n)return La;let e=za(n),r=_r("C",n);return{...e,type:"major",minorRelative:A(n,"-3m"),alteration:r,keySignature:F(r)}}function Ua(t){let n=Mn(t),e=[];return wt(n,e),e}function Xa(t){let n=hn(t),e=[];return wt(n.natural,e),wt(n.harmonic,e),wt(n.melodic,e),e}function wt(t,n){let e=(r,o)=>{if(!r)return;let a=n.find(i=>i.name===r);a||(a={name:r,roles:[]},n.push(a)),o&&!a.roles.includes(o)&&a.roles.push(o)};t.chords.forEach((r,o)=>e(r,t.chordsHarmonicFunction[o])),t.secondaryDominants.forEach((r,o)=>e(r,`V/${t.grades[o]}`)),t.secondaryDominantSupertonics.forEach((r,o)=>e(r,`ii/${t.grades[o]}`)),t.substituteDominants.forEach((r,o)=>e(r,`subV/${t.grades[o]}`)),t.substituteDominantSupertonics.forEach((r,o)=>e(r,`subii/${t.grades[o]}`))}function hn(t){let n=s(t).pc;if(!n)return Ga;let e=_r("C",n)-3;return{type:"minor",tonic:n,relativeMajor:A(n,"3m"),alteration:e,keySignature:F(e),natural:Ba(n),harmonic:Ha(n),melodic:Ka(n)}}function Rr(t){return typeof t=="number"?tt("C",t):typeof t=="string"&&/^b+|#+$/.test(t)?tt("C",L(t)):null}var Qa={majorKey:Mn,majorTonicFromKeySignature:Rr,minorKey:hn};var Sn={};d(Sn,{all:()=>An,default:()=>Wa,distance:()=>Nn,entries:()=>Or,get:()=>V,mode:()=>Fr,names:()=>$r,notes:()=>Vr,relativeTonic:()=>Gr,seventhChords:()=>Lr,triads:()=>qr});var bn=[[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"]],wr={...I,name:"",alt:0,modeNum:NaN,triad:"",seventh:"",aliases:[]},gn=bn.map(Ja),yn={};gn.forEach(t=>{yn[t.name]=t,t.aliases.forEach(n=>{yn[n]=t})});function V(t){return typeof t=="string"?yn[t.toLowerCase()]||wr:t&&t.name?V(t.name):wr}var Fr=V;function An(){return gn.slice()}var Or=An;function $r(){return gn.map(t=>t.name)}function Ja(t){let[n,e,r,o,a,i,m]=t,c=m?[m]:[],u=Number(e).toString(2);return{empty:!1,intervals:K(o).intervals,modeNum:n,chroma:u,normalized:u,name:o,setNum:e,alt:r,triad:a,seventh:i,aliases:c}}function Vr(t,n){return V(t).intervals.map(e=>p(n,e))}function kr(t){return(n,e)=>{let r=V(n);if(r.empty)return[];let o=E(r.modeNum,t),a=r.intervals.map(i=>p(e,i));return o.map((i,m)=>a[m]+i)}}var qr=kr(bn.map(t=>t[4])),Lr=kr(bn.map(t=>t[5]));function Nn(t,n){let e=V(n),r=V(t);return e.empty||r.empty?"":ht(yt("1P",r.alt-e.alt))}function Gr(t,n,e){return p(e,Nn(t,n))}var Wa={get:V,names:$r,all:An,distance:Nn,relativeTonic:Gr,notes:Vr,triads:qr,seventhChords:Lr,entries:Or,mode:Fr};var In={};d(In,{default:()=>Za,fromRomanNumerals:()=>zr,toRomanNumerals:()=>Br});function zr(t,n){return n.map(x).map(r=>p(t,f(r))+r.chordType)}function Br(t,n){return n.map(e=>{let[r,o]=Y(e),a=g(t,r);return x(f(a)).name+o})}var Za={fromRomanNumerals:zr,toRomanNumerals:Br};var Tn={};d(Tn,{chromatic:()=>Hr,default:()=>xn,numeric:()=>jn});function jn(t){let n=J(t.map(e=>typeof e=="number"?e:It(e)));return!t.length||n.length!==t.length?[]:n.reduce((e,r)=>{let o=e[e.length-1];return e.concat($(o,r).slice(1))},[n[0]])}function Hr(t,n){return jn(t).map(e=>j(e,n))}var xn={numeric:jn,chromatic:Hr};var Cn={};d(Cn,{binary:()=>Ya,euclid:()=>ai,hex:()=>ti,onsets:()=>ni,probability:()=>ri,random:()=>ei,rotate:()=>oi});function Ya(...t){return t.reduce((n,e)=>(e.toString(2).split("").forEach(r=>{n.push(parseInt(r))}),n),[])}function ti(t){let n=[];for(let e=0;e{n.push(a==="1"?1:0)})}return n}function ni(...t){return t.reduce((n,e)=>{n.push(1);for(let r=0;r=n?1:0);return r}function ri(t,n=Math.random){return t.map(e=>n()<=e?1:0)}function oi(t,n){let e=t.length,r=[];for(let o=0;osi,degrees:()=>Yr,detect:()=>Xr,extended:()=>Dn,get:()=>T,modeNames:()=>Wr,names:()=>Kr,rangeOf:()=>Zr,reduced:()=>Jr,scale:()=>Ur,scaleChords:()=>Qr,scaleNotes:()=>_n,steps:()=>to,tokenize:()=>En});var ii={empty:!0,name:"",type:"",tonic:null,setNum:NaN,chroma:"",normalized:"",aliases:[],notes:[],intervals:[]};function En(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).toLowerCase();return[e.name,r.length?r:""]}var Kr=gt;function T(t){let n=Array.isArray(t)?t:En(t),e=s(n[0]).name,r=K(n[1]);if(r.empty)return ii;let o=r.name,a=e?r.intervals.map(m=>p(e,m)):[],i=e?e+" "+o:o;return{...r,name:i,type:o,tonic:e,notes:a}}var Ur=T;function Xr(t,n={}){let e=ut(t),r=s(n.tonic??t[0]??""),o=r.chroma;if(o===void 0)return[];let a=e.split("");a[o]="1";let i=E(o,a).join(""),m=_().find(u=>u.chroma===i),c=[];return m&&c.push(r.name+" "+m.name),n.match==="exact"||Dn(i).forEach(u=>{c.push(r.name+" "+u)}),c}function Qr(t){let n=T(t),e=G(n.chroma);return D().filter(r=>e(r.chroma)).map(r=>r.aliases[0])}function Dn(t){let n=rt(t)?t:T(t).chroma,e=z(n);return _().filter(r=>e(r.chroma)).map(r=>r.name)}function Jr(t){let n=G(T(t).chroma);return _().filter(e=>n(e.chroma)).map(e=>e.name)}function _n(t){let n=t.map(o=>s(o).pc).filter(o=>o),e=n[0],r=Et(n);return E(r.indexOf(e),r)}function Wr(t){let n=T(t);if(n.empty)return[];let e=n.tonic?n.notes:n.intervals;return W(n.chroma).map((r,o)=>{let a=T(r).name;return a?[e[o],a]:["",""]}).filter(r=>r[0])}function mi(t){let n=Array.isArray(t)?_n(t):T(t).notes,e=n.map(r=>s(r).chroma);return r=>{let o=typeof r=="number"?s(Tt(r)):s(r),a=o.height;if(a===void 0)return;let i=a%12,m=e.indexOf(i);if(m!==-1)return Dt(o.name,n[m])}}function Zr(t){let n=mi(t);return(e,r)=>{let o=s(e).height,a=s(r).height;return o===void 0||a===void 0?[]:$(o,a).map(n).filter(i=>i)}}function Yr(t){let{intervals:n,tonic:e}=T(t),r=O(n,e);return o=>o?r(o>0?o-1:o):""}function to(t){let{intervals:n,tonic:e}=T(t);return O(n,e)}var si={degrees:Yr,detect:Xr,extended:Dn,get:T,modeNames:Wr,names:Kr,rangeOf:Zr,reduced:Jr,scaleChords:Qr,scaleNotes:_n,steps:to,tokenize:En,scale:Ur};var wn={};d(wn,{default:()=>fi,get:()=>ro,names:()=>eo,parse:()=>Ot});var ci={empty:!0,name:"",upper:void 0,lower:void 0,type:void 0,additive:[]},ui=["4/4","3/4","2/4","2/2","12/8","9/8","6/8","3/8"];function eo(){return ui.slice()}var li=/^(\d*\d(?:\+\d)*)\/(\d+)$/,no=new Map;function ro(t){let n=JSON.stringify(t),e=no.get(n);if(e)return e;let r=pi(Ot(t));return no.set(n,r),r}function Ot(t){if(typeof t=="string"){let[a,i,m]=li.exec(t)||[];return Ot([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 fi={names:eo,parse:Ot,get:ro},di=t=>Math.log(t)/Math.log(2)%1===0;function pi([t,n]){let e=Array.isArray(t)?t.reduce((m,c)=>m+c,0):t,r=n;if(e===0||r===0)return ci;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":di(r)?"irregular":"irrational";return{empty:!1,name:o,type:i,upper:e,lower:r,additive:a}}var On={};d(On,{default:()=>Fn,topNoteDiff:()=>oo});var oo=(t,n)=>{if(!n||!n.length)return t[0];let e=o=>S.midi(o[o.length-1])||0,r=o=>Math.abs(e(n)-e(o));return t.sort((o,a)=>r(o)-r(a))[0]},Fn={topNoteDiff:oo};var zn={};d(zn,{default:()=>Pi,get:()=>Ln,search:()=>Gn,sequence:()=>uo});var kn={};d(kn,{all:()=>io,default:()=>st,defaultDictionary:()=>Vn,lefthand:()=>$n,lookup:()=>mo,triads:()=>ao});var ao={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"]},$n={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"]},io={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"]},Vn=$n;function mo(t,n=Vn){if(n[t])return n[t];let{aliases:e}=it.get("C"+t),r=Object.keys(n).find(o=>e.includes(o))||"";if(r!==void 0)return n[r]}var st={lookup:mo,lefthand:$n,triads:ao,all:io,defaultDictionary:Vn};var qn=["C3","C5"],so=st.all,co=Fn.topNoteDiff;function Ln(t,n=qn,e=so,r=co,o){let a=Gn(t,n,e);return!o||!o.length?a[0]:r(a,o)}function Gn(t,n=qn,e=st.triads){let[r,o]=it.tokenize(t),a=st.lookup(o,e);if(!a)return[];let i=a.map(c=>c.split(" ")),m=xn.chromatic(n);return i.reduce((c,u)=>{let M=u.map(h=>tn.subtract(h,u[0])||""),y=S.transpose(r,u[0]),P=m.filter(h=>S.chroma(h)===S.chroma(y)).filter(h=>(S.midi(S.transpose(h,M[M.length-1]))||0)<=(S.midi(n[1])||0)).map(h=>S.enharmonic(h,y)).map(h=>M.map(nt=>S.transpose(h,nt)));return c.concat(P)},[])}function uo(t,n=qn,e=so,r=co,o){let{voicings:a}=t.reduce(({voicings:i,lastVoicing:m},c)=>{let u=Ln(c,n,e,r,m);return m=u,i.push(u),{voicings:i,lastVoicing:m}},{voicings:[],lastVoicing:o});return a}var Pi={get:Ln,search:Gn,sequence:uo};var $t={};d($t,{accToAlt:()=>L,altToAcc:()=>F,chroma:()=>Kn,coordToInterval:()=>q,coordToNote:()=>ct,coordinates:()=>U,deprecate:()=>Bn,distance:()=>g,fillStr:()=>lo,height:()=>kt,interval:()=>f,isNamed:()=>fo,isNamedPitch:()=>C,isPitch:()=>w,midi:()=>Un,note:()=>s,pitch:()=>X,stepToLetter:()=>zt,tokenizeInterval:()=>Lt,tokenizeNote:()=>Q,tonicIntervalsTransposer:()=>O,transpose:()=>p});var lo=(t,n)=>Array(Math.abs(n)+1).join(t);function Bn(t,n,e){return function(...r){return console.warn(`${t} is deprecated. Use ${n}.`),e.apply(this,r)}}var fo=Bn("isNamed","isNamedPitch",C);var Mi=$t,hi=ft,vi=dt,yi=At;return go(bi);})(); //# sourceMappingURL=tonal.min.js.map diff --git a/packages/tonal/browser/tonal.min.js.map b/packages/tonal/browser/tonal.min.js.map index d422ac9f..fcec45f8 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/index.ts", "../../array/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", "../../rhythm-patterm/index.ts", "../../scale/index.ts", "../../time-signature/index.ts", "../../voice-leading/index.ts", "../../voicing-dictionary/index.ts", "../../voicing-dictionary/data.ts", "../../voicing/index.ts", "../../core/index.ts"], - "sourcesContent": ["import * as AbcNotation from \"@tonaljs/abc-notation\";\nimport * as Array from \"@tonaljs/array\";\nimport * as Chord from \"@tonaljs/chord\";\nimport * as ChordType from \"@tonaljs/chord-type\";\nimport * as Collection from \"@tonaljs/collection\";\nimport * as DurationValue from \"@tonaljs/duration-value\";\nimport * as Interval from \"@tonaljs/interval\";\nimport * as Key from \"@tonaljs/key\";\nimport * as Midi from \"@tonaljs/midi\";\nimport * as Mode from \"@tonaljs/mode\";\nimport * as Note from \"@tonaljs/note\";\nimport * as Pcset from \"@tonaljs/pcset\";\nimport * as Progression from \"@tonaljs/progression\";\nimport * as Range from \"@tonaljs/range\";\nimport * as RhythmPattern from \"@tonaljs/rhythm-pattern\";\nimport * as RomanNumeral from \"@tonaljs/roman-numeral\";\nimport * as Scale from \"@tonaljs/scale\";\nimport * as ScaleType from \"@tonaljs/scale-type\";\nimport * as TimeSignature from \"@tonaljs/time-signature\";\nimport * as VoiceLeading from \"@tonaljs/voice-leading\";\nimport * as Voicing from \"@tonaljs/voicing\";\nimport * as VoicingDictionary from \"@tonaljs/voicing-dictionary\";\n\nexport * from \"@tonaljs/core\";\n\n// deprecated (backwards compatibility)\nimport * as Core from \"@tonaljs/core\";\n/** @deprecated */\nconst Tonal = Core;\n/** @deprecated */\nconst PcSet = Pcset;\n/** @deprecated */\nconst ChordDictionary = ChordType;\n/** @deprecated */\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 RhythmPattern,\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, not pitch class, and in the same octave\n // it can be descending interval (see #243 & #428)\n const forceDescending =\n to.height === from.height &&\n to.midi !== null &&\n from.oct === to.oct &&\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\n/** @deprecated */\nexport default {\n abcToScientificNotation,\n scientificToAbcNotation,\n tokenize,\n transpose,\n distance,\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", "/* 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\n/** @deprecated */\nexport default {\n compact,\n permutations,\n range,\n rotate,\n shuffle,\n};\n", "import { compact, range, rotate } from \"@tonaljs/collection\";\nimport { NotFound } from \"@tonaljs/pitch\";\nimport { transpose } from \"@tonaljs/pitch-distance\";\nimport { Interval, IntervalName, interval } from \"@tonaljs/pitch-interval\";\nimport { Note, NoteName, note } from \"@tonaljs/pitch-note\";\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.get\n * @deprecated\n */\nexport const pcset = 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 */\nexport const 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 */\nexport const 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 * Get the intervals of a pcset *starting from C*\n * @private\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 */\nfunction 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 equal\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\n/** @deprecated */\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 {\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\n/** @deprecated */\nexport const chordType = 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\n/** @deprecated */\nexport const entries = 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\n/** @deprecated */\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 { modes } from \"@tonaljs/pcset\";\nimport { note } from \"@tonaljs/pitch-note\";\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\n/** @deprecated */\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\n/** @deprecated */\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 {\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\n/**\n * @deprecated\n * @use ScaleType.get\n */\nexport const scaleType = get;\n\n/**\n * Return a list of all scale types\n */\nexport function all() {\n return dictionary.slice();\n}\n\n/**\n * @deprecated\n * @use ScaleType.all\n */\nexport const entries = all;\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\n/** @deprecated */\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\n/** @deprecated */\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\n/** @deprecated */\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/pitch-note\";\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\n/** @deprecated */\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 { freqToMidi, midiToNoteName } from \"@tonaljs/midi\";\nimport { Pitch } from \"@tonaljs/pitch\";\nimport { distance as _dist, transpose as _tr } from \"@tonaljs/pitch-distance\";\nimport { IntervalName } from \"@tonaljs/pitch-interval\";\nimport {\n Note,\n NoteLiteral,\n NoteName,\n note as props,\n} from \"@tonaljs/pitch-note\";\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\nexport const distance = _dist;\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 * Note.eharmoinic(\"C##b\"); // => \"\"\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\n/** @deprecated */\nexport default {\n names,\n get,\n name,\n pitchClass,\n accidentals,\n octave,\n midi,\n ascending,\n descending,\n distance,\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 { isNamedPitch, isPitch, Pitch } from \"@tonaljs/pitch\";\nimport { interval } from \"@tonaljs/pitch-interval\";\nimport { accToAlt, altToAcc } from \"@tonaljs/pitch-note\";\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 : isNamedPitch(src)\n ? get(src.name)\n : NoRomanNumeral;\n}\n\n/**\n * @deprecated\n * @use RomanNumeral.get\n */\nexport const romanNumeral = get;\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\n/** @deprecated */\nexport default {\n names,\n get,\n // deprecated\n romanNumeral,\n};\n", "import { transpose, transposeFifths } from \"@tonaljs/note\";\nimport { accToAlt, altToAcc, note } from \"@tonaljs/pitch-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\n/** @deprecated */\nexport default { majorKey, majorTonicFromKeySignature, minorKey };\n", "import { rotate } from \"@tonaljs/collection\";\nimport { simplify, transposeFifths } from \"@tonaljs/interval\";\nimport { EmptyPcset, Pcset } from \"@tonaljs/pcset\";\nimport { transpose } from \"@tonaljs/pitch-distance\";\nimport { NoteName } from \"@tonaljs/pitch-note\";\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 | { name: string };\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\n/** @deprecated */\nexport const mode = get;\n\n/**\n * Get a list of all modes\n */\nexport function all() {\n return modes.slice();\n}\n\n/** @deprecated */\nexport const entries = 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\n/** @deprecated */\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, transpose } from \"@tonaljs/pitch-distance\";\nimport { interval } from \"@tonaljs/pitch-interval\";\nimport { NoteLiteral } from \"@tonaljs/pitch-note\";\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\n/** @deprecated */\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\n/** @deprecated */\nexport default { numeric, chromatic };\n", "type RhythmPatternValue = 0 | 1;\n\nexport type RhythmPattern = Array;\n\n/**\n * Create a rhythm pattern from a number or concatenation of numbers in binary form\n * @param numbers one or more number\n * @returns an array of 0s and 1s representing the rhythm pattern\n * @example\n * binary(13) // => [1, 1, 0, 1]\n * binary(12, 13) // => [1, 1, 0, 0, 1, 1, 0, 1]\n */\nexport function binary(...numbers: number[]): RhythmPattern {\n return numbers.reduce((pattern, number) => {\n number\n .toString(2)\n .split(\"\")\n .forEach((digit: string) => {\n pattern.push(parseInt(digit) as RhythmPatternValue);\n });\n return pattern;\n }, [] as RhythmPattern);\n}\n\n/**\n * Create a rhythmic pattern using an hexadecimal numbers\n * @param hexNumber string with the hexadecimal number\n * @returns an array of 0s and 1s representing the rhythm pattern\n * @example\n * R.hex(\"8f\"); // => [1, 0, 0, 0, 1, 1, 1, 1]\n */\nexport function hex(hexNumber: string): RhythmPattern {\n const pattern: RhythmPattern = [];\n for (let i = 0; i < hexNumber.length; i++) {\n const digit = parseInt(\"0x\" + hexNumber[i]);\n const binary = isNaN(digit) ? \"0000\" : digit.toString(2).padStart(4, \"0\");\n binary.split(\"\").forEach((digit: string) => {\n pattern.push(digit === \"1\" ? 1 : 0);\n });\n }\n return pattern;\n}\n\n/**\n * Create a rhythm pattern from the onsets\n * @param numbers the onsets sizes\n * @returns an array of 0s and 1s representing the rhythm pattern\n * @example\n * onsets(1, 2, 2, 1) // => [1, 0, 1, 0, 0, 1, 0, 0, 1, 0]\n */\nexport function onsets(...numbers: number[]): RhythmPattern {\n return numbers.reduce((pattern, number) => {\n pattern.push(1);\n for (let i = 0; i < number; i++) {\n pattern.push(0);\n }\n return pattern;\n }, [] as RhythmPattern);\n}\n\n/**\n * Create a random rhythm pattern with a specified length\n * @param length length of the pattern\n * @param probability Threshold where random number is considered a beat (defaults to 0.5)\n * @param rnd A random function (Math.random by default)\n * @returns an array of 0s and 1s representing the rhythm pattern\n * @example\n * random(4) // => [1, 0, 0, 1]\n */\nexport function random(\n length: number,\n probability = 0.5,\n rnd: () => number = Math.random,\n): RhythmPattern {\n const pattern: RhythmPattern = [];\n for (let i = 0; i < length; i++) {\n pattern.push(rnd() >= probability ? 1 : 0);\n }\n return pattern;\n}\n\n/**\n * Create a rhythm pattern based on the given probability thresholds\n * @param probabilities An array with the probability of each step to be a beat\n * @param rnd A random function (Math.random by default)\n * @returns an array of 0s and 1s representing the rhythm pattern\n * @example\n * probability([0.6, 0, 0.2, 0.5]) // => [0, 0, 0, 1]\n */\nexport function probability(\n probabilities: number[],\n rnd: () => number = Math.random,\n): RhythmPattern {\n return probabilities.map((probability) => (rnd() <= probability ? 1 : 0));\n}\n\n/**\n * Rotate a pattern right\n * @param pattern the pattern to rotate\n * @param rotations the number of steps to rotate\n * @returns the rotated pattern (an array of 0s and 1s)\n * @example\n * rotate([1, 0, 0, 1], 2); // => [0, 1, 1, 0]\n *\n */\nexport function rotate(\n pattern: RhythmPattern,\n rotations: number,\n): RhythmPattern {\n const len = pattern.length;\n const rotated: RhythmPattern = [];\n for (let i = 0; i < len; i++) {\n const pos = (((i - rotations) % len) + len) % len;\n rotated[i] = pattern[pos];\n }\n return rotated;\n}\n\n/**\n * Generates an euclidean rhythm pattern\n * @param steps The length of the pattern\n * @param beats The number of beats\n * @returns an array with 0s and 1s representing the rhythmic pattern\n * @example\n * euclid(8, 3); // => [1, 0, 0, 1, 0, 0, 1, 0]\n */\nexport function euclid(steps: number, beats: number): RhythmPattern {\n const pattern: RhythmPattern = [];\n let d = -1;\n\n for (let i = 0; i < steps; i++) {\n const v = Math.floor(i * (beats / steps));\n pattern[i] = v !== d ? 1 : 0;\n d = v;\n }\n return pattern;\n}\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 { enharmonic, fromMidi, sortedUniqNames } from \"@tonaljs/note\";\nimport {\n chroma,\n isChroma,\n isSubsetOf,\n isSupersetOf,\n modes,\n} from \"@tonaljs/pcset\";\nimport { tonicIntervalsTransposer, transpose } from \"@tonaljs/pitch-distance\";\nimport { note, NoteName } from \"@tonaljs/pitch-note\";\nimport {\n all,\n get as getScaleType,\n ScaleType,\n names as scaleTypeNames,\n all as scaleTypes,\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).toLowerCase();\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\n/**\n * @deprecated\n * @use Scale.get\n */\nexport const scale = 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\n/** @deprecated */\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\n/** @deprecated */\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\n/** @deprecated */\nexport default {\n topNoteDiff,\n};\n", "import Chord from \"@tonaljs/chord\";\nimport { all, lefthand, triads, VoicingDictionary } from \"./data\";\nexport { all, lefthand, triads } from \"./data\";\n\nexport const defaultDictionary: VoicingDictionary = lefthand;\n\nexport function 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\n/** @deprecated */\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\nexport function 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\nexport function 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\nexport function 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\n/** @deprecated */\nexport default {\n get,\n search,\n sequence,\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"], - "mappings": "scAAA,IAAAA,GAAA,GAAAC,EAAAD,GAAA,iBAAAE,GAAA,UAAAA,GAAA,UAAAA,GAAA,oBAAAC,GAAA,cAAAD,GAAA,eAAAA,GAAA,SAAAA,GAAA,kBAAAA,GAAA,aAAAA,GAAA,QAAAA,GAAA,SAAAA,GAAA,SAAAA,GAAA,SAAAA,GAAA,UAAAE,GAAA,UAAAF,GAAA,gBAAAA,GAAA,UAAAA,GAAA,kBAAAA,GAAA,iBAAAA,GAAA,UAAAA,GAAA,oBAAAG,GAAA,cAAAH,GAAA,kBAAAA,GAAA,UAAAI,GAAA,iBAAAJ,GAAA,YAAAA,GAAA,sBAAAA,GAAA,aAAAK,EAAA,aAAAC,EAA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OAAOO,CAAK,CAC5B,EAAG,CAAC,CAAC,CACP,CAEO,SAASG,GACdC,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,CAGA,IAAOqB,GAAQ,CACb,IAAA3B,GACA,OAAAO,GACA,SAAAkB,EACF,wYC9FO,IAAMG,GAAU,CAACC,EAAW,IAAc,MAAM,KAAK,IAAI,CAAC,EAAI,CAAC,EAAE,KAAKA,CAAC,EAEvE,SAASC,GAGdC,EAAkBC,EAAqBC,EAAc,CACrD,OAAO,YAA4BC,EAAuC,CAExE,eAAQ,KAAK,GAAGH,CAAQ,uBAAuBC,CAAW,GAAG,EACtDC,EAAG,MAAM,KAAMC,CAAI,CAC5B,CACF,CAEO,IAAMC,GAAUL,GAAU,UAAW,eAAgBM,CAAY,EhCQxE,IAAMC,GAAQC,GAERC,GAAQD,GAERE,GAAkBF,GAElBG,GAAkBH", - "names": ["tonal_exports", "__export", "dist_exports", "ChordDictionary", "PcSet", "ScaleDictionary", "Tonal", "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", "scientificToAbcNotation", "note", "l", "o", "transpose", "interval", "distance", "from", "to", "abc_notation_default", "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", "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", "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", "includes", "filter", "isIncluded", "pcset_default", "chromaRotations", "setNum", "normalizedNum", "normalized", "pitch", "interval", "CHORDS", "data_default", "NoChordType", "EmptyPcset", "dictionary", "index", "get", "type", "chordType", "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", "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", "distance", "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", "isNamedPitch", "romanNumeral", "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", "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", "binary", "numbers", "pattern", "number", "digit", "hex", "hexNumber", "i", "onsets", "random", "length", "probability", "rnd", "probabilities", "rotate", "rotations", "len", "rotated", "pos", "euclid", "steps", "beats", "d", "v", "NoScale", "tokenize", "name", "i", "tonic", "note", "n", "type", "names", "get", "src", "tokens", "st", "notes", "transpose", "scale", "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", "fillStr", "s", "deprecate", "original", "alternative", "fn", "args", "isNamed", "isNamedPitch", "Tonal", "dist_exports", "PcSet", "ChordDictionary", "ScaleDictionary"] + "sourcesContent": ["import * as AbcNotation from \"@tonaljs/abc-notation\";\nimport * as Array from \"@tonaljs/array\";\nimport * as Chord from \"@tonaljs/chord\";\nimport * as ChordType from \"@tonaljs/chord-type\";\nimport * as Collection from \"@tonaljs/collection\";\nimport * as DurationValue from \"@tonaljs/duration-value\";\nimport * as Interval from \"@tonaljs/interval\";\nimport * as Key from \"@tonaljs/key\";\nimport * as Midi from \"@tonaljs/midi\";\nimport * as Mode from \"@tonaljs/mode\";\nimport * as Note from \"@tonaljs/note\";\nimport * as Pcset from \"@tonaljs/pcset\";\nimport * as Progression from \"@tonaljs/progression\";\nimport * as Range from \"@tonaljs/range\";\nimport * as RhythmPattern from \"@tonaljs/rhythm-pattern\";\nimport * as RomanNumeral from \"@tonaljs/roman-numeral\";\nimport * as Scale from \"@tonaljs/scale\";\nimport * as ScaleType from \"@tonaljs/scale-type\";\nimport * as TimeSignature from \"@tonaljs/time-signature\";\nimport * as VoiceLeading from \"@tonaljs/voice-leading\";\nimport * as Voicing from \"@tonaljs/voicing\";\nimport * as VoicingDictionary from \"@tonaljs/voicing-dictionary\";\n\nexport * from \"@tonaljs/core\";\n\n// deprecated (backwards compatibility)\nimport * as Core from \"@tonaljs/core\";\n/** @deprecated */\nconst Tonal = Core;\n/** @deprecated */\nconst PcSet = Pcset;\n/** @deprecated */\nconst ChordDictionary = ChordType;\n/** @deprecated */\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 RhythmPattern,\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, not pitch class, and in the same octave\n // it can be descending interval (see #243 & #428)\n const forceDescending =\n to.height === from.height &&\n to.midi !== null &&\n from.oct === to.oct &&\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\n/** @deprecated */\nexport default {\n abcToScientificNotation,\n scientificToAbcNotation,\n tokenize,\n transpose,\n distance,\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", "/* 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\n/** @deprecated */\nexport default {\n compact,\n permutations,\n range,\n rotate,\n shuffle,\n};\n", "import { compact, range, rotate } from \"@tonaljs/collection\";\nimport { NotFound } from \"@tonaljs/pitch\";\nimport { transpose } from \"@tonaljs/pitch-distance\";\nimport { Interval, IntervalName, interval } from \"@tonaljs/pitch-interval\";\nimport { Note, NoteName, note } from \"@tonaljs/pitch-note\";\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.get\n * @deprecated\n */\nexport const pcset = 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 */\nexport const 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 */\nexport const 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 * Get the intervals of a pcset *starting from C*\n * @private\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 */\nfunction 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 equal\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\n/** @deprecated */\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 {\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\n/** @deprecated */\nexport const chordType = 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\n/** @deprecated */\nexport const entries = 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\n/** @deprecated */\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 { modes } from \"@tonaljs/pcset\";\nimport { note } from \"@tonaljs/pitch-note\";\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\n/** @deprecated */\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\n/** @deprecated */\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 {\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\n/**\n * @deprecated\n * @use ScaleType.get\n */\nexport const scaleType = get;\n\n/**\n * Return a list of all scale types\n */\nexport function all() {\n return dictionary.slice();\n}\n\n/**\n * @deprecated\n * @use ScaleType.all\n */\nexport const entries = all;\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\n/** @deprecated */\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\n/** @deprecated */\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\n/** @deprecated */\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/pitch-note\";\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\n/** @deprecated */\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 { freqToMidi, midiToNoteName } from \"@tonaljs/midi\";\nimport { Pitch } from \"@tonaljs/pitch\";\nimport { distance as _dist, transpose as _tr } from \"@tonaljs/pitch-distance\";\nimport { IntervalName } from \"@tonaljs/pitch-interval\";\nimport {\n Note,\n NoteLiteral,\n NoteName,\n note as props,\n} from \"@tonaljs/pitch-note\";\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\nexport const distance = _dist;\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 * Note.eharmoinic(\"C##b\"); // => \"\"\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\n/** @deprecated */\nexport default {\n names,\n get,\n name,\n pitchClass,\n accidentals,\n octave,\n midi,\n ascending,\n descending,\n distance,\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 { isNamedPitch, isPitch, Pitch } from \"@tonaljs/pitch\";\nimport { interval } from \"@tonaljs/pitch-interval\";\nimport { accToAlt, altToAcc } from \"@tonaljs/pitch-note\";\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 : isNamedPitch(src)\n ? get(src.name)\n : NoRomanNumeral;\n}\n\n/**\n * @deprecated\n * @use RomanNumeral.get\n */\nexport const romanNumeral = get;\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\n/** @deprecated */\nexport default {\n names,\n get,\n // deprecated\n romanNumeral,\n};\n", "import { transpose, transposeFifths } from \"@tonaljs/note\";\nimport { accToAlt, altToAcc, note } from \"@tonaljs/pitch-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 readonly secondaryDominants: readonly string[];\n readonly secondaryDominantSupertonics: readonly string[];\n readonly substituteDominants: readonly string[];\n readonly substituteDominantSupertonics: readonly string[];\n\n // @deprecated use secondaryDominantsSupertonic\n readonly secondaryDominantsMinorRelative: readonly string[];\n // @deprecated use substituteDominantSupertonics\n readonly substituteDominantsMinorRelative: 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 secondaryDominants: Empty,\n secondaryDominantSupertonics: Empty,\n substituteDominantsMinorRelative: Empty,\n substituteDominants: Empty,\n substituteDominantSupertonics: Empty,\n secondaryDominantsMinorRelative: Empty,\n};\n\nexport interface MajorKey extends Key, KeyScale {\n readonly type: \"major\";\n readonly minorRelative: string;\n readonly scale: readonly string[];\n readonly substituteDominants: readonly string[];\n readonly secondaryDominantSupertonics: readonly string[];\n // @deprecated use secondaryDominantsSupertonic\n readonly substituteDominantsMinorRelative: readonly string[];\n}\n\nconst NoMajorKey: MajorKey = {\n ...NoKey,\n ...NoKeyScale,\n type: \"major\",\n minorRelative: \"\",\n scale: Empty,\n substituteDominants: Empty,\n secondaryDominantSupertonics: 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\nexport type KeyChord = {\n name: string;\n roles: string[];\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 chordTypes: 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 const chords = mapScaleToType(scale, chordTypes);\n const secondaryDominants = scale\n .map((note) => transpose(note, \"5P\"))\n .map((note) =>\n // A secondary dominant is a V chord which:\n // 1. is not diatonic to the key,\n // 2. it must have a diatonic root.\n scale.includes(note) && !chords.includes(note + \"7\") ? note + \"7\" : \"\",\n );\n\n const secondaryDominantSupertonics = supertonics(\n secondaryDominants,\n triads,\n );\n const substituteDominants = secondaryDominants.map((chord) => {\n if (!chord) return \"\";\n const domRoot = chord.slice(0, -1);\n const subRoot = transpose(domRoot, \"5d\");\n return subRoot + \"7\";\n });\n const substituteDominantSupertonics = supertonics(\n substituteDominants,\n triads,\n );\n\n return {\n tonic,\n grades,\n intervals,\n scale,\n triads: mapScaleToType(scale, triads),\n chords,\n chordsHarmonicFunction: harmonicFunctions.slice(),\n chordScales: mapScaleToType(scale, chordScales, \" \"),\n secondaryDominants,\n secondaryDominantSupertonics,\n substituteDominants,\n substituteDominantSupertonics,\n\n // @deprecated use secondaryDominantsSupertonic\n secondaryDominantsMinorRelative: secondaryDominantSupertonics,\n // @deprecated use secondaryDominantsSupertonic\n substituteDominantsMinorRelative: substituteDominantSupertonics,\n };\n };\n}\n\nconst supertonics = (dominants: string[], targetTriads: string[]) => {\n return dominants.map((chord, index) => {\n if (!chord) return \"\";\n const domRoot = chord.slice(0, -1);\n const minorRoot = transpose(domRoot, \"5P\");\n const target = targetTriads[index];\n const isMinor = target.endsWith(\"m\");\n return isMinor ? minorRoot + \"m7\" : minorRoot + \"m7b5\";\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\n return {\n ...keyScale,\n type: \"major\",\n minorRelative: transpose(pc, \"-3m\"),\n alteration,\n keySignature: altToAcc(alteration),\n };\n}\n\n/**\n * Get a list of available chords for a given major key\n * @param tonic\n * @returns array of { name: string, roles: string[] }\n */\nexport function majorKeyChords(tonic: string): KeyChord[] {\n const key = majorKey(tonic);\n const chords: KeyChord[] = [];\n keyChordsOf(key, chords);\n return chords;\n}\n\n/**\n * Get a list of available chords for a given major key\n * @param tonic\n * @returns array of { name: string, roles: string[] }\n */\nexport function minorKeyChords(tonic: string): KeyChord[] {\n const key = minorKey(tonic);\n const chords: KeyChord[] = [];\n keyChordsOf(key.natural, chords);\n keyChordsOf(key.harmonic, chords);\n keyChordsOf(key.melodic, chords);\n return chords;\n}\n\nfunction keyChordsOf(key: KeyScale, chords: KeyChord[]) {\n const updateChord = (name: string, newRole: string) => {\n if (!name) return;\n let keyChord = chords.find((chord) => chord.name === name);\n if (!keyChord) {\n keyChord = { name, roles: [] };\n chords.push(keyChord);\n }\n if (newRole && !keyChord.roles.includes(newRole)) {\n keyChord.roles.push(newRole);\n }\n };\n\n key.chords.forEach((chordName, index) =>\n updateChord(chordName, key.chordsHarmonicFunction[index]),\n );\n key.secondaryDominants.forEach((chordName, index) =>\n updateChord(chordName, `V/${key.grades[index]}`),\n );\n key.secondaryDominantSupertonics.forEach((chordName, index) =>\n updateChord(chordName, `ii/${key.grades[index]}`),\n );\n key.substituteDominants.forEach((chordName, index) =>\n updateChord(chordName, `subV/${key.grades[index]}`),\n );\n key.substituteDominantSupertonics.forEach((chordName, index) =>\n updateChord(chordName, `subii/${key.grades[index]}`),\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\n/** @deprecated */\nexport default { majorKey, majorTonicFromKeySignature, minorKey };\n", "import { rotate } from \"@tonaljs/collection\";\nimport { simplify, transposeFifths } from \"@tonaljs/interval\";\nimport { EmptyPcset, Pcset } from \"@tonaljs/pcset\";\nimport { transpose } from \"@tonaljs/pitch-distance\";\nimport { NoteName } from \"@tonaljs/pitch-note\";\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 | { name: string };\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\n/** @deprecated */\nexport const mode = get;\n\n/**\n * Get a list of all modes\n */\nexport function all() {\n return modes.slice();\n}\n\n/** @deprecated */\nexport const entries = 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\n/** @deprecated */\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, transpose } from \"@tonaljs/pitch-distance\";\nimport { interval } from \"@tonaljs/pitch-interval\";\nimport { NoteLiteral } from \"@tonaljs/pitch-note\";\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\n/** @deprecated */\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\n/** @deprecated */\nexport default { numeric, chromatic };\n", "type RhythmPatternValue = 0 | 1;\n\nexport type RhythmPattern = Array;\n\n/**\n * Create a rhythm pattern from a number or concatenation of numbers in binary form\n * @param numbers one or more number\n * @returns an array of 0s and 1s representing the rhythm pattern\n * @example\n * binary(13) // => [1, 1, 0, 1]\n * binary(12, 13) // => [1, 1, 0, 0, 1, 1, 0, 1]\n */\nexport function binary(...numbers: number[]): RhythmPattern {\n return numbers.reduce((pattern, number) => {\n number\n .toString(2)\n .split(\"\")\n .forEach((digit: string) => {\n pattern.push(parseInt(digit) as RhythmPatternValue);\n });\n return pattern;\n }, [] as RhythmPattern);\n}\n\n/**\n * Create a rhythmic pattern using an hexadecimal numbers\n * @param hexNumber string with the hexadecimal number\n * @returns an array of 0s and 1s representing the rhythm pattern\n * @example\n * R.hex(\"8f\"); // => [1, 0, 0, 0, 1, 1, 1, 1]\n */\nexport function hex(hexNumber: string): RhythmPattern {\n const pattern: RhythmPattern = [];\n for (let i = 0; i < hexNumber.length; i++) {\n const digit = parseInt(\"0x\" + hexNumber[i]);\n const binary = isNaN(digit) ? \"0000\" : digit.toString(2).padStart(4, \"0\");\n binary.split(\"\").forEach((digit: string) => {\n pattern.push(digit === \"1\" ? 1 : 0);\n });\n }\n return pattern;\n}\n\n/**\n * Create a rhythm pattern from the onsets\n * @param numbers the onsets sizes\n * @returns an array of 0s and 1s representing the rhythm pattern\n * @example\n * onsets(1, 2, 2, 1) // => [1, 0, 1, 0, 0, 1, 0, 0, 1, 0]\n */\nexport function onsets(...numbers: number[]): RhythmPattern {\n return numbers.reduce((pattern, number) => {\n pattern.push(1);\n for (let i = 0; i < number; i++) {\n pattern.push(0);\n }\n return pattern;\n }, [] as RhythmPattern);\n}\n\n/**\n * Create a random rhythm pattern with a specified length\n * @param length length of the pattern\n * @param probability Threshold where random number is considered a beat (defaults to 0.5)\n * @param rnd A random function (Math.random by default)\n * @returns an array of 0s and 1s representing the rhythm pattern\n * @example\n * random(4) // => [1, 0, 0, 1]\n */\nexport function random(\n length: number,\n probability = 0.5,\n rnd: () => number = Math.random,\n): RhythmPattern {\n const pattern: RhythmPattern = [];\n for (let i = 0; i < length; i++) {\n pattern.push(rnd() >= probability ? 1 : 0);\n }\n return pattern;\n}\n\n/**\n * Create a rhythm pattern based on the given probability thresholds\n * @param probabilities An array with the probability of each step to be a beat\n * @param rnd A random function (Math.random by default)\n * @returns an array of 0s and 1s representing the rhythm pattern\n * @example\n * probability([0.6, 0, 0.2, 0.5]) // => [0, 0, 0, 1]\n */\nexport function probability(\n probabilities: number[],\n rnd: () => number = Math.random,\n): RhythmPattern {\n return probabilities.map((probability) => (rnd() <= probability ? 1 : 0));\n}\n\n/**\n * Rotate a pattern right\n * @param pattern the pattern to rotate\n * @param rotations the number of steps to rotate\n * @returns the rotated pattern (an array of 0s and 1s)\n * @example\n * rotate([1, 0, 0, 1], 2); // => [0, 1, 1, 0]\n *\n */\nexport function rotate(\n pattern: RhythmPattern,\n rotations: number,\n): RhythmPattern {\n const len = pattern.length;\n const rotated: RhythmPattern = [];\n for (let i = 0; i < len; i++) {\n const pos = (((i - rotations) % len) + len) % len;\n rotated[i] = pattern[pos];\n }\n return rotated;\n}\n\n/**\n * Generates an euclidean rhythm pattern\n * @param steps The length of the pattern\n * @param beats The number of beats\n * @returns an array with 0s and 1s representing the rhythmic pattern\n * @example\n * euclid(8, 3); // => [1, 0, 0, 1, 0, 0, 1, 0]\n */\nexport function euclid(steps: number, beats: number): RhythmPattern {\n const pattern: RhythmPattern = [];\n let d = -1;\n\n for (let i = 0; i < steps; i++) {\n const v = Math.floor(i * (beats / steps));\n pattern[i] = v !== d ? 1 : 0;\n d = v;\n }\n return pattern;\n}\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 { enharmonic, fromMidi, sortedUniqNames } from \"@tonaljs/note\";\nimport {\n chroma,\n isChroma,\n isSubsetOf,\n isSupersetOf,\n modes,\n} from \"@tonaljs/pcset\";\nimport { tonicIntervalsTransposer, transpose } from \"@tonaljs/pitch-distance\";\nimport { note, NoteName } from \"@tonaljs/pitch-note\";\nimport {\n all,\n get as getScaleType,\n ScaleType,\n names as scaleTypeNames,\n all as scaleTypes,\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).toLowerCase();\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\n/**\n * @deprecated\n * @use Scale.get\n */\nexport const scale = 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\n/** @deprecated */\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\n/** @deprecated */\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\n/** @deprecated */\nexport default {\n topNoteDiff,\n};\n", "import Chord from \"@tonaljs/chord\";\nimport { all, lefthand, triads, VoicingDictionary } from \"./data\";\nexport { all, lefthand, triads } from \"./data\";\n\nexport const defaultDictionary: VoicingDictionary = lefthand;\n\nexport function 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\n/** @deprecated */\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\nexport function 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\nexport function 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\nexport function 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\n/** @deprecated */\nexport default {\n get,\n search,\n sequence,\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"], + "mappings": "scAAA,IAAAA,GAAA,GAAAC,EAAAD,GAAA,iBAAAE,GAAA,UAAAA,GAAA,UAAAA,GAAA,oBAAAC,GAAA,cAAAD,GAAA,eAAAA,GAAA,SAAAA,GAAA,kBAAAA,GAAA,aAAAA,GAAA,QAAAA,GAAA,SAAAA,GAAA,SAAAA,GAAA,SAAAA,GAAA,UAAAE,GAAA,UAAAF,GAAA,gBAAAA,GAAA,UAAAA,GAAA,kBAAAA,GA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E,KAAKA,CAAC,EAEvE,SAASC,GAGdC,EAAkBC,EAAqBC,EAAc,CACrD,OAAO,YAA4BC,EAAuC,CAExE,eAAQ,KAAK,GAAGH,CAAQ,uBAAuBC,CAAW,GAAG,EACtDC,EAAG,MAAM,KAAMC,CAAI,CAC5B,CACF,CAEO,IAAMC,GAAUL,GAAU,UAAW,eAAgBM,CAAY,EhCQxE,IAAMC,GAAQC,GAERC,GAAQD,GAERE,GAAkBF,GAElBG,GAAkBH", + "names": ["tonal_exports", "__export", "dist_exports", "ChordDictionary", "PcSet", "ScaleDictionary", "Tonal", "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", "scientificToAbcNotation", "note", "l", "o", "transpose", "interval", "distance", "from", "to", "abc_notation_default", "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", "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", "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", "includes", "filter", "isIncluded", "pcset_default", "chromaRotations", "setNum", "normalizedNum", "normalized", "pitch", "interval", "CHORDS", "data_default", "NoChordType", "EmptyPcset", "dictionary", "index", "get", "type", "chordType", "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", "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", "distance", "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", "isNamedPitch", "romanNumeral", "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", "chordTypes", "harmonicFunctions", "chordScales", "tonic", "intervals", "gr", "get", "interval", "transpose", "chords", "secondaryDominants", "note", "secondaryDominantSupertonics", "supertonics", "substituteDominants", "chord", "domRoot", "substituteDominantSupertonics", "dominants", "targetTriads", "index", "minorRoot", "distInFifths", "from", "to", "f", "t", "MajorScale", "NaturalScale", "HarmonicScale", "MelodicScale", "majorKey", "pc", "alteration", "altToAcc", "majorKeyChords", "key", "keyChordsOf", "minorKeyChords", "minorKey", "updateChord", "name", "newRole", "keyChord", "chordName", "tnc", "majorTonicFromKeySignature", "sig", "transposeFifths", "accToAlt", "key_default", "MODES", "NoMode", "EmptyPcset", "modes", "toMode", "index", "mode", "alias", "get", "name", "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", "binary", "numbers", "pattern", "number", "digit", "hex", "hexNumber", "i", "onsets", "random", "length", "probability", "rnd", "probabilities", "rotate", "rotations", "len", "rotated", "pos", "euclid", "steps", "beats", "d", "v", "NoScale", "tokenize", "name", "i", "tonic", "note", "n", "type", "names", "get", "src", "tokens", "st", "notes", "transpose", "scale", "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", "fillStr", "s", "deprecate", "original", "alternative", "fn", "args", "isNamed", "isNamedPitch", "Tonal", "dist_exports", "PcSet", "ChordDictionary", "ScaleDictionary"] } diff --git a/packages/tonal/package.json b/packages/tonal/package.json index c65c0863..0a8389da 100644 --- a/packages/tonal/package.json +++ b/packages/tonal/package.json @@ -1,6 +1,6 @@ { "name": "tonal", - "version": "6.2.0", + "version": "6.3.0", "description": "tonaljs music theory library", "keywords": [ "music", @@ -24,7 +24,7 @@ "@tonaljs/core": "5.0.1", "@tonaljs/duration-value": "4.9.0", "@tonaljs/interval": "5.1.0", - "@tonaljs/key": "4.10.0", + "@tonaljs/key": "4.11.0", "@tonaljs/midi": "4.10.0", "@tonaljs/mode": "4.9.0", "@tonaljs/note": "4.11.0", diff --git a/site/content/docs/harmony/keys.md b/site/content/docs/harmony/keys.md index ac572805..6ab123a6 100644 --- a/site/content/docs/harmony/keys.md +++ b/site/content/docs/harmony/keys.md @@ -1,14 +1,15 @@ --- title: Keys -description: Get properties of keys +description: Key scales and chords --- -Scale and chords of major and minor keys. +Obtain information of a key's scales and chords: ```js -import { Key } from "tonal"; +import * as Key from "tonal"; Key.majorKey("C").triads; // => ["C", "Dm", "Em", "F", "G" "Am", "Bdim"], +Key.majorKeyChords("C").find((chord) => chord.name === "Em"); // => { name: "Em", roles: ["T", "ii/II"] } ``` ## API @@ -42,9 +43,9 @@ Key.majorKey("C") // => chordsHarmonicFunction: ["T", "SD", "T", "SD", "D", "T", "D"], chordScales: ["C major", "D dorian", "E phrygian", "F lydian", "G mixolydian", "A minor", "B locrian"], secondaryDominants: ["", "A7", "B7", "C7", "D7", "E7", ""], - secondaryDominantsMinorRelative: ["" "Em7b5", "F#m7", "Gm7", "Am7", "Bm7b5", ""], + secondaryDominantsSupertonics: ["" "Em7b5", "F#m7", "Gm7", "Am7", "Bm7b5", ""], substituteDominants: ["" "Eb7", "F7", "Gb7", "Ab7", "Bb7", ""], - substituteDominantsMinorRelative: ["" "Em7", "Cm7", "Dbm7", "Am7", "Fm7", ""] + substituteDominantsSupertonics: [ '', 'Bbm7', 'Cm7', 'Dbm7b5', 'Ebm7b5', 'Fm7', '' ], } ``` @@ -66,12 +67,57 @@ Key.minorKey("C") // => tonic: "C", grades: ["I", "II", "bIII", "IV", "V", "bVI", "bVII"], intervals: ["1P", "2M", "3m", "4P", "5P", "6m", "7m"], - scale: ["C", "D", "Eb", "F", "G", "Ab", "Bb"], + scale: ["C", "D", "Eb", "F", "G", "Ab", "Bb"], triads: ["Cm", "Ddim", "Eb", "Fm", "Gm", "Ab", "Bb"], chords: ["Cm7", "Dm7b5", "Ebmaj7", "Fm7", "Gm7", "Abmaj7", "Bb7"], - chordsHarmonicFunction: ["T", "SD", "T", "SD", "D", "SD", "SD"], - chordScales: ["C minor", "D locrian", "Eb major", "F dorian", "G phrygian", "Ab lydian", "Bb mixolydian" - ] + chordsHarmonicFunction: ["T", "SD", "T", "SD", "D", "SD", "SD"], + chordScales: [ + "C minor", + "D locrian", + "Eb major", + "F dorian", + "G phrygian", + "Ab lydian", + "Bb mixolydian", + ], + secondaryDominants: ["G7", "", "", "C7", "D7", "Eb7", "F7"], + secondaryDominantSupertonics: [ + "Dm7", + "", + "", + "Gm7", + "Am7", + "Bbm7b5", + "Cm7b5", + ], + substituteDominants: ["Db7", "", "", "Gb7", "Ab7", "Bbb7", "Cb7"], + substituteDominantSupertonics: [ + "Abm7", + "", + "", + "Dbm7", + "Ebm7", + "Fbm7b5", + "Gbm7b5", + ], + secondaryDominantsMinorRelative: [ + "Dm7", + "", + "", + "Gm7", + "Am7", + "Bbm7b5", + "Cm7b5", + ], + substituteDominantsMinorRelative: [ + "Abm7", + "", + "", + "Dbm7", + "Ebm7", + "Fbm7b5", + "Gbm7b5", + ], }, harmonic: { tonic: "C", @@ -79,10 +125,31 @@ Key.minorKey("C") // => intervals: ["1P", "2M", "3m", "4P", "5P", "6m", "7M"], scale: ["C", "D", "Eb", "F", "G", "Ab", "B"], triads: ["Cm", "Ddim", "Ebaug", "Fm", "G", "Ab", "Bdim"], - chords: ["CmMaj7", "Dm7b5", "Eb+maj7", "Fm7", "G7" "Abmaj7", "Bo7"], - chordsHarmonicFunction: ["T", "SD", "T", "SD", "D", "SD", "D"], - chordScales: ["C harmonic minor", "D locrian 6", "Eb major augmented", "F lydian diminished", "G phrygian dominant", "Ab lydian #9", "B ultralocrian" - ] + chords: ["CmMaj7", "Dm7b5", "Eb+maj7", "Fm7", "G7", "Abmaj7", "Bo7"], + chordsHarmonicFunction: ["T", "SD", "T", "SD", "D", "SD", "D"], + chordScales: [ + "C harmonic minor", + "D locrian 6", + "Eb major augmented", + "F lydian diminished", + "G phrygian dominant", + "Ab lydian #9", + "B ultralocrian", + ], + secondaryDominants: ["", "", "", "C7", "D7", "Eb7", ""], + secondaryDominantSupertonics: ["", "", "", "Gm7", "Am7b5", "Bbm7b5", ""], + substituteDominants: ["", "", "", "Gb7", "Ab7", "Bbb7", ""], + substituteDominantSupertonics: ["", "", "", "Dbm7", "Ebm7b5", "Fbm7b5", ""], + secondaryDominantsMinorRelative: ["", "", "", "Gm7", "Am7b5", "Bbm7b5", ""], + substituteDominantsMinorRelative: [ + "", + "", + "", + "Dbm7", + "Ebm7b5", + "Fbm7b5", + "", + ], }, melodic: { tonic: "C", @@ -90,12 +157,33 @@ Key.minorKey("C") // => intervals: ["1P", "2M", "3m", "4P", "5P", "6M", "7M"], scale: ["C", "D", "Eb", "F", "G", "A", "B"], triads: ["Cm", "Dm", "Ebaug", "F", "G", "Adim", "Bdim"], - chords: ["Cm6", "Dm7", "Eb+maj7", "F7", "G7", "Am7b5", "Bm7b5" ], - chordsHarmonicFunction: ["T", "SD", "T", "SD", "D", "", ""], - chordScales: ["C melodic minor", "D dorian b2", "Eb lydian augmented", "F lydian dominant", "G mixolydian b6", "A locrian #2", "B altered" - ] - } -} + chords: ["Cm6", "Dm7", "Eb+maj7", "F7", "G7", "Am7b5", "Bm7b5"], + chordsHarmonicFunction: ["T", "SD", "T", "SD", "D", "", ""], + chordScales: [ + "C melodic minor", + "D dorian b2", + "Eb lydian augmented", + "F lydian dominant", + "G mixolydian b6", + "A locrian #2", + "B altered", + ], + secondaryDominants: ["", "A7", "", "C7", "D7", "", ""], + secondaryDominantSupertonics: ["", "Em7", "", "Gm7b5", "Am7b5", "", ""], + substituteDominants: ["", "Eb7", "", "Gb7", "Ab7", "", ""], + substituteDominantSupertonics: ["", "Bbm7", "", "Dbm7b5", "Ebm7b5", "", ""], + secondaryDominantsMinorRelative: ["", "Em7", "", "Gm7b5", "Am7b5", "", ""], + substituteDominantsMinorRelative: [ + "", + "Bbm7", + "", + "Dbm7b5", + "Ebm7b5", + "", + "", + ], + }, +}; ``` ### `Key.majorTonicFromKeySignature` @@ -108,6 +196,32 @@ Example: Key.majorTonicFromKeySignature("bbb"); // => Eb ``` +### `Key.majorKeyChords` + +`majorKeyChords(tonic: string) => Array<{ name: string, roles: string[] }>` + +Return a list of all available chords for a given major key. Is an array of `{ name: string, roles: string[] }` + +```js +Key.majorKeyChords("C") + .map((chord) => chord.name) + .join(", "); +// => "Cmaj7, Dm7, Em7, Fmaj7, G7, Am7, Bm7b5, A7, B7, C7, D7, E7, F#m7, Gm7b5, Am7b5, Bm7, Eb7, F7, Gb7, Ab7, Bb7, Bbm7, Cm7, Dbm7b5, Ebm7b5, Fm7" +``` + +### `Key.minorKeyChords` + +`minorKeyChords(tonic: string) => Array<{ name: string, roles: string[] }>` + +Return a list of all available chords for a given minor key: + +```js +Key.minorKeyChords("C") + .map((chord) => chord.name) + .join(", "); +// => "Cm7, Dm7b5, Ebmaj7, Fm7, Gm7, Abmaj7, Bb7, G7, C7, D7, Eb7, F7, Dm7, Am7, Bbm7b5, Cm7b5, Db7, Gb7, Ab7, Bbb7, Cb7, Abm7, Dbm7, Ebm7, Fbm7b5, Gbm7b5, CmMaj7, Eb+maj7, Bo7, Am7b5, Ebm7b5, Cm6, Bm7b5, A7, Em7, Gm7b5, Bbm7, Dbm7b5" +``` + ## How to... ### How to get minor tonic from key signature