From 27ee792be506651627379a2844f89250086e0ccb Mon Sep 17 00:00:00 2001 From: Bluub Date: Wed, 15 Dec 2021 17:04:51 +0100 Subject: [PATCH] louis is kinda dumb --- main.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/main.py b/main.py index 0a203c8..66dcc65 100644 --- a/main.py +++ b/main.py @@ -98,6 +98,7 @@ async def main(): s = 3500 notes_on = {} + prev_note_on = {} for msg in MidiFile(sys.argv[1]): d = msg.dict() @@ -105,10 +106,13 @@ async def main(): s += d['time'] * 1000 if d["type"] == "note_on": print(s) - notes_on[d["note"]] = s + if d["note"] in notes_on: + prev_note_on[d["note"]] = notes_on[d["note"]] # 500 + notes_on[d["note"]] = s # 0 if d["type"] == "note_off": duration = s - notes_on[d["note"]] - notes.append(Note(s - duration / 2, {"duration": duration / 2, "color": (0, 0, 255), "key": midi_key_my_key(d["note"])})) + notes_on[d["note"]] = s # 500 + notes.append(Note(s - min(s - prev_note_on[d["note"]], 500), {"duration": min(s - prev_note_on[d["note"]], 500) / 2, "color": (0, 0, 255), "key": midi_key_my_key(d["note"])})) notes.append(Note(s, {"duration": duration, "color": default_color, "key": midi_key_my_key(d["note"])})) starting = []