Skip to content

BPM event refactor #579

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

Merged
merged 11 commits into from
Mar 30, 2025
Merged

Conversation

GalaxyMaster2
Copy link
Contributor

BPM event refactor:

  • songBpmTime is now nullable. If time conversion fails, it is set to null. Casting it to float when it's null will raise an exception. This is intentional; it means there is a serious bug and we should know about it.
  • SongBpmTime cannot be set anymore. This was only used in one place, and you should set JsonTime instead.
  • BPM time conversion logic is moved to from BPMChangeGridContainer to BaseDifficulty. BPM events must be bootstrapped after loading for this to function. All object songBpmTimes should be recomputed after doing this.
  • SetTimes in BaseObject has been simplified since songBpmTime was getting recalculated anyway.

This fixes wrong saving of BPM info files (BPMInfo.dat/AudioData.dat) when saving diffs from the song edit screen. It should also make it impossible for such a bug to go unnoticed in the future.
I haven't found any new bugs stemming from this refactor, but more testing is of course welcome.


mitigate accumulating numerical errors on BPM region load/save:

  • When saving BPM regions, properly round calculated sample indexes, and ensure continuity by setting start sample index to previous end sample index.
  • When converting BPM regions into events, round the BPM value of resulting events if the unrounding was (likely) caused by numerical error.

Together these should (mostly) eliminate accumulating errors on load/save cycles, which is important for v4 maps, since they do not store the actual BPM events.

* songBpmTime is now nullable. If time conversion fails, it is set to null. Casting it to float when it's null will raise an exception. This is intentional; it means there is a serious bug and we should know about it.
* SongBpmTime cannot be set anymore. This was only used in one place, and you should set JsonTime instead.
* BPM time conversion logic is moved to from BPMChangeGridContainer to BaseDifficulty. BPM events must be bootstrapped after loading for this to function. All object songBpmTimes should be recomputed after doing this.
* SetTimes in BaseObject has been simplified since songBpmTime was getting recalculated anyway.
* When saving BPM regions, properly round calculated sample indexes, and ensure continuity by setting start sample index to previous end sample index.
* When converting BPM regions into events, round the BPM value of resulting events if the unrounding was (likely) caused by numerical error.

Together these should (mostly) eliminate accumulating errors on load/save cycles, which is important for v4 maps, since they do not store the actual BPM events.
@GalaxyMaster2 GalaxyMaster2 marked this pull request as draft March 25, 2025 16:51
* FindLastBpmEvent should have been exclusive, not inclusive. This is because BPM events use this function to update their own songBpmTime, and if it's inclusive they will recalculate based on themselves.
* BPM events need to be refreshed before any other objects, since the result of their refresh is used in the refresh of others.
* ATSC time update on BPM tweak should occur after objects have been refreshed.
@GalaxyMaster2 GalaxyMaster2 marked this pull request as ready for review March 25, 2025 21:55
turns out inclusive search WAS useful for some things
Copy link
Owner

@Caeden117 Caeden117 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, although PR is big enough for me to want a second look from Bullet before merging

Copy link
Collaborator

@XAce1337manX XAce1337manX left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tests are failing.
Also cannot load into the editor on some maps. (e.g. key 44178)

@GalaxyMaster2
Copy link
Contributor Author

tests should be passing now

@XAce1337manX XAce1337manX merged commit 148cd1a into Caeden117:dev Mar 30, 2025
@GalaxyMaster2 GalaxyMaster2 deleted the bpm-event-refactor branch March 30, 2025 14:03
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

Successfully merging this pull request may close these issues.

3 participants