Skip to content

Chords

chord(chord_notation)

Generates the chord notes from Chord notation (Chord symbols or Portuguese "Cifra").

Parameters:

Name Type Description Default
chord_notation str

A chord in form of Chord notation (Chord symbols or Portuguese "Cifra")

required

Returns:

Type Description
dict[str, list[str]]

A dictionary with notes and degrees corresponds to the major scale.

Examples:

>>> chord('C')
{'notes': ['C', 'E', 'G'], 'degrees': ['I', 'III', 'V']}
>>> chord('Cm')
{'notes': ['C', 'D#', 'G'], 'degrees': ['I', 'III-', 'V']}
>>> chord('C°')
{'notes': ['C', 'D#', 'F#'], 'degrees': ['I', 'III-', 'V-']}
>>> chord('C+')
{'notes': ['C', 'E', 'G#'], 'degrees': ['I', 'III', 'V+']}
>>> chord('Cm+')
{'notes': ['C', 'D#', 'G#'], 'degrees': ['I', 'III-', 'V+']}
Source code in musical_notes/chords.py
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
def chord(chord_notation: str) -> dict[str, list[str]]:
    """
    Generates the chord notes from Chord notation (Chord symbols or Portuguese "Cifra").

    Args:
        chord_notation: A chord in form of Chord notation (Chord symbols or Portuguese "Cifra")

    Returns:
        A dictionary with notes and degrees corresponds to the major scale.

    Examples:
        >>> chord('C')
        {'notes': ['C', 'E', 'G'], 'degrees': ['I', 'III', 'V']}
        >>> chord('Cm')
        {'notes': ['C', 'D#', 'G'], 'degrees': ['I', 'III-', 'V']}
        >>> chord('C°')
        {'notes': ['C', 'D#', 'F#'], 'degrees': ['I', 'III-', 'V-']}
        >>> chord('C+')
        {'notes': ['C', 'E', 'G#'], 'degrees': ['I', 'III', 'V+']}
        >>> chord('Cm+')
        {'notes': ['C', 'D#', 'G#'], 'degrees': ['I', 'III-', 'V+']}
    """
    if 'm' in chord_notation:
        notes, degrees = _minor(chord_notation)
    elif '°' in chord_notation:
        # Split '°' of 'C°', that's, note = C.
        note, _ = chord_notation.split('°')
        tonic, third, fifth = triad(note, 'minor')
        notes = [tonic, third, half_step(fifth, interval=-1)]
        degrees = ['I', 'III-', 'V-']
    elif '+' in chord_notation:
        # Split '+' of 'C+', that's, note = C.
        note, _ = chord_notation.split('+')
        tonic, third, fifth = triad(note, 'major')
        notes = [tonic, third, half_step(fifth, interval=+1)]
        degrees = ['I', 'III', 'V+']
    else:
        notes = triad(chord_notation, 'major')
        degrees = ['I', 'III', 'V']

    return {'notes': notes, 'degrees': degrees}