Last active
November 12, 2022 17:56
-
-
Save kistaaa/0c901048a363800a65b95a9bbfd0e4f0 to your computer and use it in GitHub Desktop.
Convert midi events to a list for importing in Blender
This file contains hidden or 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
from mido import MidiFile | |
tempo=0 | |
noteons = [] | |
notas = [] | |
mid = MidiFile('C:/scripts-python/meow.mid') | |
for evt in mid: | |
if not evt.is_meta: | |
tempo += evt.time | |
if evt.type == 'note_on': | |
noteons.append(evt) | |
elif evt.type == 'note_off': | |
for nota in noteons: | |
if nota.note == evt.note: | |
com = tempo - evt.time | |
fim = tempo | |
dur = fim - com | |
notas.append([evt.note, com, fim, dur]) | |
noteons.remove(nota) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment