]> git.alsa-project.org Git - alsa-utils.git/commitdiff
aplaymidi2: Add -a option to pass all UMP packets
authorTakashi Iwai <tiwai@suse.de>
Fri, 19 Jul 2024 12:20:33 +0000 (14:20 +0200)
committerTakashi Iwai <tiwai@suse.de>
Fri, 19 Jul 2024 12:28:44 +0000 (14:28 +0200)
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>
seq/aplaymidi2/aplaymidi2.1
seq/aplaymidi2/aplaymidi2.c

index fc85943c0d389a5b3870007a4e2ebc195f038da8..6817962229144fd4527f14f34ac61ae687b3ab20 100644 (file)
@@ -67,6 +67,14 @@ Default is 2 seconds.
 .I \-s, \-\-silent
 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
 pmidi(1)
 .br
index 6a1f21e9244417a943286f98e5f91d0ed3f7cccb..f5dfdbd91f307de33a8c5e1ac061e05298586c20 100644 (file)
@@ -21,6 +21,7 @@ static snd_seq_addr_t ports[16];
 static int queue;
 static int end_delay = 2;
 static int silent;
+static int passall;
 
 static unsigned int _current_tempo  = 50000000; /* default 120 bpm */
 static unsigned int tempo_base = 10;
@@ -411,6 +412,9 @@ static void play_midi(FILE *file)
        while ((len = read_ump_packet(file, ump)) > 0) {
                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) {
                        const snd_ump_msg_utility_t *uh =
                                (const snd_ump_msg_utility_t *)ump;
@@ -448,9 +452,10 @@ static void play_midi(FILE *file)
                                end_clip();
                                continue;
                        }
-               } else if (h->type == SND_UMP_MSG_TYPE_MIDI1_CHANNEL_VOICE ||
-                          h->type == SND_UMP_MSG_TYPE_DATA ||
-                          h->type == SND_UMP_MSG_TYPE_MIDI2_CHANNEL_VOICE) {
+               } else if (!passall &&
+                          (h->type == SND_UMP_MSG_TYPE_MIDI1_CHANNEL_VOICE ||
+                           h->type == SND_UMP_MSG_TYPE_DATA ||
+                           h->type == SND_UMP_MSG_TYPE_MIDI2_CHANNEL_VOICE)) {
                        send_ump(ump, len);
                }
        }
@@ -496,7 +501,8 @@ static void usage(const char *argv0)
                "-V, --version               print current version\n"
                "-p, --port=client:port,...  set port(s) to play to\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);
 }
 
@@ -513,13 +519,14 @@ int main(int argc, char *argv[])
                {"port", 1, NULL, 'p'},
                {"delay", 1, NULL, 'd'},
                {"silent", 0, NULL, 's'},
+               {"passall", 0, NULL, 'a'},
                {0}
        };
        int c;
 
        init_seq();
 
-       while ((c = getopt_long(argc, argv, "hVp:d:s",
+       while ((c = getopt_long(argc, argv, "hVp:d:sa",
                                long_options, NULL)) != -1) {
                switch (c) {
                case 'h':
@@ -537,6 +544,9 @@ int main(int argc, char *argv[])
                case 's':
                        silent = 1;
                        break;
+               case 'a':
+                       passall = 1;
+                       break;
                default:
                        usage(argv[0]);
                        return 1;