Text, string chord recognition algorithms?

I am looking for algorithms that take notes represented by strings as input and call the name of the chord as output.

For instance:

chordName("C", "E", "G") >>> "C major" chordName("C", "E", "G", "B") >>> "C major 7" chordName("A", "C", "E") >>> "A minor" 
+6
source share
3 answers

The plot of my own horn (i.e. I'm the lead developer of the library, so biased, of course), but with music21 ( http://web.mit.edu/music21/ ) you can do:

 >>> from music21 import chord >>> chord.Chord(['C','E','G']).pitchedCommonName 'C-major triad' >>> chord.Chord(['C','E','G','B']).pitchedCommonName 'C-major seventh chord' 

or more obscure things ...

 >>> chord.Chord(['C','C#','D','E','F#']).pitchedCommonName 'D-tritone-expanding pentachord' 

full documents for Chord ( http://web.mit.edu/music21/doc/moduleReference/moduleChord.html ) will help you figure out how to get the text in exactly the format you want.

+2
source

Not a complete solution, but maybe something for you:

  • You should start by defining all possible tones in an array of type

    var scale = [['B #', 'C'], ['C #', 'Db'], ['E'], '[F]', ['F #', 'Gb'] .. Actually it is an array of small arrays with all possible names for the "same" note. I know that purists will insist that F # and Gb are fundamentally different, but on the piano keyboard they are behind the same key. An array of scales must be combined to span more than an octave.

  • Then the components of the chord array will be found in the scale array. Their relative positions in the scale array are a fingerprint that allows you to identify the chord.

  • Other massive chords must be set up to store “fingerprints like chords,” for example

    ctfp = {'main': [4,3,5], 'minor': [3,4,5], ...

+1
source

Take a look at the source code of the Mingus Python library chord module for an example chord recognition algorithm based on line input:

https://code.google.com/p/mingus/

https://code.google.com/p/mingus/source/browse/mingus/core/chords.py

The definition function () in the chord module, I quote: “Names a chord. It can detect almost every chord, from a simple triad to a fourteen-polychord.”

+1
source

Source: https://habr.com/ru/post/950656/


All Articles