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")
| 105 | |
| 106 | |
| 107 | def 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 | |
| 143 | def relative_major(key): |
no test coverage detected