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
Implement Ticks for: libsndfile, FmMidi, Wildmidi (kinda) #2118
Conversation
This kinda fixes "チンブラ戦隊ブライアン" but this uses Midi for timing in intro music so it needs perfect ticks (and is a perfect test candidate!). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Better than what we have now.
oh there is progress on the PR :). I will check the float vs int comment and then this is ready for now. |
…to get Division or tempo changes. Assume a default tempo and manually extract the Division from the header.
I reworked the midi ticks part of FmMidi. I added a function to query the divisions. Midi ticks calculation however is now from the outside. Is more accurate this way because before we had message resolution, now we have millisecond resolution. I want to do the following in a later PR, is too involved for this one: |
09cb0fe
to
2bfbdb8
Compare
…RT value but not perfect (slightly lower).
Better way: I remember the last tempo change position and use this to calculate the ticks when they are requested via GetTicks(). This avoids useless tick calculations and has much less error (result is around the same, ~3-5% error compared to RPG_RT) |
libsndfile and our bad wave decoder for slow platforms (FASTWAV) have no way to query the position. I added sample counting to get the position. This is hard to get right when "Seek" is used, so I kept this as a FIXME.
In FmMidi I added the current tick count to the midi message. The value matches the harmony value with some margin of error (is a bit higher/lower, harmony somehow keeps the value constant). No idea yet how to make it match better.
WildMidi: This is problematic. Will probably create a PR to there library someday to export the values through there API. They only offer the samplerate (How many samples were created based on the Midi file, so this is indirectly calculated through tempo + division).
When the Midi has no tempo changes just knowing the current tempo is enough to get a quite good value but for a perfect value we need all tempo informations (thats why the midi library has to calculate it).
There is no API to get the current tempo. Assume a fixed tempo (default tempo of WildMidi) and parse the division manually from the Midi header. This makes the error small enough to fix #2106 (the tick reaches the required value before the track ends), fix #1733 and fix #2241.
The Ticks are not implemented for Midis that state that there timing is FPS based. WildMidi rejects such files and because we are not aware of any bug reports this format is very unpopular I guess.
Test for MIDI. Autorun event. Outputs the delta since the last Midi Tick call