Skip to content

Commit 58e16e1

Browse files
committed
reorganize musical modes into canonical pitch collections with aliases
1 parent 2fda20c commit 58e16e1

File tree

1 file changed

+71
-59
lines changed

1 file changed

+71
-59
lines changed

js/utils/musicutils.js

Lines changed: 71 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1567,67 +1567,79 @@ const MODE_PIE_MENUS = {
15671567
// The table contains the intervals that define the modes.
15681568
// All of these modes assume 12 semitones per octave.
15691569
// See http://www.pianoscales.org <== this is in no way definitive
1570-
// TODO: better system of organizing and naming collections of pitches
1571-
const MUSICALMODES = {
1572-
// 12 notes in an octave
1573-
"chromatic": [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
1574-
1575-
// 8 notes in an octave
1576-
"algerian": [2, 1, 2, 1, 1, 1, 3, 1],
1577-
"diminished": [2, 1, 2, 1, 2, 1, 2, 1],
1578-
"spanish": [1, 2, 1, 1, 1, 2, 2, 2],
1579-
"octatonic": [1, 2, 1, 2, 1, 2, 1, 2],
1580-
"bebop": [1, 1, 1, 2, 2, 1, 2, 2],
1581-
1582-
// 7 notes in an octave
1583-
"major": [2, 2, 1, 2, 2, 2, 1],
1584-
"harmonic major": [2, 2, 1, 2, 1, 3, 1],
1585-
"natural minor": [2, 1, 2, 2, 1, 2, 2],
1586-
"harmonic minor": [2, 1, 2, 2, 1, 3, 1],
1587-
"melodic minor": [2, 1, 2, 2, 2, 2, 1],
1588-
1589-
"ionian": [2, 2, 1, 2, 2, 2, 1],
1590-
"dorian": [2, 1, 2, 2, 2, 1, 2],
1591-
"phrygian": [1, 2, 2, 2, 1, 2, 2],
1592-
"lydian": [2, 2, 2, 1, 2, 2, 1],
1593-
"mixolydian": [2, 2, 1, 2, 2, 1, 2],
1594-
"minor": [2, 1, 2, 2, 1, 2, 2],
1595-
"aeolian": [2, 1, 2, 2, 1, 2, 2],
1596-
"locrian": [1, 2, 2, 1, 2, 2, 2],
1597-
1598-
"jazz minor": [2, 1, 2, 2, 2, 2, 1],
1599-
1600-
"arabic": [2, 2, 1, 1, 2, 2, 2],
1601-
"byzantine": [1, 3, 1, 2, 1, 3, 1],
1602-
"enigmatic": [1, 3, 2, 2, 2, 1, 1],
1603-
"ethiopian": [2, 1, 2, 2, 1, 2, 2],
1604-
"geez": [2, 1, 2, 2, 1, 2, 2],
1605-
"hindu": [2, 2, 1, 2, 1, 2, 2],
1606-
"hungarian": [2, 1, 3, 1, 1, 3, 1],
1607-
"maqam": [1, 3, 1, 2, 1, 3, 1],
1608-
"romanian minor": [2, 1, 3, 1, 2, 1, 2],
1609-
"spanish gypsy": [1, 3, 1, 2, 1, 2, 2],
1610-
1611-
// 6 notes in an octave
1612-
"minor blues": [3, 2, 1, 1, 3, 2],
1613-
"major blues": [2, 1, 1, 3, 2, 2],
1614-
"whole tone": [2, 2, 2, 2, 2, 2],
1615-
1616-
// 5 notes in an octave
1617-
"major pentatonic": [2, 2, 3, 2, 3],
1618-
"minor pentatonic": [3, 2, 2, 3, 2],
1619-
"chinese": [4, 2, 1, 4, 1],
1620-
"egyptian": [2, 3, 2, 3, 2],
1621-
"hirajoshi": [1, 4, 1, 4, 2],
1622-
"in": [1, 4, 2, 1, 4],
1623-
"minyo": [3, 2, 2, 3, 2],
1624-
"fibonacci": [1, 1, 2, 3, 5],
1625-
"alt pentatonic": [2, 3, 2, 2, 3],
1626-
1627-
// User definition overrides this constant
1628-
"custom": [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
1570+
const PITCH_COLLECTIONS = {
1571+
"12": {
1572+
"chromatic": [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
1573+
},
1574+
"8": {
1575+
"algerian": [2, 1, 2, 1, 1, 1, 3, 1],
1576+
"diminished": [2, 1, 2, 1, 2, 1, 2, 1],
1577+
"spanish": [1, 2, 1, 1, 1, 2, 2, 2],
1578+
"octatonic": [1, 2, 1, 2, 1, 2, 1, 2],
1579+
"bebop": [1, 1, 1, 2, 2, 1, 2, 2]
1580+
},
1581+
"7": {
1582+
"major": [2, 2, 1, 2, 2, 2, 1],
1583+
"harmonic major": [2, 2, 1, 2, 1, 3, 1],
1584+
"natural minor": [2, 1, 2, 2, 1, 2, 2],
1585+
"harmonic minor": [2, 1, 2, 2, 1, 3, 1],
1586+
"melodic minor": [2, 1, 2, 2, 2, 2, 1],
1587+
"dorian": [2, 1, 2, 2, 2, 1, 2],
1588+
"phrygian": [1, 2, 2, 2, 1, 2, 2],
1589+
"lydian": [2, 2, 2, 1, 2, 2, 1],
1590+
"mixolydian": [2, 2, 1, 2, 2, 1, 2],
1591+
"locrian": [1, 2, 2, 1, 2, 2, 2],
1592+
"arabic": [2, 2, 1, 1, 2, 2, 2],
1593+
"byzantine": [1, 3, 1, 2, 1, 3, 1],
1594+
"enigmatic": [1, 3, 2, 2, 2, 1, 1],
1595+
"hindu": [2, 2, 1, 2, 1, 2, 2],
1596+
"hungarian": [2, 1, 3, 1, 1, 3, 1],
1597+
"romanian minor": [2, 1, 3, 1, 2, 1, 2],
1598+
"spanish gypsy": [1, 3, 1, 2, 1, 2, 2]
1599+
},
1600+
"6": {
1601+
"minor blues": [3, 2, 1, 1, 3, 2],
1602+
"major blues": [2, 1, 1, 3, 2, 2],
1603+
"whole tone": [2, 2, 2, 2, 2, 2]
1604+
},
1605+
"5": {
1606+
"major pentatonic": [2, 2, 3, 2, 3],
1607+
"minor pentatonic": [3, 2, 2, 3, 2],
1608+
"chinese": [4, 2, 1, 4, 1],
1609+
"egyptian": [2, 3, 2, 3, 2],
1610+
"hirajoshi": [1, 4, 1, 4, 2],
1611+
"in": [1, 4, 2, 1, 4],
1612+
"fibonacci": [1, 1, 2, 3, 5],
1613+
"alt pentatonic": [2, 3, 2, 2, 3]
1614+
}
1615+
};
1616+
1617+
const PITCH_COLLECTION_ALIASES = {
1618+
"ionian": "major",
1619+
"minor": "natural minor",
1620+
"aeolian": "natural minor",
1621+
"ethiopian": "natural minor",
1622+
"geez": "natural minor",
1623+
"jazz minor": "melodic minor",
1624+
"maqam": "byzantine",
1625+
"minyo": "minor pentatonic"
16291626
};
16301627

1628+
const MUSICALMODES = {};
1629+
for (const count in PITCH_COLLECTIONS) {
1630+
const collections = PITCH_COLLECTIONS[count];
1631+
for (const name in collections) {
1632+
MUSICALMODES[name] = collections[name];
1633+
}
1634+
}
1635+
1636+
for (const alias in PITCH_COLLECTION_ALIASES) {
1637+
MUSICALMODES[alias] = MUSICALMODES[PITCH_COLLECTION_ALIASES[alias]];
1638+
}
1639+
1640+
// User definition overrides this constant.
1641+
MUSICALMODES["custom"] = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1];
1642+
16311643
/**
16321644
* Maqam table mapping specific maqams to their corresponding keys.
16331645
* @constant {Object}

0 commit comments

Comments
 (0)