You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix: keep track INDEX offsets when merging BINs - #202
Merge BINs writes every INDEX of a track 2 seconds (150 sectors) early when the track has a pregap in its own file, which is how Redump multi-bin dumps with audio tracks are laid out:
FILE "Game (Track 1).bin" BINARY # 1000 sectors
TRACK 01 MODE2/2352
INDEX 01 00:00:00
FILE "Game (Track 2).bin" BINARY # 300 sectors
TRACK 02 AUDIO
INDEX 00 00:00:00
INDEX 01 00:02:00
FILE "Game (Track 3).bin" BINARY
TRACK 03 AUDIO
INDEX 00 00:00:00
INDEX 01 00:02:00
openrom --merge-bins Game.cue gives track 2 INDEX 00 00:11:25 / INDEX 01 00:13:25 and track 3 00:15:25 / 00:17:25. Track 2's file starts at sector 1000 (00:13:25) in the merged BIN, so the right values are 00:13:25 / 00:15:25 and 00:17:25 / 00:19:25. With the current cue the data track ends 150 sectors early and every audio track starts 2 seconds before its music. The merged BIN itself is correct; only the cue is off.
INDEX times in a cue are relative to the start of their FILE, but mergeBins subtracted each track's INDEX 01 offset before adding the file's position in the merged BIN. This adds the INDEX time as it is.
Tested with a new case in bin_merger_test.dart (a track with INDEX 00 and a 2 second INDEX 01), which fails before the change, the full dart test in core/ (228 passed), and the three-track disc above through the CLI.
Summary by CodeRabbit
Bug Fixes
Corrected track positions in merged cue sheets when a later track has a pregap. The generated INDEX 00 and INDEX 01 timestamps now account for the preceding track’s length and the pregap, keeping offsets accurate across merged audio files. This improves the reliability of cue sheet timing for multi-track merges.
No actionable comments were generated in the recent review.
Walkthrough
mergeBins now adds each parsed index offset to accumulated sectors. A regression test checks the merged offsets for the second track, which has a two-second pregap.
Changes: Track index offset handling
Layer / File(s)
Summary
Merge index offsets and verify results core/lib/src/bin_merger.dart, core/test/bin_merger_test.dart
mergeBins adds each parsed index’s MSF sector offset to accumulated sectors. The regression test checks the merged INDEX 00 and INDEX 01 offsets for the second track.
This fixes merged cue-sheet INDEX positions for tracks that have a pregap inside their own file. The change is small and covered by a regression test, so merge risk is minimal.
Pre-merge checks: 4
Check name
Status
Explanation
Description Check
Check skipped - CodeRabbit’s high-level summary is enabled.
Title check
The title "fix: keep track INDEX offsets when merging BINs" names the main change. The change stops mergeBins from subtracting each track's INDEX 01 offset before computing merged positions, so track …
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Full details: Title check
Explanation
The title "fix: keep track INDEX offsets when merging BINs" names the main change. The change stops mergeBins from subtracting each track's INDEX 01 offset before computing merged positions, so track INDEX times are kept in the merged cue sheet. The title is specific, short, and matches the PR objective and the regression test for INDEX 00 and INDEX 01 offsets.
Finishing Touches
Generate unit tests (beta)
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
File: No configuration file from this repository applied
Commit: Unavailable
Layers: defaults
Review profile: CHILL
Plan: Advanced
Run ID: 32a356fa-5da9-4266-908d-358da133609d
Commits
Reviewing files that changed from the base of the PR and between e399f8b and 62d72d7.
Files selected for processing: 2
core/lib/src/bin_merger.dart
core/test/bin_merger_test.dart
Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 1 remain after this review.
This branch has not been deployed
No deployments
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
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Merge BINs writes every INDEX of a track 2 seconds (150 sectors) early when the track has a pregap in its own file, which is how Redump multi-bin dumps with audio tracks are laid out:
openrom --merge-bins Game.cuegives track 2INDEX 00 00:11:25/INDEX 01 00:13:25and track 300:15:25/00:17:25. Track 2's file starts at sector 1000 (00:13:25) in the merged BIN, so the right values are00:13:25/00:15:25and00:17:25/00:19:25. With the current cue the data track ends 150 sectors early and every audio track starts 2 seconds before its music. The merged BIN itself is correct; only the cue is off.INDEX times in a cue are relative to the start of their FILE, but
mergeBinssubtracted each track's INDEX 01 offset before adding the file's position in the merged BIN. This adds the INDEX time as it is.Tested with a new case in
bin_merger_test.dart(a track with INDEX 00 and a 2 second INDEX 01), which fails before the change, the fulldart testincore/(228 passed), and the three-track disc above through the CLI.Summary by CodeRabbit
INDEX 00andINDEX 01timestamps now account for the preceding track’s length and the pregap, keeping offsets accurate across merged audio files. This improves the reliability of cue sheet timing for multi-track merges.