ump-utils: fix MIDI 2.0 channel pressure and mask bank bytes

Fix spa_ump_to_midi() MIDI 2.0 channel pressure (0xD0) to emit the
status byte before the data byte. The fallthrough from default caused
the status to be missing, producing 1 byte instead of 2.

Mask bank MSB and LSB with 0x7f in MIDI 2.0 program change conversion
to ensure valid MIDI 1.0 data bytes.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Wim Taymans 2026-05-22 17:05:42 +02:00
parent 552eb1e618
commit 26635056a4
2 changed files with 88 additions and 4 deletions

View file

@ -105,14 +105,14 @@ SPA_API_CONTROL_UMP_UTILS int spa_ump_to_midi(const uint32_t **ump, size_t *ump_
if (*state == 0) {
midi[size++] = (status & 0xf) | 0xb0;
midi[size++] = 0;
midi[size++] = (u[1] >> 8);
midi[size++] = (u[1] >> 8) & 0x7f;
to_consume = 0;
*state = 1;
}
else if (*state == 1) {
midi[size++] = (status & 0xf) | 0xb0;
midi[size++] = 32;
midi[size++] = u[1];
midi[size++] = u[1] & 0x7f;
to_consume = 0;
*state = 2;
}
@ -122,11 +122,13 @@ SPA_API_CONTROL_UMP_UTILS int spa_ump_to_midi(const uint32_t **ump, size_t *ump_
*state = 0;
}
break;
case 0xd0:
midi[size++] = status;
midi[size++] = (u[1] >> 25);
break;
default:
midi[size++] = status;
midi[size++] = (u[0] >> 8) & 0x7f;
SPA_FALLTHROUGH;
case 0xd0:
midi[size++] = (u[1] >> 25);
break;
}