bchunk
bchunk copied to clipboard
bchunk writes "ugh" files when there are spaces at the end of the lines into the CUE file
Hello, OK, I'm pretty sure nobody understood what I said...
I regularly use bchunk to split audio files, according to the related CUE files, with the "-w" parameter :
/usr/bin/bchunk -w -v fic.wav fic.cue fic_
Today, I found a (certainly) malformed CUE file, containing one additional space at the end of each line. In this case, bchunk writes binary files with the ".ugh" extension. If I remove these spaces, bchunk writes WAVE files correctly.
I don't know if this behaviour is intentional, but the problem, for me, is that "-w" should be sufficient to get WAVE files, but it isn't : bchunk ignores it if it detects something else into the CUE file.
This can be fixed with something like this, but it should be applied to all the strcasecmp
in that function
@@ -224,7 +224,7 @@ void gettrackmode(struct track_t *track, char *modes)
track->bsize = 2336;
track->extension = ext_iso;
- } else if (!strcasecmp(modes, "AUDIO")) {
+ } else if (!strncasecmp(modes, "AUDIO", 5)) {
track->bstart = 0;
track->bsize = 2352;
track->audio = 1;
It's indeed a clever way to use bchunk, but there should be no need to use -w when the entire inputfile is a WAV file, it should be easy to detect if it's a wav file and set towav = 1
automatically or something
there should be no need to use -w when the entire inputfile is a WAV file, it should be easy to detect if it's a wav file and set
towav = 1
automatically or something
Yes, I'm sure you're right. But... Here, I don't want bchunk to automatically detect something or not, I just want it to do what it is supposed to do. When I set "-w" ("The -w flag makes binchunker write audio tracks in WAV format."), I just expect WAV files. But it writes something else when there are spaces at the end of the lines.
I get what you mean, the question is does bchunk handle WAV files?
I don't think so, I hear noise (aplay, music players don't recognize it) after splitting a wav file with a cue. So it has to be raw audio file or something, not a RIFF WAV file. The concept is appealing though and I guess it can be implemented.
Anyway here is something that fixes this issue and other issues with trailing spaces in the TRACK line or command
diff --git a/bchunk.c b/bchunk.c
index 52f1aa9..9057aaf 100644
--- a/bchunk.c
+++ b/bchunk.c
@@ -456,7 +456,11 @@ int main(int argc, char **argv)
track->bsize = track->bstart = -1;
track->bsize = -1;
track->startsect = track->stopsect = -1;
-
+
+ // remove trailing spaces
+ for (t = p; *t ; ) t++;
+ for ( ; *t <= 0x20; t--) *t = '\0';
+
gettrackmode(track, p);
} else if ((p = strstr(s, "INDEX"))) {