Created
April 8, 2020 22:41
-
-
Save codingsnap/24be849f1201d9e623b5b0c2dbbc735e 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
offset = 0 # Time | |
output_notes = [] | |
for pattern in prediction_output: | |
# if the pattern is a chord | |
if ('+' in pattern) or pattern.isdigit(): | |
notes_in_chord = pattern.split('+') | |
temp_notes = [] | |
for current_note in notes_in_chord: | |
new_note = note.Note(int(current_note)) # create Note object for each note in the chord | |
new_note.storedInstrument = instrument.Piano() | |
temp_notes.append(new_note) | |
new_chord = chord.Chord(temp_notes) # creates the chord() from the list of notes | |
new_chord.offset = offset | |
output_notes.append(new_chord) | |
else: | |
# if the pattern is a note | |
new_note = note.Note(pattern) | |
new_note.offset = offset | |
new_note.storedInstrument = instrument.Piano() | |
output_notes.append(new_note) | |
offset += 0.5 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment