Fix for handling MIDI channels in the bidirectional converter example
This commit is contained in:
Kristian Sloth Lauszus 2021-02-01 17:39:37 +01:00 committed by GitHub
commit e10f89da72
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

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,11 @@ void loop()
//SysEx is handled by event. //SysEx is handled by event.
break; break;
default : default :
// If this is a channel messages, set the channel number.
if( msg[0] < 0xf0 ){
// The getchannel() returns 1-16, but the MIDI status byte starts at 0.
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);