tttapa / Control-Surface

Arduino library for creating MIDI controllers and other MIDI devices.
GNU General Public License v3.0
1.28k stars 141 forks source link

Platformio error "MIDIUSB can only be used with an USB MCU" #309

Open xabadabazinho opened 4 years ago

xabadabazinho commented 4 years ago

Hi, thanks for the fastastic library. I´m compiling without problems in Arduino IDE, but having erros in Platformio/VSC using BLE with ESP32 and Control Surface@^1.2.0-4:

Platformio.ini

[env:esp32doit-devkit-v1]
platform = espressif32
board = esp32doit-devkit-v1
framework = arduino
lib_deps = 
    tttapa/Control Surface@^1.2.0-4
monitor_speed = 115200

===================================================== The code

#include <Arduino.h>
#include <Control_Surface.h>
#include <MIDI_Interfaces/BluetoothMIDI_Interface.hpp>

BluetoothMIDI_Interface midi;

void setup()
{
    Serial.begin(115200);
    midi.begin();
}

using namespace MIDI_Notes;

const MIDIAddress address = {note(C, 4), CHANNEL_1};
const uint8_t velocity = 0x7F;

void loop()
{
    midi.sendNoteOn(address, velocity);
    midi.sendNoteOff(address, velocity);
    delay(500);
    midi.update(); // Handle or discard MIDI input
}

======================================================= errors:

In file included from .pio\libdeps\esp32doit-devkit-v1\MIDIUSB\src\MIDIUSB.cpp:17:0:
.pio\libdeps\esp32doit-devkit-v1\MIDIUSB\src\MIDIUSB.h:18:2: error: #error MIDIUSB can only be used with an USB MCU.
 #error MIDIUSB can only be used with an USB MCU.
  ^
In file included from .pio\libdeps\esp32doit-devkit-v1\MIDIUSB\src\MIDIUSB.cpp:17:0:
.pio\libdeps\esp32doit-devkit-v1\MIDIUSB\src\MIDIUSB.h:74:2: error: #error "Unsupported architecture"
 #error "Unsupported architecture"
Compiling .pio\build\esp32doit-devkit-v1\libc83\BLE\BLE2902.cpp.o
  ^
.pio\libdeps\esp32doit-devkit-v1\MIDIUSB\src\MIDIUSB.h:125:2: error: 'EndpointDescriptor' does not name a type
  EndpointDescriptor len;  // 9
  ^
.pio\libdeps\esp32doit-devkit-v1\MIDIUSB\src\MIDIUSB.h:154:2: error: 'IADDescriptor' does not name a type     
  IADDescriptor                      iad;
  ^
.pio\libdeps\esp32doit-devkit-v1\MIDIUSB\src\MIDIUSB.h:156:2: error: 'InterfaceDescriptor' does not name a type
  InterfaceDescriptor                Audio_ControlInterface;
  ^
.pio\libdeps\esp32doit-devkit-v1\MIDIUSB\src\MIDIUSB.h:160:2: error: 'InterfaceDescriptor' does not name a type
  InterfaceDescriptor                Audio_StreamInterface;
  ^
.pio\libdeps\esp32doit-devkit-v1\MIDIUSB\src\MIDIUSB.h:208:1: error: expected class-name before '{' token
 {
 ^
.pio\libdeps\esp32doit-devkit-v1\MIDIUSB\src\MIDIUSB.h:213:2: error: 'EPTYPE_DESCRIPTOR_SIZE' does not name a 
type
  EPTYPE_DESCRIPTOR_SIZE epType[2];   ///< Container that defines the two bulk MIDI IN/OUT endpoints types
  ^
.pio\libdeps\esp32doit-devkit-v1\MIDIUSB\src\MIDIUSB.h:222:21: error: 'USBSetup' has not been declared
   int getDescriptor(USBSetup& setup);
                     ^
.pio\libdeps\esp32doit-devkit-v1\MIDIUSB\src\MIDIUSB.h:224:14: error: 'USBSetup' has not been declared
   bool setup(USBSetup& setup);
Archiving .pio\build\esp32doit-devkit-v1\lib9f0\libSPI.a
              ^
.pio\libdeps\esp32doit-devkit-v1\MIDIUSB\src\MIDIUSB.cpp:30:30: error: 'MIDI_BUFFER_SIZE' was not declared in 
this scope
  midiEventPacket_t midiEvent[MIDI_BUFFER_SIZE];
                              ^
.pio\libdeps\esp32doit-devkit-v1\MIDIUSB\src\MIDIUSB.cpp:35:51: error: braces around scalar initializer for type 'volatile uint32_t {aka volatile unsigned int}'
 ring_bufferMIDI midi_rx_buffer = {{0,0,0,0 }, 0, 0};
                                                   ^
.pio\libdeps\esp32doit-devkit-v1\MIDIUSB\src\MIDIUSB.cpp: In member function 'int MIDI_::getInterface(uint8_t*)':
.pio\libdeps\esp32doit-devkit-v1\MIDIUSB\src\MIDIUSB.cpp:19:28: error: 'pluggedInterface' was not declared in 
this scope
 #define MIDI_AC_INTERFACE  pluggedInterface // MIDI AC Interface
                            ^
.pio\libdeps\esp32doit-devkit-v1\MIDIUSB\src\MIDIUSB.cpp:44:9: note: in expansion of macro 'MIDI_AC_INTERFACE'
   D_IAD(MIDI_AC_INTERFACE, 2, MIDI_AUDIO, MIDI_AUDIO_CONTROL, 0),
         ^
.pio\libdeps\esp32doit-devkit-v1\MIDIUSB\src\MIDIUSB.cpp:44:64: error: 'D_IAD' was not declared in this scope
   D_IAD(MIDI_AC_INTERFACE, 2, MIDI_AUDIO, MIDI_AUDIO_CONTROL, 0),
                                                                ^
.pio\libdeps\esp32doit-devkit-v1\MIDIUSB\src\MIDIUSB.cpp:45:66: error: 'D_INTERFACE' was not declared in this 
scope
   D_INTERFACE(MIDI_AC_INTERFACE,0,MIDI_AUDIO,MIDI_AUDIO_CONTROL,0),
                                                                  ^
In file included from .pio\libdeps\esp32doit-devkit-v1\MIDIUSB\src\MIDIUSB.cpp:17:0:
.pio\libdeps\esp32doit-devkit-v1\MIDIUSB\src\MIDIUSB.cpp:22:27: error: 'pluggedEndpoint' was not declared in this scope
 #define MIDI_ENDPOINT_OUT pluggedEndpoint
                           ^
.pio\libdeps\esp32doit-devkit-v1\MIDIUSB\src\MIDIUSB.h:187:10: note: in definition of macro 'D_MIDI_JACK_EP'
  { 9, 5, _addr,_attr,_packetSize, 0, 0, 0}
          ^
.pio\libdeps\esp32doit-devkit-v1\MIDIUSB\src\MIDIUSB.cpp:53:35: note: in expansion of macro 'MIDI_ENDPOINT_OUT'
   D_MIDI_JACK_EP(USB_ENDPOINT_OUT(MIDI_ENDPOINT_OUT),USB_ENDPOINT_TYPE_BULK,MIDI_BUFFER_SIZE),
                                   ^
.pio\libdeps\esp32doit-devkit-v1\MIDIUSB\src\MIDIUSB.cpp:53:52: error: 'USB_ENDPOINT_OUT' was not declared in 
this scope
   D_MIDI_JACK_EP(USB_ENDPOINT_OUT(MIDI_ENDPOINT_OUT),USB_ENDPOINT_TYPE_BULK,MIDI_BUFFER_SIZE),
                                                    ^
.pio\libdeps\esp32doit-devkit-v1\MIDIUSB\src\MIDIUSB.h:187:10: note: in definition of macro 'D_MIDI_JACK_EP'
  { 9, 5, _addr,_attr,_packetSize, 0, 0, 0}
          ^
.pio\libdeps\esp32doit-devkit-v1\MIDIUSB\src\MIDIUSB.cpp:53:54: error: 'USB_ENDPOINT_TYPE_BULK' was not declared in this scope
   D_MIDI_JACK_EP(USB_ENDPOINT_OUT(MIDI_ENDPOINT_OUT),USB_ENDPOINT_TYPE_BULK,MIDI_BUFFER_SIZE),
                                                      ^
.pio\libdeps\esp32doit-devkit-v1\MIDIUSB\src\MIDIUSB.h:187:16: note: in definition of macro 'D_MIDI_JACK_EP'
  { 9, 5, _addr,_attr,_packetSize, 0, 0, 0}
                ^
.pio\libdeps\esp32doit-devkit-v1\MIDIUSB\src\MIDIUSB.cpp:53:77: error: 'MIDI_BUFFER_SIZE' was not declared in 
this scope
   D_MIDI_JACK_EP(USB_ENDPOINT_OUT(MIDI_ENDPOINT_OUT),USB_ENDPOINT_TYPE_BULK,MIDI_BUFFER_SIZE),
                                                                             ^
.pio\libdeps\esp32doit-devkit-v1\MIDIUSB\src\MIDIUSB.h:187:22: note: in definition of macro 'D_MIDI_JACK_EP'
  { 9, 5, _addr,_attr,_packetSize, 0, 0, 0}
                      ^
.pio\libdeps\esp32doit-devkit-v1\MIDIUSB\src\MIDIUSB.cpp:55:50: error: 'USB_ENDPOINT_IN' was not declared in this scope
   D_MIDI_JACK_EP(USB_ENDPOINT_IN(MIDI_ENDPOINT_IN),USB_ENDPOINT_TYPE_BULK,MIDI_BUFFER_SIZE),
                                                  ^
.pio\libdeps\esp32doit-devkit-v1\MIDIUSB\src\MIDIUSB.h:187:10: note: in definition of macro 'D_MIDI_JACK_EP'
  { 9, 5, _addr,_attr,_packetSize, 0, 0, 0}
          ^
.pio\libdeps\esp32doit-devkit-v1\MIDIUSB\src\MIDIUSB.cpp:58:67: error: 'USB_SendControl' was not declared in this scope
  return USB_SendControl(0, &_midiInterface, sizeof(_midiInterface));
                                                                   ^
.pio\libdeps\esp32doit-devkit-v1\MIDIUSB\src\MIDIUSB.cpp: At global scope:
.pio\libdeps\esp32doit-devkit-v1\MIDIUSB\src\MIDIUSB.cpp:61:19: error: 'bool MIDI_::setup' is not a static data member of 'class MIDI_'
 bool MIDI_::setup(USBSetup& setup __attribute__((unused)))
                   ^
.pio\libdeps\esp32doit-devkit-v1\MIDIUSB\src\MIDIUSB.cpp:61:19: error: 'USBSetup' was not declared in this scope
.pio\libdeps\esp32doit-devkit-v1\MIDIUSB\src\MIDIUSB.cpp:62:1: error: expected ',' or ';' before '{' token
 {
 ^
.pio\libdeps\esp32doit-devkit-v1\MIDIUSB\src\MIDIUSB.cpp:67:26: error: 'int MIDI_::getDescriptor' is not a static data member of 'class MIDI_'
 int MIDI_::getDescriptor(USBSetup& setup __attribute__((unused)))
                          ^
.pio\libdeps\esp32doit-devkit-v1\MIDIUSB\src\MIDIUSB.cpp:67:26: error: 'USBSetup' was not declared in this scope
.pio\libdeps\esp32doit-devkit-v1\MIDIUSB\src\MIDIUSB.cpp:68:1: error: expected ',' or ';' before '{' token
 {
 ^
.pio\libdeps\esp32doit-devkit-v1\MIDIUSB\src\MIDIUSB.cpp: In member function 'void MIDI_::accept()':
.pio\libdeps\esp32doit-devkit-v1\MIDIUSB\src\MIDIUSB.cpp:81:44: error: 'MIDI_BUFFER_SIZE' was not declared in 
this scope
  uint32_t i = (uint32_t)(buffer->head+1) % MIDI_BUFFER_SIZE;
                                            ^
.pio\libdeps\esp32doit-devkit-v1\MIDIUSB\src\MIDIUSB.cpp:22:27: error: 'pluggedEndpoint' was not declared in this scope
 #define MIDI_ENDPOINT_OUT pluggedEndpoint
                           ^
.pio\libdeps\esp32doit-devkit-v1\MIDIUSB\src\MIDIUSB.cpp:25:17: note: in expansion of macro 'MIDI_ENDPOINT_OUT'
 #define MIDI_RX MIDI_ENDPOINT_OUT
                 ^
.pio\libdeps\esp32doit-devkit-v1\MIDIUSB\src\MIDIUSB.cpp:90:22: note: in expansion of macro 'MIDI_RX'
   if (!USB_Available(MIDI_RX)) {
                      ^
.pio\libdeps\esp32doit-devkit-v1\MIDIUSB\src\MIDIUSB.cpp:90:29: error: 'USB_Available' was not declared in this scope
   if (!USB_Available(MIDI_RX)) {
                             ^
.pio\libdeps\esp32doit-devkit-v1\MIDIUSB\src\MIDIUSB.cpp:22:27: error: 'pluggedEndpoint' was not declared in this scope
 #define MIDI_ENDPOINT_OUT pluggedEndpoint
                           ^
.pio\libdeps\esp32doit-devkit-v1\MIDIUSB\src\MIDIUSB.cpp:25:17: note: in expansion of macro 'MIDI_ENDPOINT_OUT'
 #define MIDI_RX MIDI_ENDPOINT_OUT
                 ^
.pio\libdeps\esp32doit-devkit-v1\MIDIUSB\src\MIDIUSB.cpp:96:16: note: in expansion of macro 'MIDI_RX'
   c = USB_Recv(MIDI_RX, &event, sizeof(event) );
                ^
.pio\libdeps\esp32doit-devkit-v1\MIDIUSB\src\MIDIUSB.cpp:96:47: error: 'USB_Recv' was not declared in this scope
   c = USB_Recv(MIDI_RX, &event, sizeof(event) );
                                               ^
.pio\libdeps\esp32doit-devkit-v1\MIDIUSB\src\MIDIUSB.cpp:101:11: error: 'struct ring_bufferMIDI' has no member named 'midiEvent'
   buffer->midiEvent[buffer->head] = event;
           ^
.pio\libdeps\esp32doit-devkit-v1\MIDIUSB\src\MIDIUSB.cpp: In member function 'uint32_t MIDI_::available()':   
.pio\libdeps\esp32doit-devkit-v1\MIDIUSB\src\MIDIUSB.cpp:112:20: error: 'MIDI_BUFFER_SIZE' was not declared in this scope
  return (uint32_t)(MIDI_BUFFER_SIZE + buffer->head - buffer->tail) % MIDI_BUFFER_SIZE;
                    ^
.pio\libdeps\esp32doit-devkit-v1\MIDIUSB\src\MIDIUSB.cpp: In member function 'midiEventPacket_t MIDI_::read()':
.pio\libdeps\esp32doit-devkit-v1\MIDIUSB\src\MIDIUSB.cpp:121:17: error: 'MIDI_BUFFER_SIZE' was not declared in this scope
  if(((uint32_t)(MIDI_BUFFER_SIZE + buffer->head - buffer->tail) % MIDI_BUFFER_SIZE) > 0) {
                 ^
.pio\libdeps\esp32doit-devkit-v1\MIDIUSB\src\MIDIUSB.cpp:122:18: error: 'struct ring_bufferMIDI' has no member named 'midiEvent'
      c = buffer->midiEvent[buffer->tail];
                  ^
.pio\libdeps\esp32doit-devkit-v1\MIDIUSB\src\MIDIUSB.cpp:22:27: error: 'pluggedEndpoint' was not declared in this scope
 #define MIDI_ENDPOINT_OUT pluggedEndpoint
                           ^
.pio\libdeps\esp32doit-devkit-v1\MIDIUSB\src\MIDIUSB.cpp:25:17: note: in expansion of macro 'MIDI_ENDPOINT_OUT'
 #define MIDI_RX MIDI_ENDPOINT_OUT
                 ^
.pio\libdeps\esp32doit-devkit-v1\MIDIUSB\src\MIDIUSB.cpp:124:31: note: in expansion of macro 'MIDI_RX'
             if (USB_Available(MIDI_RX)) {
                               ^
.pio\libdeps\esp32doit-devkit-v1\MIDIUSB\src\MIDIUSB.cpp:124:38: error: 'USB_Available' was not declared in this scope
             if (USB_Available(MIDI_RX)) {
                                      ^
.pio\libdeps\esp32doit-devkit-v1\MIDIUSB\src\MIDIUSB.cpp:126:22: error: 'struct ring_bufferMIDI' has no member named 'midiEvent'
          c = buffer->midiEvent[buffer->tail];
                      ^
.pio\libdeps\esp32doit-devkit-v1\MIDIUSB\src\MIDIUSB.cpp:137:49: error: 'MIDI_BUFFER_SIZE' was not declared in this scope
   buffer->tail = (uint32_t)(buffer->tail + 1) % MIDI_BUFFER_SIZE;
                                                 ^
.pio\libdeps\esp32doit-devkit-v1\MIDIUSB\src\MIDIUSB.cpp: In member function 'void MIDI_::flush()':
.pio\libdeps\esp32doit-devkit-v1\MIDIUSB\src\MIDIUSB.cpp:23:37: error: 'pluggedEndpoint' was not declared in this scope
 #define MIDI_ENDPOINT_IN ((uint8_t)(pluggedEndpoint+1))
                                     ^
.pio\libdeps\esp32doit-devkit-v1\MIDIUSB\src\MIDIUSB.cpp:26:17: note: in expansion of macro 'MIDI_ENDPOINT_IN'
 #define MIDI_TX MIDI_ENDPOINT_IN
                 ^
.pio\libdeps\esp32doit-devkit-v1\MIDIUSB\src\MIDIUSB.cpp:144:12: note: in expansion of macro 'MIDI_TX'
  USB_Flush(MIDI_TX);
            ^
.pio\libdeps\esp32doit-devkit-v1\MIDIUSB\src\MIDIUSB.cpp:144:19: error: 'USB_Flush' was not declared in this scope
  USB_Flush(MIDI_TX);
                   ^
.pio\libdeps\esp32doit-devkit-v1\MIDIUSB\src\MIDIUSB.cpp: In member function 'size_t MIDI_::write(const uint8_t*, size_t)':
.pio\libdeps\esp32doit-devkit-v1\MIDIUSB\src\MIDIUSB.cpp:23:37: error: 'pluggedEndpoint' was not declared in this scope
 #define MIDI_ENDPOINT_IN ((uint8_t)(pluggedEndpoint+1))
                                     ^
.pio\libdeps\esp32doit-devkit-v1\MIDIUSB\src\MIDIUSB.cpp:26:17: note: in expansion of macro 'MIDI_ENDPOINT_IN'
 #define MIDI_TX MIDI_ENDPOINT_IN
                 ^
.pio\libdeps\esp32doit-devkit-v1\MIDIUSB\src\MIDIUSB.cpp:164:23: note: in expansion of macro 'MIDI_TX'
  if (is_write_enabled(MIDI_TX))
                       ^
.pio\libdeps\esp32doit-devkit-v1\MIDIUSB\src\MIDIUSB.cpp:164:30: error: 'is_write_enabled' was not declared in this scope
  if (is_write_enabled(MIDI_TX))
                              ^
.pio\libdeps\esp32doit-devkit-v1\MIDIUSB\src\MIDIUSB.cpp:167:41: error: 'USB_Send' was not declared in this scope
   int r = USB_Send(MIDI_TX, buffer, size);
                                         ^
.pio\libdeps\esp32doit-devkit-v1\MIDIUSB\src\MIDIUSB.cpp: In constructor 'MIDI_::MIDI_()':
.pio\libdeps\esp32doit-devkit-v1\MIDIUSB\src\MIDIUSB.cpp:190:22: error: class 'MIDI_' does not have any field 
named 'PluggableUSBModule'
 MIDI_::MIDI_(void) : PluggableUSBModule(2, 2, epType)
                      ^
.pio\libdeps\esp32doit-devkit-v1\MIDIUSB\src\MIDIUSB.cpp:190:47: error: 'epType' was not declared in this scope
 MIDI_::MIDI_(void) : PluggableUSBModule(2, 2, epType)
                                               ^
.pio\libdeps\esp32doit-devkit-v1\MIDIUSB\src\MIDIUSB.cpp:192:14: error: 'EP_TYPE_BULK_OUT_MIDI' was not declared in this scope
  epType[0] = EP_TYPE_BULK_OUT_MIDI; // MIDI_ENDPOINT_OUT
              ^
.pio\libdeps\esp32doit-devkit-v1\MIDIUSB\src\MIDIUSB.cpp:193:14: error: 'EP_TYPE_BULK_IN_MIDI' was not declared in this scope
  epType[1] = EP_TYPE_BULK_IN_MIDI;  // MIDI_ENDPOINT_IN
              ^
.pio\libdeps\esp32doit-devkit-v1\MIDIUSB\src\MIDIUSB.cpp:194:15: error: 'PluggableUSB' was not declared in this scope
  PluggableUSB().plug(this);
               ^
*** [.pio\build\esp32doit-devkit-v1\lib813\MIDIUSB\MIDIUSB.cpp.o] Error 1
======================================== [FAILED] Took 44.53 seconds ========================================
tttapa commented 4 years ago

I'm not a PlatformIO user myself, but it looks like it's trying to build the MIDIUSB library, which shouldn't be necessary for ESP32. I'm not sure what causes this, it might be the dependencies specified in Control Surface's library.json file, or it might detect it on its own by scanning the header files used in the code using the pio LDF.

tttapa commented 4 years ago

Adding lib_ignore = MIDIUSB to your platformio.ini file should get around this issue for now.

I'll see if I can fix this more permanently in the library.json file of the library.

xabadabazinho commented 4 years ago

Works perfectly Thanks a lot.

tttapa commented 4 years ago

On an unrelated note: there have been huge improvements in the ESP32 Bluetooth MIDI backend, I've added SysEx support and replaced the Arduino BLE library with the native ESP-IDF Bluetooth API because the former had concurrency issues. The changes haven't made it into the master branch yet, but you can check them out on the new-input branch if you want.

emalihin commented 3 years ago

Suggestion to add lib_ignore = MIDIUSB worked well for Teensy 4.0 as well

JeffyOLOLO commented 1 year ago

Hi, it's still reproduced