Skip to content
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

Handle multiple binfiles, overhaul parameter handling, split WAV files #15

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

twojstaryzdomu
Copy link

@twojstaryzdomu twojstaryzdomu commented Jun 20, 2022

This PR enables the following:

  1. Handle image based on cuesheet FILE definitions. The first parameter is used to select the track or file to convert. Specifying a track will convert a specific track whilst specifying a file will convert all tracks for a given file. Filename has to match its cuesheet definition. Wildcard * (in single quotes) selects all tracks from all files listed.
  2. Split input WAV files. It's now possible to split a single WAV file into individual WAV tracks or raw cdr files, convenient for processing CD Audio rips stored as a single WAV and a cue sheet.
  3. Basefile parameter is now optional. If omitted, the output files are named after the file or track being processed, prepended with the format extension.
  4. Replace ## as track token in basename. I doubt this combination is used anywhere in filenames.
  5. Error out if the output file already exists. Previously an existing output file would get overwritten. It also covers the case when two files of the same name would get output (when -t or the variant basename isn't specified .
  6. No track # included in the output filename unless -t is specified.
  7. Repeating error statements were refactored into functions.
  8. Sealed memory leaks.
  9. Version raised to 1.2.3, credits, manpage, README & Changelog updated.

@h3xx
Copy link
Contributor

h3xx commented Jun 25, 2022

Nice! It handles cue+wav only extraction.

I'm seeing an error in this patch, though.

bchunk -w foo.wav foo.cue

Reading the CUE file:

File: foo.wav
Track  1: AUDIO         01 00:00:00
free(): double free detected in tcache 2
Aborted

@h3xx
Copy link
Contributor

h3xx commented Jun 25, 2022

It also destroyed my wav file. Needs work.

@twojstaryzdomu
Copy link
Author

twojstaryzdomu commented Jun 25, 2022

Please post the cuesheet. A bin file should be intact. Dumping from wav to wav makes no sense to me. What is your exact use use case

@h3xx
Copy link
Contributor

h3xx commented Jun 25, 2022

This file was using Unix line ending style (0x0a or \n), just so you know.

REM GENRE Rock
REM DATE 2007
PERFORMER "Some Guy"
TITLE "Some Album"
FILE "Some Guy - Some Album.wav" WAVE
  TRACK 01 AUDIO
    TITLE "Foo"
    PERFORMER "Some Guy"
    INDEX 01 00:00:00
  TRACK 02 AUDIO
    TITLE "Bar"
    PERFORMER "Some Guy"
    INDEX 00 03:35:01
    INDEX 01 03:36:59
  TRACK 03 AUDIO
    TITLE "Blarg"
    PERFORMER "Some Guy"
    INDEX 01 06:18:60
  TRACK 04 AUDIO
    TITLE "Song"
    PERFORMER "Some Guy"
    INDEX 01 09:55:27
  TRACK 05 AUDIO
    TITLE "Another Song"
    PERFORMER "Some Guy"
    INDEX 01 13:29:19
  TRACK 06 AUDIO
    TITLE "Yet another song"
    PERFORMER "Some Guy"
    INDEX 01 16:34:29
  TRACK 07 AUDIO
    TITLE "Yet another song"
    PERFORMER "Some Guy"
    INDEX 00 19:29:48
    INDEX 01 19:30:28
  TRACK 08 AUDIO
    TITLE "Yet another song"
    PERFORMER "Some Guy"
    INDEX 01 22:32:01
  TRACK 09 AUDIO
    TITLE "Yet another song"
    PERFORMER "Some Guy"
    INDEX 00 26:31:54
    INDEX 01 26:33:37
  TRACK 10 AUDIO
    TITLE "Yet another song"
    PERFORMER "Some Guy"
    INDEX 00 30:10:56
    INDEX 01 30:12:39
  TRACK 11 AUDIO
    TITLE "Yet another song"
    PERFORMER "Some Guy"
    INDEX 00 33:05:60
    INDEX 01 33:07:53
  TRACK 12 AUDIO
    TITLE "Yet another song"
    PERFORMER "Some Guy"
    INDEX 00 37:13:52
    INDEX 01 37:14:74

@h3xx
Copy link
Contributor

h3xx commented Jun 25, 2022

file(1) reports this as the WAV file contents:

Some Guy - Some Album.wav: RIFF (little-endian) data, WAVE audio, Microsoft PCM, 16 bit, stereo 44100 Hz

Here's the output from ls -la:

-rw-r--r-- 1 h3xx users 433,539,500 Jun 25 00:26 Some\ Guy\ -\ Some\ Album.wav

@h3xx
Copy link
Contributor

h3xx commented Jun 25, 2022

Dumping from wav to wav makes no sense to me. What is your exact use use case

Dumping from .wav to .wav is for splitting wavs on the INDEX values in the cue sheet. Some of the music on archive.org exists in an hour-long .wav + a .cue file with chapters for the tracks.

bchunk already handles splitting .wav files from .bin files if an AUDIO type track is specified in the cue sheet. See the -w flag.

If your patch isn't meant to add support for this, then maybe I'm out of luck. I've wanted to use this tool for splitting .wavs for a long time.

@twojstaryzdomu
Copy link
Author

twojstaryzdomu commented Jun 26, 2022

Dumping from .wav to .wav is for splitting wavs on the INDEX values in the cue sheet. Some of the music on archive.org exists in an hour-long .wav + a .cue file with chapters for the tracks.

bchunk seems to handle simple tracks without pregaps. The problem is the tool hasn't been meant for anything else than simple cuesheets. Your example and most audio CDs tend to have pregap. Any result of a split may seem ok at first but not on closer look. If you get it to run, with any track that is followed by pregap, tracks will be overlapping at the end.

I have some code to make it work and will submit a PR later at some point when the code has been tested. It's very easy to wreck your rips by splitting in the wrong place. However, I won't be adding it under this PR.

@twojstaryzdomu
Copy link
Author

twojstaryzdomu commented Jun 29, 2022

@h3xx, I've added support for WAV splitting in my devel branch. Regular PCM WAV files ripped from CDs ought to work (44,1k). Any other type will not. It should handle pregap and ignore subtracks as well. Verify your split files with CUETools. The accurip output (Verify option in CUETools) has to be identical for the original cue/WAV source and the split single WAV's (files named in the same order as cue tracks).

Since WAV splitting seems to be working, including a few edge cases (pregaps, subtracks), I'm including the WAV splitting enhancement in this PR.

@twojstaryzdomu twojstaryzdomu changed the title Handle multiple binfiles, overhaul parameter handling, refactor error statements Handle multiple binfiles, overhaul parameter handling, split WAV files Jun 30, 2022
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.

2 participants