2

Could you please suggest a Python library which detects chords out of notes like this:

>>> chord ('A C# E G')
It's A7 chord ^_^

What I've already tried:

Detects only more or less basic chords

It does exactly what I need, but is quite tricky to work with because of deprecated requirements and no documentation.

The amazingly powerful library made at MIT. Looks very promising, but displays chord names like this:

>>> chord.Chord('D F# C E').pitchedCommonName
'D-whole-tone tetramirror'

while I'm looking for the following output:

D9

So the library I'm looking for:

  • is able to recognize advanced chords
  • outputs common abbreviated chord names
  • is well-documented

Ideally:

  • has a pip installation
  • has easy-to-install requirements
  • has clean and minimalistic syntax

Thank you very much in advance!

  • 1
    If it is Python, it’ll work on a Mac. – Eric S Oct 6 '19 at 14:32
  • 1
    Thanks! Edited. – ZenBerry Oct 6 '19 at 16:31
0

Mingus can kind of do what you're asking for:

>>> from mingus.core import chords
>>> chords.determine('A C# E G'.split(),  shorthand=True)
['A7', 'C#dim|AM']
>>> chords.determine('D F# A C E'.split(),  shorthand=True)
['D9', 'Am|DM', 'Am|D7', 'F#m7b5|DM', 'F#m7b5|D7']

For more examples see the documentation.

Note that to get your second example correct I had to include the fifth which is the A note. Without it, it's not a proper D9 chord. To handle such situations, you could create some kind of lookup table so that if mingus doesn't return any result for your notes you pick the closest matching one.

| improve this answer | |
  • Thanks a lot! For some reason, it throws the following error: >>> from mingus.core import chords File "/Users/zenberry/anaconda3/lib/python3.7/site-packages/mingus/core/chords.py", line 769 raise NoteFormatError, "Unrecognised note '%s' in chord '%s'"\ Might you probably know how to deal with this? Many thanks! – ZenBerry Apr 15 at 14:38
  • 1
    I think you have accidentally installed the python2 version of the package. If you clear it out and install the python3 version it should work. – Björn Lindqvist Apr 15 at 17:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.