Created
April 8, 2020 21:20
-
-
Save codingsnap/aa9cf3c524c8e6bb72c7236bd0f9aea5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
notes = [] | |
for file in glob.glob("midi_songs/*.mid"): | |
midi = converter.parse(file) # Convert file into stream.Score Object | |
print("parsing %s"%file) | |
elements_to_parse = midi.flat.notes | |
for ele in elements_to_parse: | |
# If the element is a Note, then store it's pitch | |
if isinstance(ele, note.Note): | |
notes.append(str(ele.pitch)) | |
# If the element is a Chord, split each note of chord and join them with + | |
elif isinstance(ele, chord.Chord): | |
notes.append("+".join(str(n) for n in ele.normalOrder)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment