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

bchunk writes "ugh" files when there are spaces at the end of the lines into the CUE file #8

Open
canoine opened this issue Apr 29, 2020 · 3 comments

Comments

@canoine
Copy link

canoine commented Apr 29, 2020

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.

@wdlkmpx
Copy link

wdlkmpx commented May 19, 2022

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

@canoine
Copy link
Author

canoine commented May 19, 2022

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.

@wdlkmpx
Copy link

wdlkmpx commented May 19, 2022

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"))) {

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

No branches or pull requests

2 participants