From d8820352fdbee5f78254bfa1d05c95c3be25ff24 Mon Sep 17 00:00:00 2001 From: Claudio Matsuoka Date: Thu, 11 Apr 2013 21:40:10 -0300 Subject: [PATCH] Add option to loop over entire module list Use --loop-all to enable looping over the entire module list. Command 'l' changed to cycle through regular loop and list loop. List loop is enabled only if at least one module was played. Signed-off-by: Claudio Matsuoka --- Changelog | 7 ++++--- src/commands.c | 3 ++- src/info.c | 10 ++++++---- src/main.c | 19 +++++++++++++++---- src/options.c | 6 ++++++ src/xmp.1 | 3 +++ 6 files changed, 36 insertions(+), 12 deletions(-) diff --git a/Changelog b/Changelog index a311569..471507b 100644 --- a/Changelog +++ b/Changelog @@ -2,14 +2,15 @@ Stable versions --------------- 4.0.3 (): - Bug reported by Misty De Meo: - - Fix native-endian support in coreaudio driver + - Fix native-endian support in coreaudio driver (reported by + Misty De Meo) - Subsong explorer requested by Benjamin Shadwick: + New features requested by Benjamin Shadwick: - Add commands '<' and '>' to jump to previous/next sequence - Add command 'z' to toggle the subsong explorer on/off - Add option -z to play a specified sequence - Add option -Z to play all sequences in module + - Add option --loop-all to loop over entire module list 4.0.2 (20130407): - Fix data type in coreaudio driver diff --git a/src/commands.c b/src/commands.c index 130f328..6c9f4ca 100644 --- a/src/commands.c +++ b/src/commands.c @@ -182,7 +182,8 @@ void read_command(xmp_context handle, struct xmp_module_info *mi, struct control ctl->skip = -1; break; case 'l': - ctl->loop ^= 1; + ctl->loop++; + ctl->loop %= 3; break; case 'Z': ctl->cur_seq = 1; diff --git a/src/info.c b/src/info.c index 4a12dbf..4b9a821 100644 --- a/src/info.c +++ b/src/info.c @@ -126,9 +126,10 @@ void info_frame(struct xmp_module_info *mi, struct xmp_frame_info *fi, struct co time = fi->time / 100; if (msg_timer > 0) { - report("\r%-61.61s %c%c ", msg_text, + report("\r%-61.61s %c%c%c", msg_text, ctl->explore ? 'Z' : ' ', - ctl->loop ? 'L' : ' '); + ctl->loop ? 'L' : ' ', + ctl->loop > 1 ? '*' : ' '); msg_timer -= fi->frame_time; if (msg_timer == 0) msg_timer--; @@ -153,9 +154,10 @@ void info_frame(struct xmp_module_info *mi, struct xmp_frame_info *fi, struct co } report("\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b" - "%02X/%02X] Chn[%02X/%02X] %c%c ", + "%02X/%02X] Chn[%02X/%02X] %c%c%c", fi->row, fi->num_rows - 1, fi->virt_used, max_channels, - ctl->explore ? 'Z' : ' ', ctl->loop ? 'L' : ' '); + ctl->explore ? 'Z' : ' ', ctl->loop ? 'L' : ' ', + ctl->loop > 1 ? '*' : ' '); print_time: diff --git a/src/main.c b/src/main.c index b5a8484..2cfe9fb 100644 --- a/src/main.c +++ b/src/main.c @@ -170,6 +170,7 @@ int main(int argc, char **argv) struct timeval tv; struct timezone tz; int flags; + int played; gettimeofday(&tv, &tz); srand(tv.tv_usec); @@ -278,7 +279,12 @@ int main(int argc, char **argv) lf_flag = 0; memcpy(&save_opt, &opt, sizeof (struct options)); - for (first = optind; optind < argc; optind++) { + control.loop = opt.loop; + control.explore = opt.explore; + first = optind; + + play_all: + for (played = 0; optind < argc; optind++) { memcpy(&opt, &save_opt, sizeof (struct options)); if (opt.verbose > 0) { @@ -330,8 +336,6 @@ int main(int argc, char **argv) skipprev = 0; control.time = 0.0; - control.loop = opt.loop; - control.explore = opt.explore; if (opt.sequence) { if (opt.sequence < mi.num_sequences) { @@ -346,6 +350,8 @@ int main(int argc, char **argv) xmp_set_player(xc, XMP_PLAYER_INTERP, opt.interp); xmp_set_player(xc, XMP_PLAYER_DSP, opt.dsp); + played = 1; + if (opt.mix >= 0) { xmp_set_player(xc, XMP_PLAYER_MIX, opt.mix); } @@ -403,7 +409,7 @@ int main(int argc, char **argv) int old_loop = fi.loop_count; xmp_get_frame_info(xc, &fi); - if (!control.loop && old_loop != fi.loop_count) + if (control.loop != 1 && old_loop != fi.loop_count) break; sigcont_handler(0); @@ -471,6 +477,11 @@ int main(int argc, char **argv) control.skip = 0; } + if (control.loop == 2 && played) { + optind = first; + goto play_all; + } + sound->flush(); end: diff --git a/src/options.c b/src/options.c index 571bafe..e53c9b0 100644 --- a/src/options.c +++ b/src/options.c @@ -35,6 +35,7 @@ enum { OPT_VBLANK, OPT_FIXLOOP, OPT_NORC, + OPT_LOOPALL, }; static void usage(char *s) @@ -65,6 +66,7 @@ static void usage(char *s) " -d --driver name Force output to the specified device\n" " --fix-sample-loops Use sample loop start /2 in MOD/UNIC/NP3\n" " -l --loop Enable module looping\n" +" --loop-all Loop over entire module list\n" " -M --mute ch-list Mute the specified channels\n" " --nocmd Disable interactive commands\n" " --norc Don't read configuration files\n" @@ -113,6 +115,7 @@ static const struct option lopt[] = { { "interpolation", 1, 0, 'i' }, { "list-formats", 0, 0, 'L' }, { "loop", 0, 0, 'l' }, + { "loop-all", 0, 0, OPT_LOOPALL }, { "mono", 0, 0, 'm' }, { "mute", 1, 0, 'M' }, { "null", 0, 0, 'N' }, @@ -207,6 +210,9 @@ void get_options(int argc, char **argv, struct options *options) case 'l': options->loop = 1; break; + case OPT_LOOPALL: + options->loop = 2; + break; case 'm': options->format |= XMP_FORMAT_MONO; break; diff --git a/src/xmp.1 b/src/xmp.1 index 83c0f64..7449edc 100644 --- a/src/xmp.1 +++ b/src/xmp.1 @@ -19,6 +19,7 @@ xmp - Extended Module Player [\fB--load-only\fP] [\fB-L, --list-formats\fP] [\fB-l, --loop\fP] +[\fB--loop-all\fP] [\fB-M, --mute\fP \fIchannel-list\fP] [\fB-m, --mono\fP] [\fB-N, --null\fP] @@ -85,6 +86,8 @@ Load module and exit\&. List supported module formats\&. .IP "\fB-l, --loop\fP" Enable module looping\&. +.IP "\fB--loop-all\fP" +Loop over the entire module list\&. .IP "\fB-M, --mute\fP \fIchannel-list\fP" Mute the specified channels\&. \fIchannel-list\fP is a comma-separated list of decimal channel ranges\&. Example: 0,2-4,8-16\&.