diff --git a/test/test.c b/test/test.c index 7d97bf82..a71c1430 100644 --- a/test/test.c +++ b/test/test.c @@ -28,6 +28,7 @@ void usage(const char * name) { " -m: print metadata only, don't decode\n" " -x: decode and print adxencd command line to encode as ADX\n" " -g: decode and print oggenc command line to encode as OGG\n" + " -b: decode and print batch variable commands\n" " -e: force end-to-end looping\n" " -E: force end-to-end looping even if file has real loop points\n" " -r outfile2.wav: output a second time after resetting\n" @@ -54,11 +55,12 @@ int main(int argc, char ** argv) { int metaonly = 0; int adxencd = 0; int oggenc = 0; + int batchvar = 0; double loop_count = 2.0; double fade_seconds = 10.0; double fade_delay_seconds = 0.0; - while ((opt = getopt(argc, argv, "o:l:f:d:ipPcmxeEr:g")) != -1) { + while ((opt = getopt(argc, argv, "o:l:f:d:ipPcmxeEr:gb")) != -1) { switch (opt) { case 'o': outfilename = optarg; @@ -94,6 +96,9 @@ int main(int argc, char ** argv) { case 'g': oggenc = 1; break; + case 'b': + batchvar = 1; + break; case 'e': force_loop = 1; break; @@ -204,11 +209,16 @@ int main(int argc, char ** argv) { if (s->loop_flag) printf(" -c LOOPSTART=%d -c LOOPLENGTH=%d",s->loop_start_sample, s->loop_end_sample-s->loop_start_sample); printf("\n"); + } else if (batchvar) { + if (!metaonly) printf("set fname=\"%s\"\n",outfilename); + printf("set tsamp=%d\nset chan=%d\n", s->num_samples, s->channels); + if (s->loop_flag) printf("set lstart=%d\nset lend=%d\nset loop=1\n", s->loop_start_sample, s->loop_end_sample); + else printf("set loop=0\n"); } else if (metaonly) printf("metadata for %s\n",argv[optind]); else printf("decoding %s\n",argv[optind]); } - if (!play && !adxencd && !oggenc) { + if (!play && !adxencd && !oggenc && !batchvar) { char description[1024]; description[0]='\0'; describe_vgmstream(s,description,1024); @@ -222,7 +232,7 @@ int main(int argc, char ** argv) { buf = malloc(BUFSIZE*sizeof(sample)*s->channels); len = get_vgmstream_play_samples(loop_count,fade_seconds,fade_delay_seconds,s); - if (!play && !adxencd && !oggenc) printf("samples to play: %d (%.2lf seconds)\n",len,(double)len/s->sample_rate); + if (!play && !adxencd && !oggenc && !batchvar) printf("samples to play: %d (%.2lf seconds)\n",len,(double)len/s->sample_rate); fade_samples = fade_seconds * s->sample_rate; /* slap on a .wav header */