Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to know time of every notes? #1

Open
cgoxopx opened this issue Aug 14, 2018 · 1 comment
Open

How to know time of every notes? #1

cgoxopx opened this issue Aug 14, 2018 · 1 comment

Comments

@cgoxopx
Copy link

cgoxopx commented Aug 14, 2018

No description provided.

@ell1e
Copy link
Contributor

ell1e commented Oct 13, 2021

I have looked into this now, it's kind of a two step thing and I think this is how to do it:

Musical offset of a note: Check out how many midi clock ticks a quarter note has via parser->header.time_division, and each midi event has the vtime which specifies the offset to the last in midi clock ticks. With this, you can calculate each note's exact offset easily in relation to musical quarter notes as e.g. a fractional double number.

Find out how long a quarter note length is in seconds: You have to track tempo change events yourself and compute how long each quarter note is yourself from that at any point in the song, and multiply that with your musical offset. (I know this sounds strongly simplified, and can be a bit involved with multiple tempo changes, but I think it's the simplest approach.)

Maybe there is a way to add all of this into the parser itself some day, due to how simple it is it basically just returns all the above pieces as-is from the midi file and leaves the rest to you. Midi is just very musically oriented, so it usually doesn't have direct seconds timing offsets but its all via the abstract midi clock/quarter notes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants