Arduino: 1.6.13 (Windows 10), Board: "Arduino/Genuino Uno"
C:\Users\Nerdinator\Documents\Arduino\libraries\USBH_MIDI-IOP_ArduinoMIDI\examples\bidrectional_converter\bidrectional_converter.ino: In function 'void setup()':
bidrectional_converter:52: error: 'MIDI' was not declared in this scope
MIDI.begin(MIDI_CHANNEL_OMNI);
^
C:\Users\Nerdinator\Documents\Arduino\libraries\USBH_MIDI-IOP_ArduinoMIDI\examples\bidrectional_converter\bidrectional_converter.ino: In function 'void loop()':
bidrectional_converter:74: error: 'MIDI' was not declared in this scope
if (MIDI.read()) {
^
C:\Users\Nerdinator\Documents\Arduino\libraries\USBH_MIDI-IOP_ArduinoMIDI\examples\bidrectional_converter\bidrectional_converter.ino: In function 'void MIDI_poll()':
bidrectional_converter:34: error: 'MIDI_DEFAULT_SERIAL_PORT' was not declared in this scope
#define _MIDI_SERIAL_PORT MIDI_DEFAULT_SERIAL_PORT
^
C:\Users\Nerdinator\Documents\Arduino\libraries\USBH_MIDI-IOP_ArduinoMIDI\examples\bidrectional_converter\bidrectional_converter.ino:98:7: note: in expansion of macro '_MIDI_SERIAL_PORT'
_MIDI_SERIAL_PORT.write(outBuf, size);
^
exit status 1
'MIDI' was not declared in this scope
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
trying to make a usb to midi host. heres the sketch:
/*
*******************************************************************************
* Legacy Serial MIDI and USB Host bidirectional converter
* Copyright 2013-2014 Yuuichi Akagawa
*
* for use with USB Host Shield 2.0 from Circuitsathome.com
* https://github.com/felis/USB_Host_Shield_2.0
* and Arduino MIDI library
* http://playground.arduino.cc/Main/MIDILibrary
*******************************************************************************
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*******************************************************************************
*/
#include <MIDI.h>
#include <Usb.h>
#include <usbh_midi.h>
//Workaround for Arduino MIDI library v4.0 compatibility
#ifdef USE_SERIAL_PORT
#define _MIDI_SERIAL_PORT USE_SERIAL_PORT
#else
#define _MIDI_SERIAL_PORT MIDI_DEFAULT_SERIAL_PORT
#endif
//////////////////////////
// MIDI Pin assign
// 2 : GND
// 4 : +5V(Vcc) with 220ohm
// 5 : TX
//////////////////////////
USB Usb;
USBH_MIDI Midi(&Usb);
void MIDI_poll();
void doDelay(unsigned long t1, unsigned long t2, unsigned long delayTime);
void setup()
{
MIDI.begin(MIDI_CHANNEL_OMNI);
//Workaround for non UHS2.0 Shield
pinMode(7,OUTPUT);
digitalWrite(7,HIGH);
if (Usb.Init() == -1) {
while(1); //halt
}//if (Usb.Init() == -1...
delay( 200 );
}
void loop()
{
unsigned long t1;
uint8_t msg[4];
Usb.Task();
t1 = micros();
if( Usb.getUsbTaskState() == USB_STATE_RUNNING )
{
MIDI_poll();
if (MIDI.read()) {
msg[0] = MIDI.getType();
if( msg[0] == 0xf0 ) { //SysEX
//TODO
//SysEx implementation is not yet.
}else{
msg[1] = MIDI.getData1();
msg[2] = MIDI.getData2();
Midi.SendData(msg, 0);
}
}
}
//delay(1ms)
doDelay(t1, micros(), 1000);
}
// Poll USB MIDI Controler and send to serial MIDI
void MIDI_poll()
{
byte outBuf[ 3 ];
uint8_t size;
if( (size=Midi.RcvData(outBuf)) > 0 ){
//MIDI Output
_MIDI_SERIAL_PORT.write(outBuf, size);
}
}
// Delay time (max 16383 us)
void doDelay(unsigned long t1, unsigned long t2, unsigned long delayTime)
{
unsigned long t3;
if( t1 > t2 ){
t3 = (4294967295 - t1 + t2);
}else{
t3 = t2 - t1;
}
if( t3 < delayTime ){
delayMicroseconds(delayTime - t3);
}
}