From 66b03d99d6b67878add6ad1c4eca90609b5d223f Mon Sep 17 00:00:00 2001 From: Yuuichi Akagawa Date: Fri, 29 Jan 2021 07:26:53 +0900 Subject: [PATCH 1/3] Fix for handling MIDI channels in the bidirectional converter example (#586) --- .../bidirectional_converter/bidirectional_converter.ino | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/examples/USBH_MIDI/bidirectional_converter/bidirectional_converter.ino b/examples/USBH_MIDI/bidirectional_converter/bidirectional_converter.ino index b752a05f..0b9854d5 100644 --- a/examples/USBH_MIDI/bidirectional_converter/bidirectional_converter.ino +++ b/examples/USBH_MIDI/bidirectional_converter/bidirectional_converter.ino @@ -1,7 +1,7 @@ /* ******************************************************************************* * 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 * https://github.com/FortySevenEffects/arduino_midi_library/ @@ -44,6 +44,7 @@ MIDI_CREATE_DEFAULT_INSTANCE(); ////////////////////////// USB Usb; +USBHub Hub1(&Usb); USBH_MIDI Midi(&Usb); void MIDI_poll(); @@ -87,6 +88,9 @@ void loop() //SysEx is handled by event. break; default : + if( msg[0] < 0xf0 ){ + msg[0] |= MIDI.getChannel() - 1; + } msg[1] = MIDI.getData1(); msg[2] = MIDI.getData2(); Midi.SendData(msg, 0); From e81b04519c6c1dbd6641495a3f0dbd5ca4e9e810 Mon Sep 17 00:00:00 2001 From: Yuuichi Akagawa Date: Fri, 29 Jan 2021 07:33:17 +0900 Subject: [PATCH 2/3] Hub commented out --- .../bidirectional_converter/bidirectional_converter.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/USBH_MIDI/bidirectional_converter/bidirectional_converter.ino b/examples/USBH_MIDI/bidirectional_converter/bidirectional_converter.ino index 0b9854d5..25f8e00b 100644 --- a/examples/USBH_MIDI/bidirectional_converter/bidirectional_converter.ino +++ b/examples/USBH_MIDI/bidirectional_converter/bidirectional_converter.ino @@ -44,7 +44,7 @@ MIDI_CREATE_DEFAULT_INSTANCE(); ////////////////////////// USB Usb; -USBHub Hub1(&Usb); +//USBHub Hub1(&Usb); USBH_MIDI Midi(&Usb); void MIDI_poll(); From ecce90052c709d7efea3e5b4a28e2fbe1c425864 Mon Sep 17 00:00:00 2001 From: Yuuichi Akagawa Date: Tue, 2 Feb 2021 00:16:16 +0900 Subject: [PATCH 3/3] add comment --- .../bidirectional_converter/bidirectional_converter.ino | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/examples/USBH_MIDI/bidirectional_converter/bidirectional_converter.ino b/examples/USBH_MIDI/bidirectional_converter/bidirectional_converter.ino index 25f8e00b..18c7cc8a 100644 --- a/examples/USBH_MIDI/bidirectional_converter/bidirectional_converter.ino +++ b/examples/USBH_MIDI/bidirectional_converter/bidirectional_converter.ino @@ -88,8 +88,10 @@ void loop() //SysEx is handled by event. break; default : + // If this is a channel messages, set the channel number. if( msg[0] < 0xf0 ){ - msg[0] |= MIDI.getChannel() - 1; + // The getchannel() returns 1-16, but the MIDI status byte starts at 0. + msg[0] |= MIDI.getChannel() - 1; } msg[1] = MIDI.getData1(); msg[2] = MIDI.getData2();