Created
June 2, 2026 06:43
-
-
Save queercat/e66c76c73d551c04103ac856b35170c9 to your computer and use it in GitHub Desktop.
ableton midi to time sequence
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
| import mido | |
| import typer | |
| def main(relative_path: str, target_bpm: int): | |
| midi = mido.MidiFile(relative_path) | |
| current_tick = 0 | |
| ratio = 60 / target_bpm | |
| for message in midi: | |
| current_tick += message.time * 96 * 2 | |
| if message.type == "note_on": | |
| print((current_tick / 96) * (ratio)) | |
| if __name__ == "__main__": | |
| typer.run(main) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment