Chords
chord(tonic_note)
Generate the notes and degrees for a chord based on a tonic note.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tonic_note |
str
|
The tonic note representing the root note of the chord. It should specify the chord type:
|
required |
Returns:
| Type | Description |
|---|---|
dict[str, list[str]]
|
A dictionary containing the notes and their corresponding degrees. |
Examples:
>>> chord("C")
{'notes': ['C', 'E', 'G'], 'degrees': ['I', 'III', 'V']}
>>> chord("Cm")
{'notes': ['C', 'D#', 'G'], 'degrees': ['I', 'III-', 'V']}
>>> chord("Cdim")
{'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 melodica_notes/chords.py
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 | |
minor(tonic_note)
Generates the minor triad based on the given tonic note.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tonic_note |
str
|
The tonic note representing the root of the minor triad. |
required |
Returns:
| Type | Description |
|---|---|
tuple[list[str], list[str]]
|
tuple[list[str], list[str]]: A tuple containing the notes and degrees of the minor triad. |
Examples:
>>> minor("Cm")
(['C', 'D#', 'G'], ['I', 'III-', 'V'])
>>> minor("Cm+")
(['C', 'D#', 'G#'], ['I', 'III-', 'V+'])
Source code in melodica_notes/chords.py
4 5 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 | |
semitone(tonic_note, *, interval)
Returns the note that is a semitone away from the given tonic note.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tonic_note |
str
|
The starting note or key. |
required |
interval |
int
|
The number of semitones to move from the tonic note. Positive values move upward, and negative values move downward. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
The note that is a semitone away from the tonic note. |
Examples:
>>> semitone('C', interval=1)
'C#'
>>> semitone('A', interval=-1)
'G#'
Source code in melodica_notes/chords.py
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 | |
triad(tonic_note, scale_type)
Generate the triad based on a given tonic note and scale mode.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tonic_note |
str
|
The tonic note or the root note of the scale for which you want to determine the triad type. |
required |
scale_type |
str
|
The type of the scale. Currently supports only "major". |
required |
Returns:
| Type | Description |
|---|---|
list[str]
|
list[str]: A list containing the notes of the triad. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the tonic note is invalid. |
KeyError
|
If the scale mode does not exist or has not been implemented. |
Examples:
>>> triad("C", "major")
['C', 'E', 'G']
>>> triad("A", "minor")
['A', 'C', 'E']
Source code in melodica_notes/chords.py
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 | |