[PATCH alsa-utils 00/10] Cleanup seq/* stuff and extend aseqsend
Hi,
this is a series of cleanup / fix patches for alsa-utils/seq/* stuff, including the extension of aseqsend to support UMP packet bytes.
Takashi
===
Takashi Iwai (10): configure: Requires the latest ALSA-lib release 1.2.12 aplaymidi: Drop ifdef for UMP support aplaymidi: Allow to pass 0 to -u option, too aconnect: Drop superfluous ifdefs aseqdump: Drop ifdef for UMP support aseqdump: Check the -u option value properly configure: Drop unused conditionals aseqdump: Show SysEx prefix to UMP SysEx data dump aseqsend: Support UMP mode aseqsend: Support long options
configure.ac | 13 +------- seq/aconnect/aconnect.c | 31 ------------------ seq/aplaymidi/aplaymidi.c | 32 +++--------------- seq/aseqdump/aseqdump.c | 25 +++----------- seq/aseqsend/aseqsend.1 | 69 +++++++++++++++++++++------------------ seq/aseqsend/aseqsend.c | 54 +++++++++++++++++++++++++++++- 6 files changed, 100 insertions(+), 124 deletions(-)
New features such as MIDI 2.0 should be always enabled for the builds. Update the dependency to alsa-lib 1.2.12.
Signed-off-by: Takashi Iwai tiwai@suse.de --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/configure.ac b/configure.ac index 708380cf31dc..4803fe471c57 100644 --- a/configure.ac +++ b/configure.ac @@ -21,7 +21,7 @@ AC_PROG_SED AC_DISABLE_STATIC AM_PROG_LIBTOOL PKG_PROG_PKG_CONFIG -AM_PATH_ALSA(1.2.5) +AM_PATH_ALSA(1.2.12) if test "x$enable_alsatest" = "xyes"; then AC_CHECK_FUNC([snd_ctl_elem_add_enumerated], , [AC_ERROR([No user enum control support in alsa-lib])])
Now that the latest alsa-lib 1.2.12 became mandatory, all ugly ifdefs can be dropped.
Signed-off-by: Takashi Iwai tiwai@suse.de --- seq/aplaymidi/aplaymidi.c | 24 +----------------------- 1 file changed, 1 insertion(+), 23 deletions(-)
diff --git a/seq/aplaymidi/aplaymidi.c b/seq/aplaymidi/aplaymidi.c index 66038e278d4a..dd8d07997985 100644 --- a/seq/aplaymidi/aplaymidi.c +++ b/seq/aplaymidi/aplaymidi.c @@ -30,9 +30,7 @@ #include <unistd.h> #include <alsa/asoundlib.h> #include "version.h" -#ifdef HAVE_SEQ_CLIENT_INFO_GET_MIDI_VERSION #include <alsa/ump_msg.h> -#endif
/* * 31.25 kbaud, one start bit, eight data bits, two stop bits. @@ -78,9 +76,7 @@ static int file_offset; /* current offset in input file */ static int num_tracks; static struct track *tracks; static int smpte_timing; -#ifdef HAVE_SEQ_CLIENT_INFO_GET_MIDI_VERSION static int ump_mode; -#endif
/* prints an error message to stderr */ static void errormsg(const char *msg, ...) @@ -685,7 +681,6 @@ static int fill_legacy_event(struct event* event, snd_seq_event_t *ev) return 0; }
-#ifdef HAVE_SEQ_CLIENT_INFO_GET_MIDI_VERSION static unsigned char to_ump_status(unsigned char ev_type) { switch (ev_type) { @@ -762,13 +757,10 @@ static int fill_ump_event(struct event* event, snd_seq_ump_event_t *ump_ev, snd_seq_ev_set_ump_data(ump_ev, &ump, sizeof(ump)); return 0; } -#endif /* HAVE_SEQ_CLIENT_INFO_GET_MIDI_VERSION */
static void play_midi(void) { -#ifdef HAVE_SEQ_CLIENT_INFO_GET_MIDI_VERSION snd_seq_ump_event_t ump_ev; -#endif snd_seq_event_t ev; int i, max_tick, err;
@@ -830,7 +822,7 @@ static void play_midi(void) if (err < 0) continue; } -#ifdef HAVE_SEQ_CLIENT_INFO_GET_MIDI_VERSION + if (ump_mode) { err = fill_ump_event(event, &ump_ev, &ev); if (err < 0) @@ -839,7 +831,6 @@ static void play_midi(void) check_snd("output event", err); continue; } -#endif
/* this blocks when the output pool has been filled */ err = snd_seq_event_output(seq, &ev); @@ -957,9 +948,7 @@ static void usage(const char *argv0) "-V, --version print current version\n" "-l, --list list all possible output ports\n" "-p, --port=client:port,... set port(s) to play to\n" -#ifdef HAVE_SEQ_CLIENT_INFO_GET_MIDI_VERSION "-u, --ump=version UMP output (only version=1 is supported)\n" -#endif "-d, --delay=seconds delay after song ends\n", argv0); } @@ -969,12 +958,7 @@ static void version(void) puts("aplaymidi version " SND_UTIL_VERSION_STR); }
-#ifdef HAVE_SEQ_CLIENT_INFO_GET_MIDI_VERSION #define OPTIONS "hVlp:d:u:" -#else -#define OPTIONS "hVlp:d:" -#endif -
int main(int argc, char *argv[]) { @@ -984,9 +968,7 @@ int main(int argc, char *argv[]) {"version", 0, NULL, 'V'}, {"list", 0, NULL, 'l'}, {"port", 1, NULL, 'p'}, -#ifdef HAVE_SEQ_CLIENT_INFO_GET_MIDI_VERSION {"ump", 1, NULL, 'u'}, -#endif {"delay", 1, NULL, 'd'}, {0} }; @@ -1013,7 +995,6 @@ int main(int argc, char *argv[]) case 'd': end_delay = atoi(optarg); break; -#ifdef HAVE_SEQ_CLIENT_INFO_GET_MIDI_VERSION case 'u': if (strcmp(optarg, "1")) { errormsg("Only MIDI 1.0 is supported"); @@ -1021,7 +1002,6 @@ int main(int argc, char *argv[]) } ump_mode = 1; break; -#endif default: usage(argv[0]); return 1; @@ -1029,13 +1009,11 @@ int main(int argc, char *argv[]) }
-#ifdef HAVE_SEQ_CLIENT_INFO_GET_MIDI_VERSION if (ump_mode) { int err; err = snd_seq_set_client_midi_version(seq, SND_SEQ_CLIENT_UMP_MIDI_1_0); check_snd("set midi version", err); } -#endif
if (do_list) { list_ports();
Specifying -u 0 shouldn't be treated as an error but it should mean the legacy MIDI 1.0 handling.
Signed-off-by: Takashi Iwai tiwai@suse.de --- seq/aplaymidi/aplaymidi.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/seq/aplaymidi/aplaymidi.c b/seq/aplaymidi/aplaymidi.c index dd8d07997985..7aeea824ce0d 100644 --- a/seq/aplaymidi/aplaymidi.c +++ b/seq/aplaymidi/aplaymidi.c @@ -996,11 +996,9 @@ int main(int argc, char *argv[]) end_delay = atoi(optarg); break; case 'u': - if (strcmp(optarg, "1")) { - errormsg("Only MIDI 1.0 is supported"); - return 1; - } - ump_mode = 1; + ump_mode = atoi(optarg); + if (ump_mode < 0 || ump_mode > 1) + fatal("Only MIDI 1.0 is supported"); break; default: usage(argv[0]);
Now that the latest alsa-lib 1.2.12 became mandatory, all ugly ifdefs can be dropped.
Signed-off-by: Takashi Iwai tiwai@suse.de --- seq/aconnect/aconnect.c | 31 ------------------------------- 1 file changed, 31 deletions(-)
diff --git a/seq/aconnect/aconnect.c b/seq/aconnect/aconnect.c index 371165d65323..edd028f0391d 100644 --- a/seq/aconnect/aconnect.c +++ b/seq/aconnect/aconnect.c @@ -29,12 +29,7 @@ #include <alsa/asoundlib.h> #include "gettext.h"
-#ifdef SND_SEQ_PORT_CAP_INACTIVE -#define HANDLE_SHOW_ALL static int show_all; -#else -#define show_all 0 -#endif
static void error_handler(const char *file, int line, const char *function, int err, const char *fmt, ...) { @@ -67,9 +62,7 @@ static void usage(void) printf(_(" aconnect -i|-o [-options]\n")); printf(_(" -i,--input list input (readable) ports\n")); printf(_(" -o,--output list output (writable) ports\n")); -#ifdef HANDLE_SHOW_ALL printf(_(" -a,--all show inactive ports, too\n")); -#endif printf(_(" -l,--list list current connections of each port\n")); printf(_(" * Remove all exported connections\n")); printf(_(" -x, --removeall\n")); @@ -84,15 +77,11 @@ static void usage(void)
#define perm_ok(cap,bits) (((cap) & (bits)) == (bits))
-#ifdef SND_SEQ_PORT_DIR_INPUT static int check_direction(snd_seq_port_info_t *pinfo, int bit) { int dir = snd_seq_port_info_get_direction(pinfo); return !dir || (dir & bit); } -#else -#define check_direction(x, y) 1 -#endif
static int check_permission(snd_seq_port_info_t *pinfo, int perm) { @@ -174,20 +163,16 @@ static void do_search_port(snd_seq_t *seq, int perm, action_func_t do_action) /* reset query info */ snd_seq_port_info_set_client(pinfo, snd_seq_client_info_get_client(cinfo)); snd_seq_port_info_set_port(pinfo, -1); -#ifdef HANDLE_SHOW_ALL if (show_all) snd_seq_port_info_set_capability(pinfo, SND_SEQ_PORT_CAP_INACTIVE); -#endif count = 0; while (snd_seq_query_next_port(seq, pinfo) >= 0) { if (check_permission(pinfo, perm)) { do_action(seq, cinfo, pinfo, count); count++; } -#ifdef HANDLE_SHOW_ALL if (show_all) snd_seq_port_info_set_capability(pinfo, SND_SEQ_PORT_CAP_INACTIVE); -#endif } } } @@ -205,7 +190,6 @@ static void print_port(snd_seq_t *seq ATTRIBUTE_UNUSED, snd_seq_client_info_get_name(cinfo), (snd_seq_client_info_get_type(cinfo) == SND_SEQ_USER_CLIENT ? _("user") : _("kernel"))); -#ifdef HAVE_SEQ_CLIENT_INFO_GET_MIDI_VERSION switch (snd_seq_client_info_get_midi_version(cinfo)) { case SND_SEQ_CLIENT_UMP_MIDI_1_0: printf(",UMP-MIDI1"); @@ -214,16 +198,11 @@ static void print_port(snd_seq_t *seq ATTRIBUTE_UNUSED, printf(",UMP-MIDI2"); break; } -#endif -#ifdef HAVE_SEQ_CLIENT_INFO_GET_CARD card = snd_seq_client_info_get_card(cinfo); -#endif if (card != -1) printf(",card=%d", card);
-#ifdef HAVE_SEQ_CLIENT_INFO_GET_PID pid = snd_seq_client_info_get_pid(cinfo); -#endif if (pid != -1) printf(",pid=%d", pid); printf("]\n"); @@ -231,10 +210,8 @@ static void print_port(snd_seq_t *seq ATTRIBUTE_UNUSED, printf(" %3d '%-16s'", snd_seq_port_info_get_port(pinfo), snd_seq_port_info_get_name(pinfo)); -#ifdef HANDLE_SHOW_ALL if (snd_seq_port_info_get_capability(pinfo) & SND_SEQ_PORT_CAP_INACTIVE) printf(" [INACTIVE]"); -#endif printf("\n"); }
@@ -299,11 +276,7 @@ enum { SUBSCRIBE, UNSUBSCRIBE, LIST, REMOVE_ALL };
-#ifdef HANDLE_SHOW_ALL #define ACONNECT_OPTS "dior:t:elxa" -#else -#define ACONNECT_OPTS "dior:t:elx" -#endif
static const struct option long_option[] = { {"disconnect", 0, NULL, 'd'}, @@ -314,9 +287,7 @@ static const struct option long_option[] = { {"exclusive", 0, NULL, 'e'}, {"list", 0, NULL, 'l'}, {"removeall", 0, NULL, 'x'}, -#ifdef HANDLE_SHOW_ALL {"all", 0, NULL, 'a'}, -#endif {NULL, 0, NULL, 0}, };
@@ -370,12 +341,10 @@ int main(int argc, char **argv) case 'x': command = REMOVE_ALL; break; -#ifdef HANDLE_SHOW_ALL case 'a': command = LIST; show_all = 1; break; -#endif default: usage(); exit(1);
Now that the latest alsa-lib 1.2.12 is mandatory, drop the ugly ifdefs.
Signed-off-by: Takashi Iwai tiwai@suse.de --- seq/aseqdump/aseqdump.c | 22 +--------------------- 1 file changed, 1 insertion(+), 21 deletions(-)
diff --git a/seq/aseqdump/aseqdump.c b/seq/aseqdump/aseqdump.c index 6ac897c0710a..1c968b1cfc05 100644 --- a/seq/aseqdump/aseqdump.c +++ b/seq/aseqdump/aseqdump.c @@ -29,9 +29,7 @@ #include <poll.h> #include <alsa/asoundlib.h> #include "version.h" -#ifdef HAVE_SEQ_CLIENT_INFO_GET_MIDI_VERSION #include <alsa/ump_msg.h> -#endif
enum { VIEW_RAW, VIEW_NORMALIZED, VIEW_PERCENT @@ -41,11 +39,7 @@ static snd_seq_t *seq; static int port_count; static snd_seq_addr_t *ports; static volatile sig_atomic_t stop = 0; -#ifdef HAVE_SEQ_CLIENT_INFO_GET_MIDI_VERSION static int ump_version; -#else -#define ump_version 0 -#endif static int view_mode = VIEW_RAW;
/* prints an error message to stderr, and dies */ @@ -368,7 +362,6 @@ static void dump_event(const snd_seq_event_t *ev) } }
-#ifdef HAVE_SEQ_CLIENT_INFO_GET_MIDI_VERSION static int group_number(unsigned char c) { if (view_mode != VIEW_RAW) @@ -986,7 +979,6 @@ static void dump_ump_event(const snd_seq_ump_event_t *ev) break; } } -#endif /* HAVE_SEQ_CLIENT_INFO_GET_MIDI_VERSION */
static void list_ports(void) { @@ -1029,10 +1021,8 @@ static void help(const char *argv0) " -N,--normalized-view show normalized values\n" " -P,--percent-view show percent values\n" " -R,--raw-view show raw values (default)\n" -#ifdef HAVE_SEQ_CLIENT_INFO_GET_MIDI_VERSION " -u,--ump=version set client MIDI version (0=legacy, 1= UMP MIDI 1.0, 2=UMP MIDI2.0)\n" " -r,--raw do not convert UMP and legacy events\n" -#endif " -p,--port=client:port,... source port(s)\n", argv0); } @@ -1049,11 +1039,7 @@ static void sighandler(int sig ATTRIBUTE_UNUSED)
int main(int argc, char *argv[]) { - static const char short_options[] = "hVlp:NPR" -#ifdef HAVE_SEQ_CLIENT_INFO_GET_MIDI_VERSION - "u:r" -#endif - ; + static const char short_options[] = "hVlp:NPRu:r"; static const struct option long_options[] = { {"help", 0, NULL, 'h'}, {"version", 0, NULL, 'V'}, @@ -1062,10 +1048,8 @@ int main(int argc, char *argv[]) {"normalized-view", 0, NULL, 'N'}, {"percent-view", 0, NULL, 'P'}, {"raw-view", 0, NULL, 'R'}, -#ifdef HAVE_SEQ_CLIENT_INFO_GET_MIDI_VERSION {"ump", 1, NULL, 'u'}, {"raw", 0, NULL, 'r'}, -#endif {0} };
@@ -1100,7 +1084,6 @@ int main(int argc, char *argv[]) case 'N': view_mode = VIEW_NORMALIZED; break; -#ifdef HAVE_SEQ_CLIENT_INFO_GET_MIDI_VERSION case 'u': ump_version = atoi(optarg); snd_seq_set_client_midi_version(seq, ump_version); @@ -1108,7 +1091,6 @@ int main(int argc, char *argv[]) case 'r': snd_seq_set_client_ump_conversion(seq, 0); break; -#endif default: help(argv[0]); return 1; @@ -1150,7 +1132,6 @@ int main(int argc, char *argv[]) break; for (;;) { snd_seq_event_t *event; -#ifdef HAVE_SEQ_CLIENT_INFO_GET_MIDI_VERSION snd_seq_ump_event_t *ump_ev; if (ump_version > 0) { err = snd_seq_ump_event_input(seq, &ump_ev); @@ -1160,7 +1141,6 @@ int main(int argc, char *argv[]) dump_ump_event(ump_ev); continue; } -#endif
err = snd_seq_event_input(seq, &event); if (err < 0)
Instead of passing the value as is, check the value passed to -u option and bail out for bad values.
Signed-off-by: Takashi Iwai tiwai@suse.de --- seq/aseqdump/aseqdump.c | 2 ++ 1 file changed, 2 insertions(+)
diff --git a/seq/aseqdump/aseqdump.c b/seq/aseqdump/aseqdump.c index 1c968b1cfc05..f717557824ad 100644 --- a/seq/aseqdump/aseqdump.c +++ b/seq/aseqdump/aseqdump.c @@ -1086,6 +1086,8 @@ int main(int argc, char *argv[]) break; case 'u': ump_version = atoi(optarg); + if (ump_version < 0 || ump_version > 2) + fatal("Invalid UMP version %d", ump_version); snd_seq_set_client_midi_version(seq, ump_version); break; case 'r':
Since the required alsa-lib version was bumped and the relevant code cleanup, some conditionals are no longer referred. Drop them.
Signed-off-by: Takashi Iwai tiwai@suse.de --- configure.ac | 11 ----------- 1 file changed, 11 deletions(-)
diff --git a/configure.ac b/configure.ac index 4803fe471c57..bc33fecd72e1 100644 --- a/configure.ac +++ b/configure.ac @@ -47,17 +47,6 @@ AC_CHECK_HEADERS([samplerate.h], [have_samplerate="yes"], [have_samplerate="no"] [#include <samplerate.h>])
AC_CHECK_LIB([asound], [snd_seq_client_info_get_card], [HAVE_SEQ_CLIENT_INFO_GET_CARD="yes"]) -if test "$HAVE_SEQ_CLIENT_INFO_GET_CARD" = "yes" ; then - AC_DEFINE([HAVE_SEQ_CLIENT_INFO_GET_CARD], 1, [alsa-lib supports snd_seq_client_info_get_card]) -fi -AC_CHECK_LIB([asound], [snd_seq_client_info_get_pid], [HAVE_SEQ_CLIENT_INFO_GET_PID="yes"]) -if test "$HAVE_SEQ_CLIENT_INFO_GET_PID" = "yes" ; then - AC_DEFINE([HAVE_SEQ_CLIENT_INFO_GET_PID], 1, [alsa-lib supports snd_seq_client_info_get_pid]) -fi -AC_CHECK_LIB([asound], [snd_seq_client_info_get_midi_version], [HAVE_SEQ_CLIENT_INFO_GET_MIDI_VERSION="yes"]) -if test "$HAVE_SEQ_CLIENT_INFO_GET_MIDI_VERSION" = "yes" -a "$have_rawmidi" = "yes"; then - AC_DEFINE([HAVE_SEQ_CLIENT_INFO_GET_MIDI_VERSION], 1, [alsa-lib supports snd_seq_client_info_get_midi_version]) -fi AC_CHECK_LIB([atopology], [snd_tplg_save], [have_topology="yes"], [have_topology="no"])
#
Show the event prefix "SysEx" for UMP SysEx data. Otherwise it's difficult to know what it is.
Fixes: 506097ebb184 ("aseqdump: Show UMP SysEx messages") Signed-off-by: Takashi Iwai tiwai@suse.de --- seq/aseqdump/aseqdump.c | 1 + 1 file changed, 1 insertion(+)
diff --git a/seq/aseqdump/aseqdump.c b/seq/aseqdump/aseqdump.c index f717557824ad..7be988fa094b 100644 --- a/seq/aseqdump/aseqdump.c +++ b/seq/aseqdump/aseqdump.c @@ -673,6 +673,7 @@ static void dump_ump_sysex_event(const unsigned int *ump) int i, length;
printf("Group %2d, ", group_number(snd_ump_msg_group(ump))); + printf("SysEx "); switch (snd_ump_sysex_msg_status(ump)) { case SND_UMP_SYSEX_STATUS_SINGLE: printf("Single ");
Add a new option -u to specify the UMP MIDI1 or MIDI2 mode. As default (-u 0), the program reads the legacy MIDI 1.0 byte stream, while in UMP mode, it reads as UMP packets and send to the target. The UMP packet bytes are encoded in big endian.
Signed-off-by: Takashi Iwai tiwai@suse.de --- seq/aseqsend/aseqsend.1 | 13 ++++++++++--- seq/aseqsend/aseqsend.c | 43 ++++++++++++++++++++++++++++++++++++++++- 2 files changed, 52 insertions(+), 4 deletions(-)
diff --git a/seq/aseqsend/aseqsend.1 b/seq/aseqsend/aseqsend.1 index 340c3292f5ed..febbf55dfb16 100644 --- a/seq/aseqsend/aseqsend.1 +++ b/seq/aseqsend/aseqsend.1 @@ -14,6 +14,10 @@ It can also send any other MIDI commands. Messages to be send can be given in the last argument as hex encoded byte string or can be read from raw binary file. When sending several SysEx messages at once there is a delay of 1ms after each message as deafult and can be set to different value with option -i.
+A client can be specified by its number, its name, or a prefix of its +name. A port is specified by its number; for port 0 of a client, the +":0" part of the port specification can be omitted. + .SH OPTIONS
.TP @@ -44,10 +48,13 @@ Send raw binary data from given file name -i Interval between SysEx messages in miliseconds
+.TP +-u +Specify the MIDI version. 0 for the legacy MIDI 1.0 (default), +1 for UMP MIDI 1.0 protocol and 2 for UMP MIDI 2.0 protocol.
-A client can be specified by its number, its name, or a prefix of its -name. A port is specified by its number; for port 0 of a client, the -":0" part of the port specification can be omitted. +When UMP MIDI 1.0 or MIDI 2.0 protocol is specified, \fBaseqsend\fP +reads the input as raw UMP packets, 4 each byte in big endian.
.SH EXAMPLES
diff --git a/seq/aseqsend/aseqsend.c b/seq/aseqsend/aseqsend.c index 95b0024c0fd6..bd1a221d4149 100644 --- a/seq/aseqsend/aseqsend.c +++ b/seq/aseqsend/aseqsend.c @@ -33,6 +33,7 @@ #include <signal.h> #include <unistd.h> #include <alsa/asoundlib.h> +#include <alsa/ump_msg.h>
typedef unsigned char mbyte_t;
@@ -43,6 +44,7 @@ static char *send_hex; static mbyte_t *send_data; static snd_seq_addr_t addr; static int send_data_length; +static int ump_version;
static void error(const char *format, ...) { @@ -320,6 +322,32 @@ static void send_midi_msg(snd_seq_event_type_t type, mbyte_t *data, int len) snd_seq_drain_output(seq); }
+static int send_ump(const unsigned char *data) +{ + static int ump_len = 0, offset = 0; + unsigned int ump[4]; + snd_seq_ump_event_t ev; + + ump[offset] = (data[0] << 24) | (data[1] << 16) | + (data[2] << 8) | data[3]; + if (!offset) + ump_len = snd_ump_packet_length(snd_ump_msg_type(ump)); + + offset++; + if (offset < ump_len) + return 0; + + snd_seq_ump_ev_clear(&ev); + snd_seq_ev_set_source(&ev, 0); + snd_seq_ev_set_dest(&ev, addr.client, addr.port); + snd_seq_ev_set_direct(&ev); + snd_seq_ev_set_ump_data(&ev, ump, ump_len * 4); + snd_seq_ump_event_output(seq, &ev); + snd_seq_drain_output(seq); + offset = 0; + return ump_len * 4; +} + static int msg_byte_in_range(mbyte_t *data, mbyte_t len) { for (int i = 0; i < len; i++) { @@ -342,7 +370,7 @@ int main(int argc, char *argv[]) int sent_data_c; int k;
- while ((c = getopt(argc, argv, "hi:Vvlp:s:")) != -1) { + while ((c = getopt(argc, argv, "hi:Vvlp:s:u:")) != -1) { switch (c) { case 'h': usage(); @@ -366,6 +394,9 @@ int main(int argc, char *argv[]) case 'i': sysex_interval = atoi(optarg) * 1000; //ms--->us break; + case 'u': + ump_version = atoi(optarg); + break; default: error("Try 'aseqsend -h' for more information."); exit(EXIT_FAILURE); @@ -401,7 +432,11 @@ int main(int argc, char *argv[]) if (!send_data) exit(EXIT_SUCCESS);
+ if (ump_version && (send_data_length % 4) != 0) + fatal("UMP data must be aligned to 4 bytes"); + init_seq(); + snd_seq_set_client_midi_version(seq, ump_version); create_port();
if (snd_seq_parse_address(seq, &addr, port_name) < 0) { @@ -414,6 +449,12 @@ int main(int argc, char *argv[])
while (k < send_data_length) {
+ if (ump_version) { + sent_data_c += send_ump(send_data + k); + k += 4; + continue; + } + if (send_data[k] == 0xF0) {
int c1 = k;
Add the support for long-style options such as --verbose.
Signed-off-by: Takashi Iwai tiwai@suse.de --- seq/aseqsend/aseqsend.1 | 16 ++++++++-------- seq/aseqsend/aseqsend.c | 13 ++++++++++++- 2 files changed, 20 insertions(+), 9 deletions(-)
diff --git a/seq/aseqsend/aseqsend.1 b/seq/aseqsend/aseqsend.1 index febbf55dfb16..626f9ea1fb19 100644 --- a/seq/aseqsend/aseqsend.1 +++ b/seq/aseqsend/aseqsend.1 @@ -21,35 +21,35 @@ name. A port is specified by its number; for port 0 of a client, the .SH OPTIONS
.TP --h +-h, --help Prints a list of options.
.TP --V +-V, --version Prints the current version.
.TP --l +-l, --list Prints a list of possible output ports.
.TP --v +-v, --verbose Prints number of bytes actually sent
.TP --p +-p, --port=client:port Target port by number or name
.TP --s +-s, --file=filename Send raw binary data from given file name
.TP --i +-i, --interval=msec Interval between SysEx messages in miliseconds
.TP --u +-u, --ump=version Specify the MIDI version. 0 for the legacy MIDI 1.0 (default), 1 for UMP MIDI 1.0 protocol and 2 for UMP MIDI 2.0 protocol.
diff --git a/seq/aseqsend/aseqsend.c b/seq/aseqsend/aseqsend.c index bd1a221d4149..d98423c45c7c 100644 --- a/seq/aseqsend/aseqsend.c +++ b/seq/aseqsend/aseqsend.c @@ -362,6 +362,17 @@ static int msg_byte_in_range(mbyte_t *data, mbyte_t len)
int main(int argc, char *argv[]) { + static const struct option long_options[] = { + {"help", 0, NULL, 'h'}, + {"version", 0, NULL, 'V'}, + {"verbose", 0, NULL, 'v'}, + {"list", 0, NULL, 'l'}, + {"port", 1, NULL, 'p'}, + {"file", 1, NULL, 's'}, + {"interval", 1, NULL, 'i'}, + {"ump", 1, NULL, 'u'}, + {0} + }; char c = 0; char do_send_file = 0; char do_port_list = 0; @@ -370,7 +381,7 @@ int main(int argc, char *argv[]) int sent_data_c; int k;
- while ((c = getopt(argc, argv, "hi:Vvlp:s:u:")) != -1) { + while ((c = getopt_long(argc, argv, "hi:Vvlp:s:u:", long_options, NULL)) != -1) { switch (c) { case 'h': usage();
participants (1)
-
Takashi Iwai