[xmp] Add option to display information and exit

This is similar to option --load-only of xmp 3.

Signed-off-by: Claudio Matsuoka <cmatsuoka@gmail.com>
master
Claudio Matsuoka 14 years ago
parent e9e5d176c3
commit 3d2933532e
  1. 1
      src/common.h
  2. 9
      src/main.c
  3. 72
      src/options.c

@ -11,6 +11,7 @@ struct options {
int load_only; /* load module and exit */
int verbose;
int silent; /* silent output */
int info; /* display information and exit */
char *out_file; /* output file name */
char *ins_path; /* instrument path */
char mute[XMP_MAX_CHANNELS];

@ -178,10 +178,9 @@ int main(int argc, char **argv)
info_instruments_compact(&mi);
}
/* Play module */
while (xmp_player_frame(handle) == 0) {
while (!options.info && xmp_player_frame(handle) == 0) {
int old_loop = mi.loop_count;
xmp_player_get_info(handle, &mi);
@ -207,11 +206,15 @@ int main(int argc, char **argv)
options.start = 0;
}
xmp_player_end(handle);
}
xmp_release_module(handle);
printf("\n");
if (!options.info) {
printf("\n");
}
if (control.skip == -1) {
optind -= optind > first ? 2 : 1;

@ -21,7 +21,6 @@ static int o, i;
static char *token;
extern int probeonly;
extern int loadonly;
extern int randomize;
extern int nocmd;
#ifdef HAVE_SYS_RTPRIO_H
@ -80,37 +79,37 @@ static void usage(char *s)
#endif
printf("\nPlayer control options:\n"
" -D parameter[=val] Pass configuration parameter to the output driver\n"
" -d --driver name Force output to the specified device\n"
" --offset-bug-emulation Emulate Protracker 2.x bug in effect 9\n"
" -l --loop Enable module looping\n"
" -M --mute ch-list Mute the specified channels\n"
" -R --random Random order playing\n"
" -S --solo ch-list Set channels to solo mode\n"
" -s --start num Start from the specified order\n"
" -t --time num Maximum playing time in seconds\n"
"\nPlayer sound options:\n"
" -8 --8bit Convert 16 bit samples to 8 bit\n"
" -m --mono Mono output\n"
" -P --pan pan Percentual pan amplitude\n"
"\nSoftware mixer options:\n"
" -a --amplify {0|1|2|3} Amplification factor: 0=Normal, 1=x2, 2=x4, 3=x8\n"
" -b --bits {8|16} Software mixer resolution (8 or 16 bits)\n"
" -c --stdout Mix the module to stdout\n"
" -F --click-filter Apply low pass filter to reduce clicks\n"
" -f --frequency rate Sampling rate in hertz (default 44100)\n"
" -o --output-file name Mix the module to file ('-' for stdout)\n"
" -u --unsigned Set the mixer to use unsigned samples\n"
"\nEnvironment options:\n"
" -I --instrument-path Set pathname to external samples\n"
"\nInformation options:\n"
" -h --help Print a summary of the command line options\n"
" --load-only Load module and exit\n"
" --probe-only Probe audio device and exit\n"
" -q --quiet Quiet mode (verbosity level = 0)\n"
" --show-time Display elapsed and remaining time\n"
" -V --version Print version information\n"
" -v --verbose Verbose mode (incremental)\n");
" -D parameter[=val] Pass configuration parameter to the output driver\n"
" -d --driver name Force output to the specified device\n"
" --offset-bug-emulation Emulate Protracker 2.x bug in effect 9\n"
" -l --loop Enable module looping\n"
" -M --mute ch-list Mute the specified channels\n"
" -R --random Random order playing\n"
" -S --solo ch-list Set channels to solo mode\n"
" -s --start num Start from the specified order\n"
" -t --time num Maximum playing time in seconds\n"
"\nPlayer sound options:\n"
" -8 --8bit Convert 16 bit samples to 8 bit\n"
" -m --mono Mono output\n"
" -P --pan pan Percentual pan amplitude\n"
"\nSoftware mixer options:\n"
" -a --amplify {0|1|2|3} Amplification factor: 0=Normal, 1=x2, 2=x4, 3=x8\n"
" -b --bits {8|16} Software mixer resolution (8 or 16 bits)\n"
" -c --stdout Mix the module to stdout\n"
" -F --click-filter Apply low pass filter to reduce clicks\n"
" -f --frequency rate Sampling rate in hertz (default 44100)\n"
" -o --output-file name Mix the module to file ('-' for stdout)\n"
" -u --unsigned Set the mixer to use unsigned samples\n"
"\nEnvironment options:\n"
" -I --instrument-path Set pathname to external samples\n"
"\nInformation options:\n"
" -h --help Display a summary of the command line options\n"
" -i --info Display module information and exit\n"
" --probe-only Probe audio device and exit\n"
" -q --quiet Quiet mode (verbosity level = 0)\n"
" --show-time Display elapsed and remaining time\n"
" -V --version Print version information\n"
" -v --verbose Verbose mode (incremental)\n");
}
static struct option lopt[] = {
@ -120,8 +119,8 @@ static struct option lopt[] = {
{ "frequency", 1, 0, 'f' },
{ "offset-bug-emulation", 0, 0, OPT_FX9BUG },
{ "help", 0, 0, 'h' },
{ "instrument-path", 1, 0, 'I' },
{ "load-only", 0, 0, OPT_LOADONLY },
{ "instrument-path", 1, 0, 'I' },
{ "info", 0, 0, 'i' },
{ "loop", 0, 0, 'l' },
{ "mono", 0, 0, 'm' },
{ "mute", 1, 0, 'M' },
@ -143,7 +142,7 @@ static struct option lopt[] = {
void get_options(int argc, char **argv, struct options *options)
{
int optidx = 0;
#define OPTIONS "a:b:cD:d:f:hI:lM:mno:qRS:s:T:t:uVv"
#define OPTIONS "a:b:cD:d:f:hI:ilM:mno:qRS:s:T:t:uVv"
i = 0;
while ((o = getopt_long(argc, argv, OPTIONS, lopt, &optidx)) != -1) {
switch (o) {
@ -175,6 +174,9 @@ void get_options(int argc, char **argv, struct options *options)
case 'I':
options->ins_path = optarg;
break;
case 'i':
options->info = 1;
break;
case 'l':
options->loop = 1;
break;

Loading…
Cancel
Save