chorder
is a chord detection and reharmonize tool for .mid
files. You can download chorder
using pip:
pip install chorder
To check if chorder
is successfully installed, type python
in the terminal, and do the following:
>>> from chorder import Chord
>>> Chord()
Chord(root_pc=None, quality=None, bass_pc=None)
The Chord
class is the basic building block for the whole chorder package. A Chord
instance has four attributes, including:
root_pc
- the pitch class of a chord's root note
- is an integer ranging from 0 to 11
quality
, the quality of a chord (the complete list of quality)- the quality of a chord
- is a string
- the complete list of qualities covered in
chorder
can be found atChord.standard_qualities
bass_pc
- the pitch class of a chord's bass note
- is an integer ranging from 0 to 11
scale
- the scale of the chord
- is a list of strings representing the note names of each pitch class from 0 to 11
- if a scale is not specified, a default scale is used, which is in
Chord.default_scale
args
:None
orstr
ortuple
, optionalNone
: implies constructing an empty chordstr
: a chord symbol, such as'Bbmaj7'
tuple
: a tuple consisting of `(root_pc, quality, bass_pc)
scale
:list
, optional- specify the scale the chord uses
- will use
Chord.default_scale
if left asNone
Returns the root note name of a chord based on the chord's scale.
Returns the bass note name of a chord based on the chord's scale.
Returns if any attributes of a chord is None
. This can help filtering empty chords.
Transposes a chord to C-based relative chord. For example, Chord('Bb7').transpose(3)
should return Chord('G7')
.
key
:int
- the pitch class of the key
- ranges from 0 to 11
DeChorder
is a class that consists of static methods related to chord recognition. To utilize this class, the midi information has to be in the form of miditoolkit objects.
Returns the pitch class of bass note among the notes between the time range of start
and end
.
notes
: list- the group of notes
- notes are in the form of
miditoolkit.midi.containers.Note
start
: int- the start tick of the notes to be considered
- set it to
notes[0].start
for now, as this feature will later be updated
end
: int- the end tick of the notes to be considered
- set it to
notes[-1].end
for now, as this feature will later be updated
Returns the chord among the notes between the time range of start
and end
.
notes
: list- the group of notes
- notes are in the form of
miditoolkit.midi.containers.Note
start
: int- the start tick of the notes to be considered
- set it to
notes[0].start
for now, as this feature will later be updated
end
: int- the end tick of the notes to be considered
- set it to
notes[-1].end
for now, as this feature will later be updated
consider_bass
: `bool- decreases the likelihood of chords with non-chord tones as bass to be chosen as the answer
Returns a list of chords by beat.
midi_obj
:miditoolkit.midi.parser.MidiFile
- the midi object to extract chord symbols from
scale
:list
- the list of note names for each pitch class
- must be a list of strings