From c5d9a8c637eeba95e8f308f99fa02a50c70a7147 Mon Sep 17 00:00:00 2001 From: Lars-Erik Aabech Date: Sat, 30 Nov 2019 11:26:49 +0100 Subject: [PATCH] Fixes index error for staffs and removes invalid last note (pitch undefined) --- main.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/main.py b/main.py index b1e0af5..cf3ff80 100644 --- a/main.py +++ b/main.py @@ -189,7 +189,7 @@ def open_file(path): note_group = [] i = 0; j = 0; while(i < len(staff_notes)): - if (staff_notes[i].rec.x > staffs[j].x and j < len(staffs)): + if (j < len(staffs) and staff_notes[i].rec.x > staffs[j].x): r = staffs[j] j += 1; if len(note_group) > 0: @@ -240,7 +240,7 @@ def open_file(path): midi.addNote(track,channel,pitch,time,duration,volume) time += duration - midi.addNote(track,channel,pitch,time,4,0) + # midi.addNote(track,channel,pitch,time,4,0) # And write it to disk. binfile = open("output.mid", 'wb') midi.writeFile(binfile)