diff --git a/index.js b/index.js index 41e09be..2290e57 100644 --- a/index.js +++ b/index.js @@ -58,7 +58,7 @@ module.exports = function(symbol) { var sub2 = (i + 1) < len ? symbol.substr(i, 2).toLowerCase() : null; if (sub3 in SYMBOLS) name = sub3; - else if (sub2 in SYMBOLS) + else if (sub2 in SYMBOLS && symbol.substr(i + 1, 3).toLowerCase() !== "add") name = sub2; else if (c in SYMBOLS) name = c; @@ -71,7 +71,6 @@ module.exports = function(symbol) { if (name === 'M' || name === 'ma' || name === 'maj') explicitMajor = true; - i += name.length - 1; parsing = 'extension'; } else if (parsing === 'extension') { @@ -151,6 +150,10 @@ module.exports = function(symbol) { additionals.push('P11'); else if (next === '13') additionals.push('M13'); + else if (next === '4') + additionals.push('P4'); + else if (next === '2') + additionals.push('M2'); else { throw ParseError({ title: 'Invalid token', diff --git a/test/chords.js b/test/chords.js index fb2da8b..0ee92a1 100644 --- a/test/chords.js +++ b/test/chords.js @@ -19,6 +19,8 @@ test('Parsing chops', function(t) { t.deepEqual(daccord('mi7'), ['P1', 'm3', 'P5', 'm7']); t.deepEqual(daccord('M'), ['P1', 'M3', 'P5']); t.deepEqual(daccord('Ma'), ['P1', 'M3', 'P5']); + t.deepEqual(daccord('Madd11'), ['P1', 'M3', 'P5', 'P11']); + t.deepEqual(daccord('madd11'), ['P1', 'm3', 'P5', 'P11']); t.deepEqual(daccord('M#5'), ['P1', 'M3', 'A5']); t.deepEqual(daccord('maj7'), ['P1', 'M3', 'P5', 'M7']); t.deepEqual(daccord('+'), ['P1', 'M3', 'A5']);