[xmp] Update to new API

Update to API with split module/frame info data.

Signed-off-by: Claudio Matsuoka <cmatsuoka@gmail.com>
master
Claudio Matsuoka 14 years ago
parent 725491c554
commit 5b8c1a1140
  1. 12
      src/common.h
  2. 63
      src/info.c
  3. 34
      src/main.c

@ -48,12 +48,12 @@ int set_tty(void);
int reset_tty(void); int reset_tty(void);
/* info */ /* info */
void info_mod(struct xmp_frame_info *); void info_mod(struct xmp_module_info *);
void info_frame_init(struct xmp_frame_info *); void info_frame_init(void);
void info_frame(struct xmp_frame_info *, struct control *, int); void info_frame(struct xmp_module_info *, struct xmp_frame_info *, struct control *, int);
void info_ins_smp(struct xmp_frame_info *); void info_ins_smp(struct xmp_module_info *);
void info_instruments(struct xmp_frame_info *); void info_instruments(struct xmp_module_info *);
void info_samples(struct xmp_frame_info *); void info_samples(struct xmp_module_info *);
void info_help(void); void info_help(void);
/* commands */ /* commands */

@ -25,42 +25,45 @@ void info_help(void)
); );
} }
void info_mod(struct xmp_frame_info *fi) void info_mod(struct xmp_module_info *mi)
{ {
int i; int i;
int num_seq; int num_seq;
int total_time;
report("Module name : %s\n", fi->mod->name);
report("Module type : %s\n", fi->mod->type); report("Module name : %s\n", mi->mod->name);
report("Module length: %d patterns\n", fi->mod->len); report("Module type : %s\n", mi->mod->type);
report("Patterns : %d\n", fi->mod->pat); report("Module length: %d patterns\n", mi->mod->len);
report("Instruments : %d\n", fi->mod->ins); report("Patterns : %d\n", mi->mod->pat);
report("Samples : %d\n", fi->mod->smp); report("Instruments : %d\n", mi->mod->ins);
report("Channels : %d [ ", fi->mod->chn); report("Samples : %d\n", mi->mod->smp);
report("Channels : %d [ ", mi->mod->chn);
for (i = 0; i < fi->mod->chn; i++) {
if (fi->mod->xxc[i].flg & XMP_CHANNEL_SYNTH) { for (i = 0; i < mi->mod->chn; i++) {
if (mi->mod->xxc[i].flg & XMP_CHANNEL_SYNTH) {
report("S "); report("S ");
} else { } else {
report("%x ", fi->mod->xxc[i].pan >> 4); report("%x ", mi->mod->xxc[i].pan >> 4);
} }
} }
report("]\n"); report("]\n");
report("Duration : %dmin%02ds", (fi->total_time + 500) / 60000, total_time = mi->seq_data[0].duration;
((fi->total_time + 500) / 1000) % 60);
report("Duration : %dmin%02ds", (total_time + 500) / 60000,
((total_time + 500) / 1000) % 60);
/* Check non-zero-length sequences */ /* Check non-zero-length sequences */
num_seq = 0; num_seq = 0;
for (i = 0; i < fi->num_sequences; i++) { for (i = 0; i < mi->num_sequences; i++) {
if (fi->seq_data[i].duration > 0) if (mi->seq_data[i].duration > 0)
num_seq++; num_seq++;
} }
if (num_seq > 1) { if (num_seq > 1) {
report(" (main sequence)\n"); report(" (main sequence)\n");
for (i = 1; i < fi->num_sequences; i++) { for (i = 1; i < mi->num_sequences; i++) {
int dur = fi->seq_data[i].duration; int dur = mi->seq_data[i].duration;
if (dur == 0) { if (dur == 0) {
continue; continue;
@ -69,19 +72,19 @@ void info_mod(struct xmp_frame_info *fi)
report(" %dmin%02ds " report(" %dmin%02ds "
"(sequence at position %d)\n", "(sequence at position %d)\n",
(dur + 500) / 60000, ((dur + 500) / 1000) % 60, (dur + 500) / 60000, ((dur + 500) / 1000) % 60,
fi->seq_data[i].entry_point); mi->seq_data[i].entry_point);
} }
} else { } else {
report("\n"); report("\n");
} }
} }
void info_frame_init(struct xmp_frame_info *fi) void info_frame_init()
{ {
max_channels = 0; max_channels = 0;
} }
void info_frame(struct xmp_frame_info *fi, struct control *ctl, int reprint) void info_frame(struct xmp_module_info *mi, struct xmp_frame_info *fi, struct control *ctl, int reprint)
{ {
static int ord = -1, spd = -1, bpm = -1; static int ord = -1, spd = -1, bpm = -1;
int time; int time;
@ -98,8 +101,8 @@ void info_frame(struct xmp_frame_info *fi, struct control *ctl, int reprint)
report("\rSpeed[%02X] BPM[%02X] Pos[%02X/%02X] " report("\rSpeed[%02X] BPM[%02X] Pos[%02X/%02X] "
"Pat[%02X/%02X] Row[ / ] Chn[ / ] 0:00:00.0", "Pat[%02X/%02X] Row[ / ] Chn[ / ] 0:00:00.0",
fi->speed, fi->bpm, fi->speed, fi->bpm,
fi->pos, fi->mod->len - 1, fi->pos, mi->mod->len - 1,
fi->pattern, fi->mod->pat - 1); fi->pattern, mi->mod->pat - 1);
ord = fi->pos; ord = fi->pos;
bpm = fi->bpm; bpm = fi->bpm;
spd = fi->speed; spd = fi->speed;
@ -121,10 +124,10 @@ void info_frame(struct xmp_frame_info *fi, struct control *ctl, int reprint)
fflush(stdout); fflush(stdout);
} }
void info_ins_smp(struct xmp_frame_info *fi) void info_ins_smp(struct xmp_module_info *mi)
{ {
int i, j; int i, j;
struct xmp_module *mod = fi->mod; struct xmp_module *mod = mi->mod;
report("Instruments and samples:\n"); report("Instruments and samples:\n");
report(" Instrument name Smp Size Loop End Vol Fine Xpo Pan\n"); report(" Instrument name Smp Size Loop End Vol Fine Xpo Pan\n");
@ -170,10 +173,10 @@ void info_ins_smp(struct xmp_frame_info *fi)
} }
} }
void info_instruments(struct xmp_frame_info *fi) void info_instruments(struct xmp_module_info *mi)
{ {
int i, j; int i, j;
struct xmp_module *mod = fi->mod; struct xmp_module *mod = mi->mod;
report("Instruments:\n"); report("Instruments:\n");
report(" Instrument name Vl Fade Env Ns Sub Gv Vl Fine Xpo Pan Sm\n"); report(" Instrument name Vl Fade Env Ns Sub Gv Vl Fine Xpo Pan Sm\n");
@ -220,10 +223,10 @@ void info_instruments(struct xmp_frame_info *fi)
} }
} }
void info_samples(struct xmp_frame_info *fi) void info_samples(struct xmp_module_info *mi)
{ {
int i; int i;
struct xmp_module *mod = fi->mod; struct xmp_module *mod = mi->mod;
report("Samples:\n"); report("Samples:\n");
report(" Sample name Length Start End Flags\n"); report(" Sample name Length Start End Flags\n");

@ -84,7 +84,7 @@ static void sigcont_handler(int sig)
} }
#endif #endif
static void show_info(int what, struct xmp_frame_info *fi) static void show_info(int what, struct xmp_module_info *mi)
{ {
report("\r%78.78s\n", " "); report("\r%78.78s\n", " ");
switch (what) { switch (what) {
@ -92,16 +92,16 @@ static void show_info(int what, struct xmp_frame_info *fi)
info_help(); info_help();
break; break;
case 'i': case 'i':
info_ins_smp(fi); info_ins_smp(mi);
break; break;
case 'I': case 'I':
info_instruments(fi); info_instruments(mi);
break; break;
case 'S': case 'S':
info_samples(fi); info_samples(mi);
break; break;
case 'm': case 'm':
info_mod(fi); info_mod(mi);
break; break;
} }
} }
@ -120,20 +120,20 @@ static void shuffle(int argc, char **argv)
} }
static void check_pause(xmp_context handle, struct control *ctl, static void check_pause(xmp_context handle, struct control *ctl,
struct xmp_frame_info *fi, int verbose) struct xmp_module_info *mi, struct xmp_frame_info *fi, int verbose)
{ {
if (ctl->pause) { if (ctl->pause) {
sound->pause(); sound->pause();
if (verbose) { if (verbose) {
info_frame(fi, ctl, 1); info_frame(mi, fi, ctl, 1);
} }
while (ctl->pause) { while (ctl->pause) {
usleep(100000); usleep(100000);
read_command(handle, ctl); read_command(handle, ctl);
if (ctl->display) { if (ctl->display) {
show_info(ctl->display, fi); show_info(ctl->display, mi);
if (verbose) { if (verbose) {
info_frame(fi, ctl, 1); info_frame(mi, fi, ctl, 1);
} }
ctl->display = 0; ctl->display = 0;
} }
@ -145,6 +145,7 @@ static void check_pause(xmp_context handle, struct control *ctl,
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
xmp_context handle; xmp_context handle;
struct xmp_module_info mi;
struct xmp_frame_info fi; struct xmp_frame_info fi;
struct options options; struct options options;
struct control control; struct control control;
@ -330,20 +331,21 @@ int main(int argc, char **argv)
/* Show module data */ /* Show module data */
xmp_get_frame_info(handle, &fi); xmp_get_module_info(handle, &mi);
if (options.verbose > 0) { if (options.verbose > 0) {
info_mod(&fi); info_mod(&mi);
} }
if (options.verbose > 1) { if (options.verbose > 1) {
info_instruments(&fi); info_instruments(&mi);
} }
/* Play module */ /* Play module */
refresh_status = 1; refresh_status = 1;
info_frame_init(&fi); info_frame_init();
fi.loop_count = 0;
while (!options.info && xmp_play_frame(handle) == 0) { while (!options.info && xmp_play_frame(handle) == 0) {
int old_loop = fi.loop_count; int old_loop = fi.loop_count;
@ -352,7 +354,7 @@ int main(int argc, char **argv)
break; break;
if (!background && options.verbose > 0) { if (!background && options.verbose > 0) {
info_frame(&fi, &control, refresh_status); info_frame(&mi, &fi, &control, refresh_status);
refresh_status = 0; refresh_status = 0;
} }
@ -364,7 +366,7 @@ int main(int argc, char **argv)
read_command(handle, &control); read_command(handle, &control);
if (control.display) { if (control.display) {
show_info(control.display, &fi); show_info(control.display, &mi);
control.display = 0; control.display = 0;
refresh_status = 1; refresh_status = 1;
} }
@ -375,7 +377,7 @@ int main(int argc, char **argv)
break; break;
} }
check_pause(handle, &control, &fi, check_pause(handle, &control, &mi, &fi,
options.verbose); options.verbose);
options.start = 0; options.start = 0;

Loading…
Cancel
Save