Skip to content

Commit 6b4838c

Browse files
authored
Merge pull request hathach#1910 from rppicomidi/fix-1909
Fix issue 1909
2 parents e3be8a0 + fde7577 commit 6b4838c

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/class/midi/midi_device.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -261,11 +261,11 @@ uint32_t tud_midi_n_stream_write(uint8_t itf, uint8_t cable_num, uint8_t const*
261261
stream->buffer[1] = data;
262262

263263
// Check to see if we're still in a SysEx transmit.
264-
if ( stream->buffer[0] == MIDI_CIN_SYSEX_START )
264+
if ( ((stream->buffer[0]) & 0xF) == MIDI_CIN_SYSEX_START )
265265
{
266266
if ( data == MIDI_STATUS_SYSEX_END )
267267
{
268-
stream->buffer[0] = MIDI_CIN_SYSEX_END_1BYTE;
268+
stream->buffer[0] = (uint8_t) ((cable_num << 4) | MIDI_CIN_SYSEX_END_1BYTE);
269269
stream->total = 2;
270270
}
271271
else
@@ -308,6 +308,7 @@ uint32_t tud_midi_n_stream_write(uint8_t itf, uint8_t cable_num, uint8_t const*
308308
stream->buffer[0] = MIDI_CIN_SYSEX_END_1BYTE;
309309
stream->total = 2;
310310
}
311+
stream->buffer[0] |= (uint8_t)(cable_num << 4);
311312
}
312313
else
313314
{
@@ -328,9 +329,9 @@ uint32_t tud_midi_n_stream_write(uint8_t itf, uint8_t cable_num, uint8_t const*
328329
stream->index++;
329330

330331
// See if this byte ends a SysEx.
331-
if ( stream->buffer[0] == MIDI_CIN_SYSEX_START && data == MIDI_STATUS_SYSEX_END )
332+
if ( (stream->buffer[0] & 0xF) == MIDI_CIN_SYSEX_START && data == MIDI_STATUS_SYSEX_END )
332333
{
333-
stream->buffer[0] = MIDI_CIN_SYSEX_START + (stream->index - 1);
334+
stream->buffer[0] = (uint8_t) ((cable_num << 4) | (MIDI_CIN_SYSEX_START + (stream->index - 1)));
334335
stream->total = stream->index;
335336
}
336337
}

0 commit comments

Comments
 (0)