Fix for handling MIDI channels in the bidirectional converter example (#586)

This commit is contained in:
Yuuichi Akagawa 2021-01-29 07:26:53 +09:00
parent b4bbfecd09
commit 66b03d99d6

View file

@ -1,7 +1,7 @@
/* /*
******************************************************************************* *******************************************************************************
* Legacy Serial MIDI and USB Host bidirectional converter * Legacy Serial MIDI and USB Host bidirectional converter
* Copyright (C) 2013-2020 Yuuichi Akagawa * Copyright (C) 2013-2021 Yuuichi Akagawa
* *
* for use with Arduino MIDI library * for use with Arduino MIDI library
* https://github.com/FortySevenEffects/arduino_midi_library/ * https://github.com/FortySevenEffects/arduino_midi_library/
@ -44,6 +44,7 @@ MIDI_CREATE_DEFAULT_INSTANCE();
////////////////////////// //////////////////////////
USB Usb; USB Usb;
USBHub Hub1(&Usb);
USBH_MIDI Midi(&Usb); USBH_MIDI Midi(&Usb);
void MIDI_poll(); void MIDI_poll();
@ -87,6 +88,9 @@ void loop()
//SysEx is handled by event. //SysEx is handled by event.
break; break;
default : default :
if( msg[0] < 0xf0 ){
msg[0] |= MIDI.getChannel() - 1;
}
msg[1] = MIDI.getData1(); msg[1] = MIDI.getData1();
msg[2] = MIDI.getData2(); msg[2] = MIDI.getData2();
Midi.SendData(msg, 0); Midi.SendData(msg, 0);