mirror of
https://github.com/vgmstream/vgmstream.git
synced 2025-01-18 07:44:43 +01:00
new test feature, clarify usage, add usage to readme
git-svn-id: https://vgmstream.svn.sourceforge.net/svnroot/vgmstream@30 51a99a44-fe44-0410-b1ba-c3e57ba2b86b
This commit is contained in:
parent
f9fd15ee7d
commit
ba26771fdc
18
readme.txt
18
readme.txt
@ -3,8 +3,22 @@ vgmstream
|
||||
This is vgmstream, a library for playing streamed audio from video games.
|
||||
It is very much under development. The only end-user part right now is the test program, simply called "test" (test.exe for Windows), which decodes a file to a standard .wav output file.
|
||||
|
||||
Formats supported by this version of vgmstream (r29):
|
||||
- ADX (CRI ADX ADPCM)
|
||||
Usage: test [-o outfile.wav] [-l loop count]
|
||||
[-f fade time] [-i] [-p] [-c] [-m] infile
|
||||
Options:
|
||||
-o outfile.wav: name of output .wav file, default is dump.wav
|
||||
-l loop count: loop count, default 2.0
|
||||
-f fade time: fade time (seconds), default 10.0
|
||||
-i: ignore looping information and play the whole stream once
|
||||
-p: output to stdout (for piping into another program)
|
||||
-c: loop forever (continuously)
|
||||
-m: print metadata only, don't decode
|
||||
|
||||
Typical usage would be:
|
||||
test -o happy.wav happy.adx
|
||||
|
||||
Formats supported by this version of vgmstream (r30):
|
||||
- .adx (CRI ADX ADPCM)
|
||||
- .brstm (RSTM: GC/Wii ADPCM, 8/16 bit PCM)
|
||||
- .strm (STRM: NDS IMA ADPCM, 8/16 bit PCM)
|
||||
- .adp (GC DTK ADPCM)
|
||||
|
@ -412,6 +412,4 @@ void describe_vgmstream(VGMSTREAM * vgmstream) {
|
||||
printf("last block interleave: %#x bytes\n",vgmstream->interleave_smallblock_size);
|
||||
}
|
||||
}
|
||||
|
||||
printf("\n");
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
SHELL = /bin/sh
|
||||
CFLAGS=-lm
|
||||
CFLAGS=-lm -O3
|
||||
|
||||
VGMSTREAMFILES = ../src/streamfile.c ../src/vgmstream.c ../src/util.c ../src/meta/adx_header.c ../src/coding/adx_decoder.c ../src/coding/gcdsp_decoder.c ../src/meta/brstm.c ../src/layout/interleave.c ../src/layout/nolayout.c ../src/coding/pcm_decoder.c ../src/meta/nds_strm.c ../src/coding/ima_decoder.c ../src/meta/agsc.c ../src/meta/ngc_adpdtk.c ../src/coding/ngc_dtk_decoder.c ../src/coding/g721_decoder.c ../src/meta/rsf.c
|
||||
|
||||
|
54
test/test.c
54
test/test.c
@ -9,7 +9,16 @@ extern char * optarg;
|
||||
extern int optind, opterr, optopt;
|
||||
|
||||
void usage(const char * name) {
|
||||
fprintf(stderr,"Usage: %s [-o outfile.wav] [-l loop count] [-f fade time] [-i] [-p] [-c] infile\n\t-i: ignore loop\n\t-p: output to stdout\n\t-c: loop forever\n",name);
|
||||
fprintf(stderr,"Usage: %s [-o outfile.wav] [-l loop count]\n"
|
||||
"\t[-f fade time] [-i] [-p] [-c] [-m] infile\n"
|
||||
"Options:\n"
|
||||
"\t-o outfile.wav: name of output .wav file, default is dump.wav\n"
|
||||
"\t-l loop count: loop count, default 2.0\n"
|
||||
"\t-f fade time: fade time (seconds), default 10.0\n"
|
||||
"\t-i: ignore looping information and play the whole stream once\n"
|
||||
"\t-p: output to stdout (for piping into another program)\n"
|
||||
"\t-c: loop forever (continuously)\n"
|
||||
"\t-m: print metadata only, don't decode\n",name);
|
||||
}
|
||||
|
||||
int main(int argc, char ** argv) {
|
||||
@ -19,27 +28,25 @@ int main(int argc, char ** argv) {
|
||||
int32_t fade_samples;
|
||||
int i;
|
||||
FILE * outfile = NULL;
|
||||
char * outfilename = NULL;
|
||||
int opt;
|
||||
int ignore_loop = 0;
|
||||
int play = 0;
|
||||
int forever = 0;
|
||||
int metaonly = 0;
|
||||
double loop_count = 2.0;
|
||||
double fade_time = 10.0;
|
||||
|
||||
while ((opt = getopt(argc, argv, "o:l:f:ipc")) != -1) {
|
||||
while ((opt = getopt(argc, argv, "o:l:f:ipcm")) != -1) {
|
||||
switch (opt) {
|
||||
case 'o':
|
||||
outfile = fopen(optarg,"wb");
|
||||
if (!outfile) {
|
||||
fprintf(stderr,"failed to open %s for output\n",optarg);
|
||||
return 1;
|
||||
}
|
||||
outfilename = optarg;
|
||||
break;
|
||||
case 'l':
|
||||
loop_count = atoi(optarg);
|
||||
loop_count = atof(optarg);
|
||||
break;
|
||||
case 'f':
|
||||
fade_time = atoi(optarg);
|
||||
fade_time = atof(optarg);
|
||||
break;
|
||||
case 'i':
|
||||
ignore_loop = 1;
|
||||
@ -50,6 +57,9 @@ int main(int argc, char ** argv) {
|
||||
case 'c':
|
||||
forever = 1;
|
||||
break;
|
||||
case 'm':
|
||||
metaonly = 1;
|
||||
break;
|
||||
default:
|
||||
usage(argv[0]);
|
||||
return 1;
|
||||
@ -77,16 +87,16 @@ int main(int argc, char ** argv) {
|
||||
if (ignore_loop) s->loop_flag=0;
|
||||
|
||||
if (play) {
|
||||
if (outfile) {
|
||||
if (outfilename) {
|
||||
fprintf(stderr,"either -p or -o, make up your mind\n");
|
||||
return 1;
|
||||
}
|
||||
outfile = stdout;
|
||||
}
|
||||
else if (!outfile) {
|
||||
outfile = fopen("dump.wav","wb");
|
||||
} else if (!metaonly) {
|
||||
if (!outfilename) outfilename = "dump.wav";
|
||||
outfile = fopen(outfilename,"wb");
|
||||
if (!outfile) {
|
||||
fprintf(stderr,"failed to open dump.wav for output\n");
|
||||
fprintf(stderr,"failed to open %s for output\n",optarg);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
@ -96,17 +106,15 @@ int main(int argc, char ** argv) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (!play) printf("decoding %s\n",argv[optind]);
|
||||
/*
|
||||
printf("sample rate %d Hz\n",s->sample_rate);
|
||||
printf("channels: %d\n",s->channels);
|
||||
if (s->loop_flag) {
|
||||
printf("loop start: %d samples (%.2lf seconds)\n",s->loop_start_sample,(double)s->loop_start_sample/s->sample_rate);
|
||||
printf("loop end: %d samples (%.2lf seconds)\n",s->loop_end_sample,(double)s->loop_end_sample/s->sample_rate);
|
||||
if (!play) {
|
||||
if (metaonly) printf("metadata for %s\n",argv[optind]);
|
||||
else printf("decoding %s\n",argv[optind]);
|
||||
}
|
||||
printf("file total samples: %d (%.2lf seconds)\n",s->num_samples,(double)s->num_samples/s->sample_rate);
|
||||
*/
|
||||
if (!play) describe_vgmstream(s);
|
||||
if (metaonly) {
|
||||
close_vgmstream(s);
|
||||
return 0;
|
||||
}
|
||||
|
||||
len = get_vgmstream_play_samples(loop_count,fade_time,s);
|
||||
if (!play) printf("samples to play: %d (%.2lf seconds)\n",len,(double)len/s->sample_rate);
|
||||
|
Loading…
x
Reference in New Issue
Block a user