Skip to content

Instantly share code, notes, and snippets.

@ryanfb
Created February 24, 2017 17:01
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 ryanfb/38099a674976295c4b4ee54d0b780606 to your computer and use it in GitHub Desktop.
Save ryanfb/38099a674976295c4b4ee54d0b780606 to your computer and use it in GitHub Desktop.
MIDI Synthesis / DeepBach notes
diff --git a/data_utils.py b/data_utils.py
index 4e3734e..d67e6f3 100644
--- a/data_utils.py
+++ b/data_utils.py
@@ -90,14 +90,20 @@ def part_to_list(part):
while i < length:
if j < num_notes - 1:
if list_notes[j + 1].offset > i / SUBDIVISION:
- t[i, :] = [list_notes[j].pitch.midi, is_articulated]
+ if hasattr(list_notes[j], 'pitch'):
+ t[i, :] = [list_notes[j].pitch.midi, is_articulated]
+ elif hasattr(list_notes[j], 'pitches'):
+ t[i, :] = [list_notes[j].pitches[0].midi, is_articulated]
i += 1
is_articulated = False
else:
j += 1
is_articulated = True
else:
- t[i, :] = [list_notes[j].pitch.midi, is_articulated]
+ if hasattr(list_notes[j], 'pitch'):
+ t[i, :] = [list_notes[j].pitch.midi, is_articulated]
+ elif hasattr(list_notes[j], 'pitches'):
+ t[i, :] = [list_notes[j].pitches[0].midi, is_articulated]
i += 1
is_articulated = False
return t
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment