yuma-m / pychord

Python library to handle musical chords.
https://pypi.python.org/pypi/pychord
MIT License
239 stars 46 forks source link

getting four notes for a triad inversion #33

Open eyaler opened 5 years ago

eyaler commented 5 years ago

from pychord import Chord print(Chord('A/C#').components()) ['C#', 'A', 'C#', 'E'] #not sure why C# should appear twice?

yuma-m commented 4 years ago

Hello @eyaler

It is because, A/C# just means "C# root note" and "A major chord" in PyChrod.

A/C# -> C# + [A, C#, E] Am7/G -> G + [A, C, E, G]

You can remove duplicated note in components by using set:set(Chord('A/C#').components()), but do you need another method which returns notes without duplication?

>>> Chord('A/C#').non_duplicated_components()
["C#", "A", "E"]  # or ["C#", "E", "A"] ?
eyaler commented 4 years ago

thanks! i am not an expert on music theory but afaiu a/c# means inversion not doubling, when the new root is also part of the original chord. also in some other cases i do not see doubling in pychord

eyaler commented 4 years ago

by the way, the issue with set() is that it doesn't preserve order of course. this would be a separate issue, but one can think of different logic depending on if you care about voicing (order and octaves) or not.

when i do not care about voicing i use: sorted(set([n%12 for n in components]))

you could have: letters, numbers, letters unique+sorted, numbers mod%12+unique+sorted

and i would use more intuitive name than "visible". eg: notes, numbers, notes_ignore_voicing, numbers_ignore voiceing, respectively for the above