From be6356d847a780539431de8afcab40b57a8df9cb Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 27 Jun 2024 13:24:11 +0200 Subject: [PATCH] aseqdump: Refactor UMP SysEx dump A slightly better version. The extraction of a SysEx byte from a UMP packet is more complicated than wished, in anyway. Signed-off-by: Takashi Iwai --- seq/aseqdump/aseqdump.c | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/seq/aseqdump/aseqdump.c b/seq/aseqdump/aseqdump.c index e1aea4c..b813711 100644 --- a/seq/aseqdump/aseqdump.c +++ b/seq/aseqdump/aseqdump.c @@ -668,9 +668,16 @@ static void dump_ump_system_event(const unsigned int *ump) } } +static unsigned char ump_sysex7_data(const unsigned int *ump, + unsigned int offset) +{ + offset += 2; + return (ump[offset / 4] >> ((3 - (offset & 3)) * 8)) & 0xff; +} + static void dump_ump_sysex_event(const unsigned int *ump) { - int i, offset, length; + int i, length; printf("Group %2d, ", group_number(snd_ump_msg_group(ump))); switch (snd_ump_sysex_msg_status(ump)) { @@ -693,18 +700,8 @@ static void dump_ump_sysex_event(const unsigned int *ump) length = snd_ump_sysex_msg_length(ump); printf(" length %d ", length); - offset = 24; - for (i = 0; i < length; i++) { - if (i) - printf(":"); - printf("%02x", (*ump >> (32 - offset)) & 0x7f); - if (offset < 32) { - offset += 8; - } else { - ump++; - offset = 8; - } - } + for (i = 0; i < length; i++) + printf("%s%02x", i ? ":" : "", ump_sysex7_data(ump, i)); printf("\n"); }