Skip to content

Instantly share code, notes, and snippets.

@codingsnap
Created April 8, 2020 22:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save codingsnap/24be849f1201d9e623b5b0c2dbbc735e to your computer and use it in GitHub Desktop.
Save codingsnap/24be849f1201d9e623b5b0c2dbbc735e to your computer and use it in GitHub Desktop.
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