Reduce any extra accidentals to proper notes. Example: >>> reduce_accidentals('C####') 'E'
(note)
| 97 | |
| 98 | |
| 99 | def reduce_accidentals(note): |
| 100 | """Reduce any extra accidentals to proper notes. |
| 101 | |
| 102 | Example: |
| 103 | >>> reduce_accidentals('C####') |
| 104 | 'E' |
| 105 | """ |
| 106 | val = note_to_int(note[0]) |
| 107 | for token in note[1:]: |
| 108 | if token == "b": |
| 109 | val -= 1 |
| 110 | elif token == "#": |
| 111 | val += 1 |
| 112 | else: |
| 113 | raise NoteFormatError("Unknown note format '%s'" % note) |
| 114 | if val >= note_to_int(note[0]): |
| 115 | return int_to_note(val % 12) |
| 116 | else: |
| 117 | return int_to_note(val % 12, "b") |
| 118 | |
| 119 | |
| 120 | def remove_redundant_accidentals(note): |
no test coverage detected