tonaljs / tonal

A functional music theory library for Javascript
https://tonaljs.github.io/tonal/docs
3.78k stars 218 forks source link

VoicingDictionary should enable mapping multiple chord symbols to one set of intervals #227

Open felixroos opened 3 years ago

felixroos commented 3 years ago

Copied from https://github.com/tonaljs/tonal/pull/224#issuecomment-727252979

This should be done before publish to avoid a breaking change (if we decide to do it)

Before:

export const lefthand: VoicingDictionary = {
  m7: ["3m 5P 7m 9M", "7m 9M 10m 12P"],
  /* more symbols */
}

after:

const lefthand = [
  [['m7','m9'], ["3m 5P 7m 9M", "7m 9M 10m 12P"]],
  /* more symbols */
];

This format allows mapping more than one symbol to a set of intervals. This resembles how many chord symbols are sometimes used synonymously. For example, in a jazz leadsheet, a "m7" is mostly played with a 9 (like above). If the sheet contains a "m9" instead, it is played exactly the same.

Additionally, this makes it possible to define the same symbol multiple times, which could be useful for some scenarios. VoicingDictionary.lookup should therefore filter all dictionary items by the given symbol and concat all sets that match.

felixroos commented 3 years ago

defining shell voicings would be much shorter with this:

const shell = [
  [["m7", "m9", "m11", "m13", /* many many more*/], ["3m 7m", "7m 10m"]],
  /* more symbols */
];
danigb commented 3 years ago

I think we should not export the data directly. See #230