Skip to content

Added support for CUE files that reference multiple BINs#20

Open
jakemkz wants to merge 6 commits intohessu:masterfrom
jakemkz:master
Open

Added support for CUE files that reference multiple BINs#20
jakemkz wants to merge 6 commits intohessu:masterfrom
jakemkz:master

Conversation

@jakemkz
Copy link

@jakemkz jakemkz commented Feb 15, 2026

This pull request adds the following features to bchunk which may be useful to individuals seeking to archive CDs and handle a few corner cases in CD preservation. I have attempted to maintain backwards compatibility with existing bchunk usage while extending its capabilities

1. Added support for handling CUE sheets with multiple BIN files

This was added with the use of a new flag "-m" for merge. In this mode the file passed in the <image.cue> argument is used to identify files based on FILE line descriptors in the CUE file. The referenced .BIN files should be in the same directory as <image.cue>. The meaning of <image.bin> in this mode is changed from being an input file to being an output file that is the combination of all .BIN files. A .CUE file with the same basename as <image.bin> is also created with adjusted INDEX times to match the merged .BIN.

If merge mode is used with only two arguments bchunk will only create the merged bin/cue files and take no further actions but it can also be used with other flags such as -w to create the merged bin and produce the normal output wav/iso files.

2. Adjustment of INDEX handling logic and support for pre-gap audio

The handling logic for identifying the separation point between tracks was adjusted to ensure that this occurs at INDEX 01 even for CUE files that may have multiple INDEX entries, this is intended to match the behavior of a CD player where data in INDEX 00 would be played as part of the previous TRACK.

Special handling was added for INDEX 00 on TRACK 01 that creates a separate "track 0" for pre-gap audio if it exists.

3. Minor datatype and makefile adjustments

A few of the data types were changed from variable length to fixed length types. These changes aren't necessary but reduce some of the compiler warnings using the most pedantic settings.

Added the 'make debug' option to the makefile which uses the -g flag for debugging with gdb along with very pedantic warnings from the compiler

Other notes:

  • These changes are intended to work well with split bin/cue files produced by redumper which may be useful for folks trying to archive compact discs.
  • You should really only use merge mode on CUE files that you trust or have read since it uses the FILE references to open files on your computer and write the output to other files
  • I'm not a software engineer, just a person trying to make the tools I use a bit better, so there may be mistakes in my code but I have tested it on some of my available media and it has worked well. I have also done binary comparisons of files produced from the merged bin/cue files (using the legacy codepath) and the merge option which resulted in identical files in several test cases.
  • Also forgive me if I have made any faux pas in this pull request, its my first one.

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.

1 participant