[PATCH alsa-utils 1/2] aplaymidi2: Add -a option to pass all UMP packets

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxx>
---
 seq/aplaymidi2/aplaymidi2.1 |  8 ++++++++
 seq/aplaymidi2/aplaymidi2.c | 20 +++++++++++++++-----
 2 files changed, 23 insertions(+), 5 deletions(-)

diff --git a/seq/aplaymidi2/aplaymidi2.1 b/seq/aplaymidi2/aplaymidi2.1
index fc85943c0d38..681796222914 100644
--- a/seq/aplaymidi2/aplaymidi2.1
+++ b/seq/aplaymidi2/aplaymidi2.1
@@ -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
diff --git a/seq/aplaymidi2/aplaymidi2.c b/seq/aplaymidi2/aplaymidi2.c
index 6a1f21e92444..f5dfdbd91f30 100644
--- a/seq/aplaymidi2/aplaymidi2.c
+++ b/seq/aplaymidi2/aplaymidi2.c
@@ -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;
-- 
2.43.0




[Index of Archives]     [ALSA User]     [Linux Audio Users]     [Pulse Audio]     [Kernel Archive]     [Asterisk PBX]     [Photo Sharing]     [Linux Sound]     [Video 4 Linux]     [Gimp]     [Yosemite News]

  Powered by Linux