MCPcopy Create free account
hub / github.com/bspaans/python-mingus / get_notes

Function get_notes

mingus/core/keys.py:107–140  ·  view source on GitHub ↗

Return an ordered list of the notes in this natural key. Examples: >>> get_notes('F') ['F', 'G', 'A', 'Bb', 'C', 'D', 'E'] >>> get_notes('c') ['C', 'D', 'Eb', 'F', 'G', 'Ab', 'Bb']

(key="C")

Source from the content-addressed store, hash-verified

105
106
107def get_notes(key="C"):
108 """Return an ordered list of the notes in this natural key.
109
110 Examples:
111 >>> get_notes('F')
112 ['F', 'G', 'A', 'Bb', 'C', 'D', 'E']
113 >>> get_notes('c')
114 ['C', 'D', 'Eb', 'F', 'G', 'Ab', 'Bb']
115 """
116 if key in _key_cache:
117 return _key_cache[key]
118 if not is_valid_key(key):
119 raise NoteFormatError("unrecognized format for key '%s'" % key)
120 result = []
121
122 # Calculate notes
123 altered_notes = [x[0] for x in get_key_signature_accidentals(key)]
124
125 if get_key_signature(key) < 0:
126 symbol = "b"
127 elif get_key_signature(key) > 0:
128 symbol = "#"
129
130 raw_tonic_index = base_scale.index(key.upper()[0])
131
132 for note in islice(cycle(base_scale), raw_tonic_index, raw_tonic_index + 7):
133 if note in altered_notes:
134 result.append("%s%s" % (note, symbol))
135 else:
136 result.append(note)
137
138 # Save result to cache
139 _key_cache[key] = result
140 return result
141
142
143def relative_major(key):

Callers 6

determineFunction · 0.90
ascendingMethod · 0.90
ascendingMethod · 0.90
__init__Method · 0.90
ascendingMethod · 0.90
descendingMethod · 0.90

Calls 4

NoteFormatErrorClass · 0.90
is_valid_keyFunction · 0.85
get_key_signatureFunction · 0.85

Tested by

no test coverage detected