tonaljs / tonal

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

Set Number: Which source do you use / refer to? #142

Closed rowild closed 4 years ago

rowild commented 4 years ago

Hi!

I was wondering which source you use for the set numbers. I know Alan Forte's system, which is quite different (and not yet implement in this library, right?) and I know John Rahn and Joseph N Straus's systems, none of whom use 0 to 4096.

I also ask, because when I list them, I get this one strange chord "M" (setNum 2192), which, as a second option has ... nothing? How can / does this happen? Please see enclosed screenshot. Bildschirmfoto 2020-03-12 um 11 00 25

Thank you!

danigb commented 4 years ago

Briefly: the set chroma is generated (12-digit binary number, one digit per pitch class. 1 means note).

For example, for pitch class set [c, d] -> chroma 101000000000

Set number: that binary number to base 10 integer

I don't remember the reference

rowild commented 4 years ago

Any idea why 2192 happens?

danigb commented 4 years ago

Can you post the code snippet?

rowild commented 4 years ago

Here is a codesandbox: https://codesandbox.io/s/list-of-tonaljs-chords-ntjye

There are also some chords that have an "_" (underline). I have never seen such a symbol in chord namings - are those on purpose?

danigb commented 4 years ago

Thanks for the sandbox 👍

Okey, I see: 2192 is the Major chord (1P , 3M, 5P). It has two aliases: "M" and "" (empty). That's on purpose: when parsing "C" as a chord, I want it to understand is major

rowild commented 4 years ago

Aha. So I should probably leave that one out. What about the chords with underscore ("_")? Are those valid chord symbols?

danigb commented 4 years ago

Well I'm quite influenced by spanish way to notate chord. We use underscore as an alias of minor 🤷‍♀ . For example C_7 it's the same as Cm7

To give more context: this is a dictionary of chords. The idea is to have many alternate notations to provide flexibility, but I think only first shorthand name (abreviature) should be shown to the user... Open to suggestions, as always

rowild commented 4 years ago

Interesting! Never heard of the Spanish way of notating chords like this. What is a "13#9_" then?

danigb commented 4 years ago

No, that is definitely a typo! 😂 Where is it?

rowild commented 4 years ago

There are several of those:

setNum 2454: 13#9 setNum 2442: 7#5#9 7#9b13 setNum 2738: 9#11 9#4_ setNum 2836: _69 (that might be correct according to your description, right?) setNum 2338: _7b5 (detto)

If you refer to the sandbox again, it now has a live filter search. That should make it easier to find them (and other kind of strings)

BTW: the filter is not yet working properly, it still shows too many chord options for one set number. If you know of a better solution - and you happen to have tooooooooooo much time ;-) - an improvement to the filter algorithm would be most welcome!

Muchas gracias!

danigb commented 4 years ago

Thanks for pointing me those typos 👍

Quick look to your code. I think it could be replaced by this:

if (this.filterString) {
  list = list.filter(item =>
    item.aliases.filter(alias => alias - includes(this.filterString))
  );
}

Hope it helps

rowild commented 4 years ago

Thanks for your feedback! Unfortunately your filter algorithm does not work. The "-" [minus] is not intended, right? That should be a dot... or did you have sth else in mind at this place? It's a pity... would so much like to get this filter to work properly...