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

Function reduce_accidentals

mingus/core/notes.py:99–117  ·  view source on GitHub ↗

Reduce any extra accidentals to proper notes. Example: >>> reduce_accidentals('C####') 'E'

(note)

Source from the content-addressed store, hash-verified

97
98
99def 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
120def remove_redundant_accidentals(note):

Callers 1

descendingMethod · 0.90

Calls 3

NoteFormatErrorClass · 0.90
note_to_intFunction · 0.85
int_to_noteFunction · 0.85

Tested by

no test coverage detected