@ -28,6 +28,9 @@
# include <SD.h>
# include <SD.h>
# include <MIDI.h>
# include <MIDI.h>
# include <EEPROM.h>
# include <EEPROM.h>
# if defined(USBCON)
# include <midi_UsbTransport.h>
# endif
# include <limits.h>
# include <limits.h>
# include "dexed.h"
# include "dexed.h"
# include "dexed_sysex.h"
# include "dexed_sysex.h"
@ -131,6 +134,12 @@ MIDI_CREATE_INSTANCE(HardwareSerial, MIDI_DEVICE, midi_serial);
USBHost usb_host ;
USBHost usb_host ;
MIDIDevice midi_usb ( usb_host ) ;
MIDIDevice midi_usb ( usb_host ) ;
# endif
# endif
# if defined(USBCON)
static const unsigned sUsbTransportBufferSize = 16 ;
typedef midi : : UsbTransport < sUsbTransportBufferSize > UsbTransport ;
UsbTransport sUsbTransport ;
MIDI_CREATE_INSTANCE ( UsbTransport , sUsbTransport , midi_onboard_usb ) ;
# endif
# ifdef TEST_NOTE
# ifdef TEST_NOTE
IntervalTimer sched_note_on ;
IntervalTimer sched_note_on ;
@ -171,6 +180,12 @@ void setup()
Serial . println ( F ( " USB-MIDI enabled. " ) ) ;
Serial . println ( F ( " USB-MIDI enabled. " ) ) ;
# endif
# endif
// check for onboard USB-MIDI
# if defined(USBCON)
midi_onboard_usb . begin ( ) ;
Serial . println ( F ( " Onboard USB-MIDI enabled. " ) ) ;
# endif
# ifdef MIDI_DEVICE
# ifdef MIDI_DEVICE
// Start serial MIDI
// Start serial MIDI
midi_serial . begin ( DEFAULT_MIDI_CHANNEL ) ;
midi_serial . begin ( DEFAULT_MIDI_CHANNEL ) ;
@ -370,6 +385,25 @@ void loop()
void handle_input ( void )
void handle_input ( void )
{
{
# if defined(USBCON)
while ( midi_onboard_usb . read ( ) )
{
# ifdef DEBUG
Serial . println ( F ( " [ONBOARD-MIDI-USB] " ) ) ;
# endif
if ( midi_onboard_usb . getType ( ) > = 0xf0 ) // SysEX
{
handle_sysex_parameter ( midi_onboard_usb . getSysExArray ( ) , midi_onboard_usb . getSysExArrayLength ( ) ) ;
}
else
{
queue_midi_event ( midi_onboard_usb . getType ( ) , midi_onboard_usb . getData1 ( ) , midi_onboard_usb . getData2 ( ) )
# ifdef MIDI_MERGE_THRU
midi_serial . send ( midi_serial . getType ( ) , midi_serial . getData1 ( ) , midi_serial . getData2 ( ) , midi_serial . getChannel ( ) ) ;
# endif
}
}
# endif
# ifdef USE_ONBOARD_USB_HOST
# ifdef USE_ONBOARD_USB_HOST
usb_host . Task ( ) ;
usb_host . Task ( ) ;
while ( midi_usb . read ( ) )
while ( midi_usb . read ( ) )
@ -381,8 +415,13 @@ void handle_input(void)
{
{
handle_sysex_parameter ( midi_usb . getSysExArray ( ) , midi_usb . getSysExArrayLength ( ) ) ;
handle_sysex_parameter ( midi_usb . getSysExArray ( ) , midi_usb . getSysExArrayLength ( ) ) ;
}
}
else if ( queue_midi_event ( midi_usb . getType ( ) , midi_usb . getData1 ( ) , midi_usb . getData2 ( ) ) )
else
return ;
{
queue_midi_event ( midi_usb . getType ( ) , midi_usb . getData1 ( ) , midi_usb . getData2 ( ) ) ;
# ifdef MIDI_MERGE_THRU
midi_serial . send ( midi_serial . getType ( ) , midi_serial . getData1 ( ) , midi_serial . getData2 ( ) , midi_serial . getChannel ( ) ) ;
# endif
}
}
}
# endif
# endif
# ifdef MIDI_DEVICE
# ifdef MIDI_DEVICE
@ -395,8 +434,13 @@ void handle_input(void)
{
{
handle_sysex_parameter ( midi_serial . getSysExArray ( ) , midi_serial . getSysExArrayLength ( ) ) ;
handle_sysex_parameter ( midi_serial . getSysExArray ( ) , midi_serial . getSysExArrayLength ( ) ) ;
}
}
else if ( queue_midi_event ( midi_serial . getType ( ) , midi_serial . getData1 ( ) , midi_serial . getData2 ( ) ) )
else
return ;
{
queue_midi_event ( midi_serial . getType ( ) , midi_serial . getData1 ( ) , midi_serial . getData2 ( ) ) ;
# ifdef MIDI_MERGE_THRU
midi_serial . send ( midi_serial . getType ( ) , midi_serial . getData1 ( ) , midi_serial . getData2 ( ) , midi_serial . getChannel ( ) ) ;
# endif
}
}
}
# endif
# endif
}
}