Added append, prepend, and split pregap modes to cuebreakpoints.
This commit is contained in:
@@ -19,8 +19,22 @@ print usage information
|
|||||||
.B \-i, \--input-format cue|toc
|
.B \-i, \--input-format cue|toc
|
||||||
set format of file(s)
|
set format of file(s)
|
||||||
.
|
.
|
||||||
|
.TP
|
||||||
|
.B \--append-gaps
|
||||||
|
append pregaps to previous track (default)
|
||||||
|
.
|
||||||
|
.TP
|
||||||
|
.B \--prepend-gaps
|
||||||
|
prefix pregaps to track
|
||||||
|
.
|
||||||
|
.TP
|
||||||
|
.B \--split-gaps
|
||||||
|
split at beginning and end of pregaps
|
||||||
|
.
|
||||||
.SH NOTES
|
.SH NOTES
|
||||||
The breakpoints are in a format usable by shnsplit (part of the shntool package). A track breakpoint is at index 1.
|
The breakpoints are in a format usable by shnsplit (part of the shntool package).
|
||||||
|
.PP
|
||||||
|
The first track's pregap cannot be appended to the previous track, so it is prefixed to the track in both append and prepend modes. If you want the track without it, use the split mode.
|
||||||
.PP
|
.PP
|
||||||
If no files are specified, stdin is used. If a filename is specified and the format is not specified, the format will be set based on a ".cue" or ".toc" suffix.
|
If no files are specified, stdin is used. If a filename is specified and the format is not specified, the format will be set based on a ".cue" or ".toc" suffix.
|
||||||
.
|
.
|
||||||
|
|||||||
@@ -14,6 +14,8 @@
|
|||||||
|
|
||||||
char *progname;
|
char *progname;
|
||||||
|
|
||||||
|
enum {APPEND, PREPEND, SPLIT};
|
||||||
|
|
||||||
void usage (int status)
|
void usage (int status)
|
||||||
{
|
{
|
||||||
if (0 == status) {
|
if (0 == status) {
|
||||||
@@ -23,6 +25,9 @@ void usage (int status)
|
|||||||
OPTIONS\n\
|
OPTIONS\n\
|
||||||
-h, --help print usage\n\
|
-h, --help print usage\n\
|
||||||
-i, --input-format cue|toc set format of file(s)\n\
|
-i, --input-format cue|toc set format of file(s)\n\
|
||||||
|
--append-gaps append pregaps to previous track (default)\n\
|
||||||
|
--prepend-gaps prefix pregaps to track\n\
|
||||||
|
--split-gaps split at beginning and end of pregaps\n\
|
||||||
", stdout);
|
", stdout);
|
||||||
} else {
|
} else {
|
||||||
fprintf(stderr, "run `%s --help' for usage\n", progname);
|
fprintf(stderr, "run `%s --help' for usage\n", progname);
|
||||||
@@ -39,27 +44,45 @@ void print_m_ss_ff (long frame)
|
|||||||
printf ("%d:%02d.%02d\n", m, s, f);
|
printf ("%d:%02d.%02d\n", m, s, f);
|
||||||
}
|
}
|
||||||
|
|
||||||
void print_breaks (Cd *cd)
|
void print_breakpoint (long b)
|
||||||
|
{
|
||||||
|
/* do not print zero breakpoints */
|
||||||
|
if (0 != b)
|
||||||
|
print_m_ss_ff(b);
|
||||||
|
}
|
||||||
|
|
||||||
|
void print_breaks (Cd *cd, int gaps)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
long b;
|
long b;
|
||||||
Track *track;
|
Track *track;
|
||||||
|
|
||||||
/* start on track 2 */
|
for (i = 1; i <= cd_get_ntrack(cd); i++) {
|
||||||
for (i = 2; i <= cd_get_ntrack(cd); i++) {
|
|
||||||
track = cd_get_track(cd, i);
|
track = cd_get_track(cd, i);
|
||||||
/* breakpoint is at index 1 */
|
/* when breakpoint is at:
|
||||||
/* TODO: make option for breakpoint at index 0,
|
* index 0: gap is prepended to track
|
||||||
* and option for breakpoints a index 0 and 1
|
* index 1: gap is appended to previous track
|
||||||
*/
|
*/
|
||||||
b = track_get_start(track) + track_get_index(track, 1) - track_get_zero_pre(track);
|
b = track_get_start(track);
|
||||||
/* don't print zero indexes */
|
|
||||||
if (0 != b)
|
if (gaps == PREPEND || gaps == SPLIT) {
|
||||||
print_m_ss_ff(b);
|
print_breakpoint(b);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (gaps == APPEND || gaps == SPLIT) {
|
||||||
|
/* there is no previous track to append the first tracks pregap to */
|
||||||
|
/* TODO: should first track's pregap be split when appending?
|
||||||
|
* this could be a suprising default
|
||||||
|
*/
|
||||||
|
if (1 < i) {
|
||||||
|
b += track_get_index(track, 1) - track_get_zero_pre(track);
|
||||||
|
print_breakpoint(b);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int breaks (char *name, int format)
|
int breaks (char *name, int format, int gaps)
|
||||||
{
|
{
|
||||||
Cd *cd = NULL;
|
Cd *cd = NULL;
|
||||||
|
|
||||||
@@ -68,7 +91,7 @@ int breaks (char *name, int format)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
print_breaks(cd);
|
print_breaks(cd, gaps);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -76,6 +99,7 @@ int breaks (char *name, int format)
|
|||||||
int main (int argc, char **argv)
|
int main (int argc, char **argv)
|
||||||
{
|
{
|
||||||
int format = UNKNOWN;
|
int format = UNKNOWN;
|
||||||
|
int gaps = APPEND;
|
||||||
|
|
||||||
/* option variables */
|
/* option variables */
|
||||||
char c;
|
char c;
|
||||||
@@ -86,6 +110,9 @@ int main (int argc, char **argv)
|
|||||||
static struct option longopts[] = {
|
static struct option longopts[] = {
|
||||||
{"help", no_argument, NULL, 'h'},
|
{"help", no_argument, NULL, 'h'},
|
||||||
{"input-format", required_argument, NULL, 'i'},
|
{"input-format", required_argument, NULL, 'i'},
|
||||||
|
{"append-gaps", no_argument, NULL, 'a'},
|
||||||
|
{"prepend-gaps", no_argument, NULL, 'p'},
|
||||||
|
{"split-gaps", no_argument, NULL, 's'},
|
||||||
{NULL, 0, NULL, 0}
|
{NULL, 0, NULL, 0}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -105,6 +132,15 @@ int main (int argc, char **argv)
|
|||||||
fprintf(stderr, "%s: illegal format `%s'\n", progname, optarg);
|
fprintf(stderr, "%s: illegal format `%s'\n", progname, optarg);
|
||||||
usage(1);
|
usage(1);
|
||||||
break;
|
break;
|
||||||
|
case 'a':
|
||||||
|
gaps = APPEND;
|
||||||
|
break;
|
||||||
|
case 'p':
|
||||||
|
gaps = PREPEND;
|
||||||
|
break;
|
||||||
|
case 's':
|
||||||
|
gaps = SPLIT;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
usage(1);
|
usage(1);
|
||||||
break;
|
break;
|
||||||
@@ -112,10 +148,10 @@ int main (int argc, char **argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (optind == argc) {
|
if (optind == argc) {
|
||||||
breaks("-", format);
|
breaks("-", format, gaps);
|
||||||
} else {
|
} else {
|
||||||
for (; optind < argc; optind++)
|
for (; optind < argc; optind++)
|
||||||
breaks(argv[optind], format);
|
breaks(argv[optind], format, gaps);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user