From 1efba54ff69d5272b023920f49488140844e6f45 Mon Sep 17 00:00:00 2001 From: Claudio Matsuoka Date: Wed, 10 Apr 2013 21:27:24 -0300 Subject: [PATCH] Add option to play hidden sequences Add command-line option -z to specify a pattern sequence to play. The main sequence is 0. Signed-off-by: Claudio Matsuoka --- src/common.h | 1 + src/info.c | 4 ++-- src/main.c | 9 +++++++++ src/options.c | 7 ++++++- src/xmp.1 | 4 ++++ 5 files changed, 22 insertions(+), 3 deletions(-) diff --git a/src/common.h b/src/common.h index fe9e747..7ff321a 100644 --- a/src/common.h +++ b/src/common.h @@ -25,6 +25,7 @@ struct options { int nocmd; /* disable interactive commands */ int norc; /* don't read the configuration files */ int dparm; /* driver parameter index */ + int sequence; /* sequence to play */ char *driver_id; /* sound driver ID */ char *out_file; /* output file name */ char *ins_path; /* instrument path */ diff --git a/src/info.c b/src/info.c index d2ad9f3..0f3ddfa 100644 --- a/src/info.c +++ b/src/info.c @@ -78,9 +78,9 @@ void info_mod(struct xmp_module_info *mi) } report(" %dmin%02ds " - "(sequence at position %d)\n", + "(sequence %d at position %d)\n", (dur + 500) / 60000, ((dur + 500) / 1000) % 60, - mi->seq_data[i].entry_point); + i, mi->seq_data[i].entry_point); } } else { report("\n"); diff --git a/src/main.c b/src/main.c index c5990ea..4a15745 100644 --- a/src/main.c +++ b/src/main.c @@ -332,6 +332,15 @@ int main(int argc, char **argv) control.time = 0.0; control.loop = opt.loop; + if (opt.sequence) { + if (opt.sequence < mi.num_sequences) { + if (mi.seq_data[opt.sequence].duration > 0) { + opt.start = mi.seq_data[opt.sequence].entry_point; + } + } + opt.sequence = 0; + } + if (xmp_start_player(xc, opt.rate, opt.format) == 0) { xmp_set_player(xc, XMP_PLAYER_INTERP, opt.interp); xmp_set_player(xc, XMP_PLAYER_DSP, opt.dsp); diff --git a/src/options.c b/src/options.c index c325648..47209ae 100644 --- a/src/options.c +++ b/src/options.c @@ -74,6 +74,7 @@ static void usage(char *s) " -s --start num Start from the specified order\n" " -t --time num Maximum playing time in seconds\n" " --vblank Force vblank timing in Amiga modules\n" +" -z --sequence num Play the specified sequence (0=main)\n" "\nMixer 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" @@ -134,6 +135,7 @@ static const struct option lopt[] = { { "vblank", 0, 0, OPT_VBLANK }, { "version", 0, 0, 'V' }, { "verbose", 0, 0, 'v' }, + { "sequence", 1, 0, 'z' }, { NULL, 0, 0, 0 } }; @@ -142,7 +144,7 @@ void get_options(int argc, char **argv, struct options *options) int optidx = 0; int o; -#define OPTIONS "a:b:cD:d:Ff:hI:i:LlM:mNo:P:qRrS:s:T:t:uVv" +#define OPTIONS "a:b:cD:d:Ff:hI:i:LlM:mNo:P:qRrS:s:T:t:uVvz:" while ((o = getopt_long(argc, argv, OPTIONS, lopt, &optidx)) != -1) { switch (o) { case 'a': @@ -291,6 +293,9 @@ void get_options(int argc, char **argv, struct options *options) case 'v': options->verbose++; break; + case 'z': + options->sequence = strtoul(optarg, NULL, 0); + break; case 'h': usage(argv[0]); default: diff --git a/src/xmp.1 b/src/xmp.1 index 222e052..5f9a613 100644 --- a/src/xmp.1 +++ b/src/xmp.1 @@ -36,6 +36,7 @@ xmp - Extended Module Player [\fB--vblank\fP] [\fB-V, --version\fP] [\fB-v, --verbose\fP] +[\fB-z, --sequence\fP] \fImodules\fP .PP .SH "DESCRIPTION" @@ -123,6 +124,9 @@ Print version information\&. Verbose mode (incremental)\&. If specified more than once, the verbosity level will be increased (no messages will be displayed when the player runs in background)\&. +.IP "\fB-z, --sequence\fP \fInum\fP" +Play hidden or alternative pattern sequence \fInum\fP\ (0 is the main +sequence)\&. .PP .SH "DEVICE DRIVER PARAMETERS" Use the option \fB-D\fP to send parameters directly to the device