Skip to contentSkip to conversation

aseqdump: Correct wrong channel number

PATCH New Takashi Iwai 1 participant 2 messages Aug 28, 2023

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 aseqdump: Correct wrong channel number

Correct the wrong value shown in MIDI2 default output (status instead of channel). Also adjust the printf formats to use %2d consistently for the channel numbers.

---
 seq/aseqdump/aseqdump.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)
seq/aseqdump/aseqdump.c +8 -8
index f3eebc73a9f4..a15e0752f0f1 100644
@@ -368,29 +368,29 @@ static void dump_ump_midi2_event(const unsigned int *ump)
 	printf("Group %2d, ", group);
 	switch (status) {
 	case SND_UMP_MSG_PER_NOTE_RCC:
-		printf("Per-note RCC           %2u, note %u, index %u, value 0x%x",
+		printf("Per-note RCC           %2d, note %u, index %u, value 0x%x",
 		       channel, m->per_note_rcc.note,
 		       m->per_note_rcc.index, m->per_note_rcc.data);
 		break;
 	case SND_UMP_MSG_PER_NOTE_ACC:
-		printf("Per-note ACC           %2u, note %u, index %u, value 0x%x",
+		printf("Per-note ACC           %2d, note %u, index %u, value 0x%x",
 		       channel, m->per_note_acc.note,
 		       m->per_note_acc.index, m->per_note_acc.data);
 		break;
 	case SND_UMP_MSG_RPN:
-		printf("RPN                    %2u, bank %u:%u, value 0x%x",
+		printf("RPN                    %2d, bank %u:%u, value 0x%x",
 		       channel, m->rpn.bank, m->rpn.index, m->rpn.data);
 		break;
 	case SND_UMP_MSG_NRPN:
-		printf("NRPN                   %2u, bank %u:%u, value 0x%x",
+		printf("NRPN                   %2d, bank %u:%u, value 0x%x",
 		       channel, m->rpn.bank, m->rpn.index, m->rpn.data);
 		break;
 	case SND_UMP_MSG_RELATIVE_RPN:
-		printf("relative RPN           %2u, bank %u:%u, value 0x%x",
+		printf("relative RPN           %2d, bank %u:%u, value 0x%x",
 		       channel, m->rpn.bank, m->rpn.index, m->rpn.data);
 		break;
 	case SND_UMP_MSG_RELATIVE_NRPN:
-		printf("relative NRP           %2u, bank %u:%u, value 0x%x",
+		printf("relative NRP           %2d, bank %u:%u, value 0x%x",
 		       channel, m->rpn.bank, m->rpn.index, m->rpn.data);
 		break;
 	case SND_UMP_MSG_PER_NOTE_PITCHBEND:
@@ -437,8 +437,8 @@ static void dump_ump_midi2_event(const unsigned int *ump)
 		       channel, m->per_note_mgmt.flags);
 		break;
 	default:
-		printf("UMP MIDI2 event: status = %d, channel = %x, 0x%08x",
-		       status, status, *ump);
+		printf("UMP MIDI2 event: status = %d, channel = %d, 0x%08x",
+		       status, channel, *ump);
 		break;
 	}
 	printf("\n");
Signature · 1 line
2.35.3
#1 lore raw

PATCH 2/2 aseqdump: Add options to switch view mode

This patch adds to switch the operation mode of aseqdump to specify how the values are shown. Namely, it allows to show the MIDI 2.0 values in two more different ways: compatible "normalized" view and percentage view, in addition to the default "raw" view.

The "raw" view mode just shows the value found in the event almost as is. The MIDI 2.0 values are shown in 16 or 32bit hex numbers. The channel and UMP group numbers are 0-based, taking from 0 to 15.

OTOH, in the normalized view, the 16bit or 32bit velocity and data values of MIDI 2.0 are normalized to the value fit in MIDI 1.0, i.e. from 0 to 127, but with decimal points. Similarly, the pitch wheel values are normalized between -8192 to 8191.
Also, the channel numbers and UMP group numbers are 1-based, taking from 1 to 16.

In the percentage view, the velocity and data values are normalized and shown in percentage, from 0% to 100%. The pitch wheel is normalized from -100% to 100%. The channel and UMP groups are 1-based as well as in normalized view mode.

---
 seq/aseqdump/aseqdump.1 |  25 ++++
 seq/aseqdump/aseqdump.c | 252 +++++++++++++++++++++++++++++++++-------
 2 files changed, 234 insertions(+), 43 deletions(-)
seq/aseqdump/aseqdump.1 +25 -0
index 6f7904159b90..7b389bd769ae 100644
@@ -36,6 +36,31 @@ Sets the client MIDI version.
 .I \-r,\-\-raw
 Suppress the automatic conversion of events among UMP and legacy clients.
 
+.TP
+.I \-R,\-\-raw-view
+Shows the raw values as is.
+The channel numbers and UMP group numbers are 0-based in this mode.
+This is the default behavior.
+
+.TP
+.I \-N,\-\-normalized-view
+Shows the normalized values to be aligned with MIDI 1.0.
+The channel numbers and UMP group numbers are shown as 1-based values,
+i.e. 1 is the lowest number.
+The velocity and data values are normalized between 0 and 127.
+The values for MIDI 2.0 are shown with two digits decimal points (from
+0.00 to 127.00).
+The pitch wheel is normalized between -8192 to 8192, too.
+
+.TP
+.I \-P,\-\-percent-view
+Shows the values in percentage.
+The channel numbers and UMP group numbers are shown as 1-based values
+in this mode, too.
+The velocity and data values are normalized between 0 and 100%, shown
+with two digits decimal points.
+The pitch wheel is normalized between -100% to 100%, too.
+
 .TP
 .I \-p,\-\-port=client:port,...
 Sets the sequencer port(s) from which events are received.
seq/aseqdump/aseqdump.c +209 -43

388 lines not on this page · raw message

Signature · 1 line
2.35.3