[xmp] Add option to display instrument info

Signed-off-by: Claudio Matsuoka <cmatsuoka@gmail.com>
master
Claudio Matsuoka 14 years ago
parent 3e2641d653
commit 189aa74b38
  1. 1
      src/common.h
  2. 48
      src/info.c
  3. 10
      src/main.c
  4. 2
      src/options.c

@ -9,6 +9,7 @@ struct options {
int loop; /* loop module */
int random; /* play in random order */
int load_only; /* load module and exit */
int verbose;
char *out_file; /* output file name */
char *ins_path; /* instrument path */
char mute[XMP_MAX_CHANNELS];

@ -1,4 +1,5 @@
#include <stdio.h>
#include <string.h>
#include <xmp.h>
void info_mod(struct xmp_module_info *mi)
@ -61,3 +62,50 @@ void info_frame(struct xmp_module_info *mi, int reset)
fflush(stdout);
}
void info_instruments_compact(struct xmp_module_info *mi)
{
int i, j;
struct xmp_module *mod = mi->mod;
printf("Instruments:\n");
printf(" Instrument name Size Loop End Vol Fine Pan\n");
for (i = 0; i < mod->ins; i++) {
struct xmp_instrument *ins = &mod->xxi[i];
if (strlen(ins->name) == 0 && ins->nsm == 0) {
continue;
}
printf("%02x %-32.32s %02x ", i, ins->name, ins->nsm);
for (j = 0; j < ins->nsm; j++) {
struct xmp_subinstrument *sub = &ins->sub[j];
struct xmp_sample *smp = &mod->xxs[sub->sid];
if (j > 0) {
if (smp->len == 0) {
continue;
}
printf("%38.38s", " ");
}
printf("%05x%c%05x %05x%c V%02x %+04d P%02x\n",
smp->len,
smp->flg & XMP_SAMPLE_16BIT ? '+' : ' ',
smp->lps,
smp->lpe,
smp->flg & XMP_SAMPLE_LOOP ?
smp->flg & XMP_SAMPLE_LOOP_BIDIR ?
'B' : 'L' : ' ',
sub->vol,
sub->fin,
sub->pan);
}
if (j == 0) {
printf("----- ----- ----- --- ---- ---\n");
}
}
}

@ -63,6 +63,8 @@ int main(int argc, char **argv)
#endif
memset(&options, 0, sizeof (struct options));
options.verbose = 1;
get_options(argc, argv, &options);
if (options.random) {
@ -107,7 +109,13 @@ int main(int argc, char **argv)
xmp_player_get_info(ctx, &mi);
info_mod(&mi);
if (options.verbose > 0) {
info_mod(&mi);
}
if (options.verbose == 2) {
info_instruments_compact(&mi);
}
/* Play module */

@ -261,7 +261,7 @@ void get_options(int argc, char **argv, struct options *options)
puts("Extended Module Player " VERSION);
exit(0);
case 'v':
//options->verbosity++;
options->verbose++;
break;
case 'h':
usage(argv[0]);

Loading…
Cancel
Save