aplaymidi2: Add -a option to pass all UMP packets

So far, aplaymidi2 passes the MIDI1/MIDI2 channel voice UMP messages
to the target while processing other UMP messages internally.  But
sometimes we'd like to pass all UMP messages as is and let the
receiver processes.

This patch adds a new option -a (or --passall) to pass the all UMP
packets included in the given MIDI Clip file to the target as-is.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
This commit is contained in:
Takashi Iwai 2024-07-19 14:20:33 +02:00
parent 47931000fd
commit 6a676f4a46
2 changed files with 23 additions and 5 deletions

View file

@ -67,6 +67,14 @@ Default is 2 seconds.
.I \-s, \-\-silent .I \-s, \-\-silent
Don't show message texts. Don't show message texts.
.TP
.I \-a, \-\-passall
Pass all UMP packets as is.
As default, \fBaplaymidi2\fP passes only MIDI1 and MIDI2 channel voice
messages and process other UMP packets internally.
With this option, it passes all UMP packets to the target.
.SH SEE ALSO .SH SEE ALSO
pmidi(1) pmidi(1)
.br .br

View file

@ -21,6 +21,7 @@ static snd_seq_addr_t ports[16];
static int queue; static int queue;
static int end_delay = 2; static int end_delay = 2;
static int silent; static int silent;
static int passall;
static unsigned int _current_tempo = 50000000; /* default 120 bpm */ static unsigned int _current_tempo = 50000000; /* default 120 bpm */
static unsigned int tempo_base = 10; static unsigned int tempo_base = 10;
@ -411,6 +412,9 @@ static void play_midi(FILE *file)
while ((len = read_ump_packet(file, ump)) > 0) { while ((len = read_ump_packet(file, ump)) > 0) {
const snd_ump_msg_hdr_t *h = (snd_ump_msg_hdr_t *)ump; const snd_ump_msg_hdr_t *h = (snd_ump_msg_hdr_t *)ump;
if (passall)
send_ump(ump, len);
if (h->type == SND_UMP_MSG_TYPE_UTILITY) { if (h->type == SND_UMP_MSG_TYPE_UTILITY) {
const snd_ump_msg_utility_t *uh = const snd_ump_msg_utility_t *uh =
(const snd_ump_msg_utility_t *)ump; (const snd_ump_msg_utility_t *)ump;
@ -448,9 +452,10 @@ static void play_midi(FILE *file)
end_clip(); end_clip();
continue; continue;
} }
} else if (h->type == SND_UMP_MSG_TYPE_MIDI1_CHANNEL_VOICE || } else if (!passall &&
h->type == SND_UMP_MSG_TYPE_DATA || (h->type == SND_UMP_MSG_TYPE_MIDI1_CHANNEL_VOICE ||
h->type == SND_UMP_MSG_TYPE_MIDI2_CHANNEL_VOICE) { h->type == SND_UMP_MSG_TYPE_DATA ||
h->type == SND_UMP_MSG_TYPE_MIDI2_CHANNEL_VOICE)) {
send_ump(ump, len); send_ump(ump, len);
} }
} }
@ -496,7 +501,8 @@ static void usage(const char *argv0)
"-V, --version print current version\n" "-V, --version print current version\n"
"-p, --port=client:port,... set port(s) to play to\n" "-p, --port=client:port,... set port(s) to play to\n"
"-d, --delay=seconds delay after song ends\n" "-d, --delay=seconds delay after song ends\n"
"-s, --silent don't show texts\n", "-s, --silent don't show texts\n"
"-a, --passall pass all UMP packets as-is\n",
argv0); argv0);
} }
@ -513,13 +519,14 @@ int main(int argc, char *argv[])
{"port", 1, NULL, 'p'}, {"port", 1, NULL, 'p'},
{"delay", 1, NULL, 'd'}, {"delay", 1, NULL, 'd'},
{"silent", 0, NULL, 's'}, {"silent", 0, NULL, 's'},
{"passall", 0, NULL, 'a'},
{0} {0}
}; };
int c; int c;
init_seq(); init_seq();
while ((c = getopt_long(argc, argv, "hVp:d:s", while ((c = getopt_long(argc, argv, "hVp:d:sa",
long_options, NULL)) != -1) { long_options, NULL)) != -1) {
switch (c) { switch (c) {
case 'h': case 'h':
@ -537,6 +544,9 @@ int main(int argc, char *argv[])
case 's': case 's':
silent = 1; silent = 1;
break; break;
case 'a':
passall = 1;
break;
default: default:
usage(argv[0]); usage(argv[0]);
return 1; return 1;