We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 121c84f commit 70aa65fCopy full SHA for 70aa65f
cedargrove_midi_tools.py
100644
100755
@@ -74,16 +74,10 @@ def name_to_note(name):
74
:param str name: The note name input in NoteOctave format. No default value.
75
"""
76
name = name.upper() # Convert lower to uppercase
77
- if (name[:1] or name[:2]) in NOTE_BASE:
+ if name[:-1] in NOTE_BASE:
78
# Note name is valid
79
- if "#" in name:
80
- # Extract octave value for 'sharped' note
81
- note = NOTE_BASE.index(name[:2])
82
- octave = int(name[2:])
83
- else:
84
- # Extract octave value
85
- note = NOTE_BASE.index(name[0])
86
- octave = int(name[1:])
+ note = NOTE_BASE.index(name[:-1])
+ octave = int(name[-1])
87
return note + (12 * (octave + 1)) # Calculated note value
88
return None # Input string is not in NOTE_BASE
89
0 commit comments