Scroll segments seem to cause the lag when there's a lot of segment
in the steps, say, 165. On my Mac, it drops the frame-rate down by about
30 FPS in the end.
This is because the way the the game tries to determine the exact position
of the note, it has to go through all the scroll segments from the
beginning until it finds the currently active scroll segment and keep
track of the beat to display instead.
And each frame, the game needs to determine the position for each note,
and also when figuring out the first beat and last beat to display. This
makes the game slow even with just 165 scroll segments.
The approach is that at every game update, we create an optimized data
structure that can calculate the displayed beat from real song beat
in O(log n) time. So in this approach we iterate through EVERY scroll
segments each frame instead of iterating through the scroll segments
for each note for each frame. This eliminates the lag on this side.
The data structure is recomputed each update because I assume that the
timing segments can change at any time, but not during draws.
A similar problem is: when using Cmods, GetElapsedTimeFromBeat()
is also called very often (say, for each note and also in FindFirst/Last
DisplayedBeat), we may as well have to make these queries faster for songs
that has hundreds of BPM changes or stops or delays to prevent the game
from lagging.
a bit more about autokeysounds: when I add this RageSoundReader_Extend,
I'm not sure whether the "autokeysounds are delayed" bug will come back
or not. Someone on Windows please test it.
quite a simple fix, but the song now no longer stops scrolling
when there are no more auto keysounds to play, which is what I've
been trying to fix for a long time.
It's now possible to play BMS which the BGM track is a bit too short
that in previous versions, the notes stop scrolling because there's
nothing more to play and it's impossible to finish the level.
It's also now possible to play BMS file which does not have any
autokeysounds at all, and also it's now possible to edit BMS files
(but the editor is very un-intuitive, but at least you can now add
timing changes to songs loaded from BMS files, such as speed segments
and scroll segments [they will be saved as .ssc file by the way]).
which returns the dispalyed position and timing (based on the timing display
switch in the editor), so less copy n paste in ArrowEffects and NoteField.
this prevents the crash caused by the asserion "No keysounds were loaded for the song %s!".
the song will load just fine in this case, but the notes will not scroll.
this only takes place when m_pSharedSound is NULL, which doesn't break when there's
background music but no autokeysounds.
on a related note,
the "notes don't scroll" problem also existed [before this commit] when there's no more
autokeysounds to play, in this case, the song stopped and the notes stopped scrolling.
and there's no way to get to the end of the song. can't figure out how to deal with this yet.
- handles BPM changes correctly
- songs should load faster
- auto-adjusts time signature changes (not sure how well will it perform.)
- add some code to differentiate between beat_single5 and popn_five, fixes bug 430
- also, bug 500 seems to be fixed after the rewrite, after some other attempts fail
what's not supported yet:
- #LNOBJ long note parsing
- #LNTYPE 2 long note parsing [http://nvyu.net/rdm/ex.php]