Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Esp32-S3 does not appear as Midi-USB #1108

Open
ashojon opened this issue Jan 5, 2025 · 6 comments
Open

Esp32-S3 does not appear as Midi-USB #1108

ashojon opened this issue Jan 5, 2025 · 6 comments

Comments

@ashojon
Copy link

ashojon commented Jan 5, 2025

Describe the bug
I have an ESP32-S3 board and am trying to build a USB and BLE MIDI controller using the Control Surface library. Both USB and BLE MIDI work perfectly in the Arduino IDE. However, when I use PlatformIO with Visual Studio Code, the USB MIDI does not appear in Windows MIDI monitor software.

That is what I used as setting in Arduino IDE

Set board to ESP32-S3 in Tools -> Board -> esp32 -> ESP32S3 Dev Module
Set USB mode to USB-OTG Tools -> USB Mode -> USB-OTG (TinyUSB)
Connect the dev board to the PC (UART USB port)
Select the according port in Tools -> Port

That is what I used as Setting in Platformio

[env:esp32s3usbotg]
platform = espressif32
board = esp32s3usbotg
framework = arduino
board_build.mcu = esp32s3
lib_deps = https://github.com/tttapa/Control-Surface.git#main
lib_ignore = MIDIUSB

Expected behavior
Esp32-S3 should recognized as MIDI-USB

Code

  • Please post the full code required to reproduce the problem.
  • If the code doesn't do what you expect, include a detailed description of what you expected the code it to do.
  • Don't post code that is too long. Try to narrow down the problem, try one component or aspect of your project at a time.
  • Don't post snippets, always post a complete (compilable) sketch.
  • Post your code between triple back ticks with the cpp language specifier, as shown below. This ensures that the code is displayed correctly and that syntax highlighting is enabled. (See the GitHub Markdown guide.)
#include <Arduino.h>
#include <Control_Surface.h>

USBMIDI_Interface midi;
BluetoothMIDI_Interface midi_ble;

void setup() {
    Serial.begin(460800);
    midi_ble.setName("MIDI_BLE_32");
   
  midi_ble.begin();
  midi.begin(); // Initialize the MIDI interface
}

void loop() {

    // Send a MIDI Note On message for the given note to trigger it
    midi.sendNoteOn(note, velocity);
  
    delay(500);
   
    // Send a MIDI Note Off message to turn it off again
    midi.sendNoteOff(note, velocity);
    delay(500);
    
    midi_ble.update();
    midi.update();
}
@ashojon ashojon changed the title Midi-USB Esp32-S3 does not appear as Midi-USB Jan 5, 2025
@tttapa
Copy link
Owner

tttapa commented Jan 13, 2025

I don't use PlatformIO myself, so I'm afraid I won't be able to provide detailed support.

Control Surface uses the built-in USB library from the ESP32 Arduino Core. Could you please test https://github.com/espressif/arduino-esp32/blob/master/libraries/USB/examples/MIDI/MidiController/MidiController.ino and report back? If that also doesn't work, it's probably a problem with PlatformIO rather than Control Surface.

@madskjeldgaard
Copy link

I get a similar problem with Raspberry Pi Pico in Platformio. Is it the same? The problem seems to be that MIDIUSB doesn't detect the architecture.

In file included from .pio/libdeps/raspberrypi-pico/MIDIUSB/src/MIDIUSB.cpp:17:
.pio/libdeps/raspberrypi-pico/MIDIUSB/src/MIDIUSB.h:18:2: error: #error MIDIUSB can only be used with an USB MCU.
   18 | #error MIDIUSB can only be used with an USB MCU.
      |  ^~~~~
.pio/libdeps/raspberrypi-pico/MIDIUSB/src/MIDIUSB.h:78:2: error: #error "Unsupported architecture"
   78 | #error "Unsupported architecture"
      |  ^~~~~
Compiling .pio/build/raspberrypi-pico/lib333/Control Surface/MIDI_Constants/MCUNameFromNoteNumber.cpp.o
.pio/libdeps/raspberrypi-pico/MIDIUSB/src/MIDIUSB.h:129:9: error: 'EndpointDescriptor' does not name a type
  129 |         EndpointDescriptor len;         // 9
      |         ^~~~~~~~~~~~~~~~~~
.pio/libdeps/raspberrypi-pico/MIDIUSB/src/MIDIUSB.h:158:9: error: 'IADDescriptor' does not name a type; did you mean 'MIDI_EPDescriptor'?
  158 |         IADDescriptor                      iad;
      |         ^~~~~~~~~~~~~
      |         MIDI_EPDescriptor
.pio/libdeps/raspberrypi-pico/MIDIUSB/src/MIDIUSB.h:160:9: error: 'InterfaceDescriptor' does not name a type; did you mean 'MIDI_ASInterfaceDes
criptor'?
  160 |         InterfaceDescriptor                Audio_ControlInterface;
      |         ^~~~~~~~~~~~~~~~~~~
      |         MIDI_ASInterfaceDescriptor
.pio/libdeps/raspberrypi-pico/MIDIUSB/src/MIDIUSB.h:164:9: error: 'InterfaceDescriptor' does not name a type; did you mean 'MIDI_ASInterfaceDes
criptor'?
  164 |         InterfaceDescriptor                Audio_StreamInterface;
      |         ^~~~~~~~~~~~~~~~~~~
      |         MIDI_ASInterfaceDescriptor
.pio/libdeps/raspberrypi-pico/MIDIUSB/src/MIDIUSB.h:217:9: error: 'EPTYPE_DESCRIPTOR_SIZE' does not name a type
  217 |         EPTYPE_DESCRIPTOR_SIZE epType[2];   ///< Container that defines the two bulk MIDI IN/OUT endpoints types
      |         ^~~~~~~~~~~~~~~~~~~~~~
.pio/libdeps/raspberrypi-pico/MIDIUSB/src/MIDIUSB.cpp:30:37: error: 'MIDI_BUFFER_SIZE' was not declared in this scope
   30 |         midiEventPacket_t midiEvent[MIDI_BUFFER_SIZE];
      |                                     ^~~~~~~~~~~~~~~~
.pio/libdeps/raspberrypi-pico/MIDIUSB/src/MIDIUSB.cpp:35:51: error: too many initializers for 'ring_bufferMIDI'
   35 | ring_bufferMIDI midi_rx_buffer = {{0,0,0,0 }, 0, 0};
      |                                                   ^
.pio/libdeps/raspberrypi-pico/MIDIUSB/src/MIDIUSB.cpp: In member function 'virtual int MIDI_::getInterface(uint8_t*)':
.pio/libdeps/raspberrypi-pico/MIDIUSB/src/MIDIUSB.cpp:44:17: error: 'D_IAD' was not declared in this scope
   44 |                 D_IAD(MIDI_AC_INTERFACE, 2, MIDI_AUDIO, MIDI_AUDIO_CONTROL, 0),
      |                 ^~~~~
.pio/libdeps/raspberrypi-pico/MIDIUSB/src/MIDIUSB.cpp:45:17: error: 'D_INTERFACE' was not declared in this scope; did you mean 'D_AC_INTERFACE'
?
   45 |                 D_INTERFACE(MIDI_AC_INTERFACE,0,MIDI_AUDIO,MIDI_AUDIO_CONTROL,0),
      |                 ^~~~~~~~~~~
      |                 D_AC_INTERFACE
.pio/libdeps/raspberrypi-pico/MIDIUSB/src/MIDIUSB.cpp:53:32: error: 'USB_ENDPOINT_OUT' was not declared in this scope; did you mean 'MIDI_ENDPO
INT_OUT'?
   53 |                 D_MIDI_JACK_EP(USB_ENDPOINT_OUT(MIDI_ENDPOINT_OUT),USB_ENDPOINT_TYPE_BULK,MIDI_BUFFER_SIZE),
      |                                ^~~~~~~~~~~~~~~~
.pio/libdeps/raspberrypi-pico/MIDIUSB/src/MIDIUSB.h:191:17: note: in definition of macro 'D_MIDI_JACK_EP'
  191 |         { 9, 5, _addr,_attr,_packetSize, 0, 0, 0}
      |                 ^~~~~
Compiling .pio/build/raspberrypi-pico/lib333/Control Surface/MIDI_Inputs/LEDs/NoteCCKPRangeFastLED.cpp.o
.pio/libdeps/raspberrypi-pico/MIDIUSB/src/MIDIUSB.cpp:53:68: error: 'USB_ENDPOINT_TYPE_BULK' was not declared in this scope
   53 |                 D_MIDI_JACK_EP(USB_ENDPOINT_OUT(MIDI_ENDPOINT_OUT),USB_ENDPOINT_TYPE_BULK,MIDI_BUFFER_SIZE),
      |                                                                    ^~~~~~~~~~~~~~~~~~~~~~
.pio/libdeps/raspberrypi-pico/MIDIUSB/src/MIDIUSB.h:191:23: note: in definition of macro 'D_MIDI_JACK_EP'
  191 |         { 9, 5, _addr,_attr,_packetSize, 0, 0, 0}
      |                       ^~~~~
.pio/libdeps/raspberrypi-pico/MIDIUSB/src/MIDIUSB.cpp:53:91: error: 'MIDI_BUFFER_SIZE' was not declared in this scope
   53 |                 D_MIDI_JACK_EP(USB_ENDPOINT_OUT(MIDI_ENDPOINT_OUT),USB_ENDPOINT_TYPE_BULK,MIDI_BUFFER_SIZE),
      |                                                                                           ^~~~~~~~~~~~~~~~
.pio/libdeps/raspberrypi-pico/MIDIUSB/src/MIDIUSB.h:191:29: note: in definition of macro 'D_MIDI_JACK_EP'
  191 |         { 9, 5, _addr,_attr,_packetSize, 0, 0, 0}
      |                             ^~~~~~~~~~~
.pio/libdeps/raspberrypi-pico/MIDIUSB/src/MIDIUSB.cpp:55:32: error: 'USB_ENDPOINT_IN' was not declared in this scope; did you mean 'MIDI_ENDPOI
NT_IN'?
   55 |                 D_MIDI_JACK_EP(USB_ENDPOINT_IN(MIDI_ENDPOINT_IN),USB_ENDPOINT_TYPE_BULK,MIDI_BUFFER_SIZE),
      |                                ^~~~~~~~~~~~~~~
.pio/libdeps/raspberrypi-pico/MIDIUSB/src/MIDIUSB.h:191:17: note: in definition of macro 'D_MIDI_JACK_EP'
  191 |         { 9, 5, _addr,_attr,_packetSize, 0, 0, 0}
      |                 ^~~~~
.pio/libdeps/raspberrypi-pico/MIDIUSB/src/MIDIUSB.cpp: In member function 'void MIDI_::accept()':
.pio/libdeps/raspberrypi-pico/MIDIUSB/src/MIDIUSB.cpp:81:51: error: 'MIDI_BUFFER_SIZE' was not declared in this scope
   81 |         uint32_t i = (uint32_t)(buffer->head+1) % MIDI_BUFFER_SIZE;
      |                                                   ^~~~~~~~~~~~~~~~
.pio/libdeps/raspberrypi-pico/MIDIUSB/src/MIDIUSB.cpp:101:25: error: 'struct ring_bufferMIDI' has no member named 'midiEvent'
  101 |                 buffer->midiEvent[buffer->head] = event;
      |                         ^~~~~~~~~
.pio/libdeps/raspberrypi-pico/MIDIUSB/src/MIDIUSB.cpp: In member function 'uint32_t MIDI_::available()':
.pio/libdeps/raspberrypi-pico/MIDIUSB/src/MIDIUSB.cpp:112:27: error: 'MIDI_BUFFER_SIZE' was not declared in this scope
  112 |         return (uint32_t)(MIDI_BUFFER_SIZE + buffer->head - buffer->tail) % MIDI_BUFFER_SIZE;
      |                           ^~~~~~~~~~~~~~~~
Compiling .pio/build/raspberrypi-pico/lib333/Control Surface/MIDI_Inputs/MCU/LCD.cpp.o
.pio/libdeps/raspberrypi-pico/MIDIUSB/src/MIDIUSB.cpp: In member function 'midiEventPacket_t MIDI_::read()':
.pio/libdeps/raspberrypi-pico/MIDIUSB/src/MIDIUSB.cpp:121:24: error: 'MIDI_BUFFER_SIZE' was not declared in this scope
  121 |         if(((uint32_t)(MIDI_BUFFER_SIZE + buffer->head - buffer->tail) % MIDI_BUFFER_SIZE) > 0) {
      |                        ^~~~~~~~~~~~~~~~
.pio/libdeps/raspberrypi-pico/MIDIUSB/src/MIDIUSB.cpp:122:25: error: 'struct ring_bufferMIDI' has no member named 'midiEvent'
  122 |             c = buffer->midiEvent[buffer->tail];
      |                         ^~~~~~~~~
.pio/libdeps/raspberrypi-pico/MIDIUSB/src/MIDIUSB.cpp:126:29: error: 'struct ring_bufferMIDI' has no member named 'midiEvent'
  126 |                 c = buffer->midiEvent[buffer->tail];
      |                             ^~~~~~~~~
.pio/libdeps/raspberrypi-pico/MIDIUSB/src/MIDIUSB.cpp:137:63: error: 'MIDI_BUFFER_SIZE' was not declared in this scope
  137 |                 buffer->tail = (uint32_t)(buffer->tail + 1) % MIDI_BUFFER_SIZE;
      |                                                               ^~~~~~~~~~~~~~~~
Compiling .pio/build/raspberrypi-pico/lib333/Control Surface/MIDI_Interfaces/BLEMIDI/BLEMIDIPacketBuilder.cpp.o
.pio/libdeps/raspberrypi-pico/MIDIUSB/src/MIDIUSB.cpp: In member function 'size_t MIDI_::write(const uint8_t*, size_t)':
.pio/libdeps/raspberrypi-pico/MIDIUSB/src/MIDIUSB.cpp:164:13: error: 'is_write_enabled' was not declared in this scope
  164 |         if (is_write_enabled(MIDI_TX))
      |             ^~~~~~~~~~~~~~~~
.pio/libdeps/raspberrypi-pico/MIDIUSB/src/MIDIUSB.cpp: In constructor 'MIDI_::MIDI_()':
.pio/libdeps/raspberrypi-pico/MIDIUSB/src/MIDIUSB.cpp:190:47: error: 'epType' was not declared in this scope
  190 | MIDI_::MIDI_(void) : PluggableUSBModule(2, 2, epType)
      |                                               ^~~~~~
Compiling .pio/build/raspberrypi-pico/lib333/Control Surface/MIDI_Interfaces/BLEMIDI/BTstack/advertising.cpp.o
.pio/libdeps/raspberrypi-pico/MIDIUSB/src/MIDIUSB.cpp:192:21: error: 'EP_TYPE_BULK_OUT_MIDI' was not declared in this scope
  192 |         epType[0] = EP_TYPE_BULK_OUT_MIDI;      // MIDI_ENDPOINT_OUT
      |                     ^~~~~~~~~~~~~~~~~~~~~
Compiling .pio/build/raspberrypi-pico/lib333/Control Surface/MIDI_Interfaces/BLEMIDI/BTstack/gatt_midi.cpp.o
Compiling .pio/build/raspberrypi-pico/lib333/Control Surface/MIDI_Interfaces/BLEMIDI/ESP32/advertising.c.o
Compiling .pio/build/raspberrypi-pico/lib333/Control Surface/MIDI_Interfaces/BLEMIDI/ESP32/app.cpp.o
.pio/libdeps/raspberrypi-pico/MIDIUSB/src/MIDIUSB.cpp:193:21: error: 'EP_TYPE_BULK_IN_MIDI' was not declared in this scope
  193 |         epType[1] = EP_TYPE_BULK_IN_MIDI;               // MIDI_ENDPOINT_IN
      |                     ^~~~~~~~~~~~~~~~~~~~
Compiling .pio/build/raspberrypi-pico/lib333/Control Surface/MIDI_Interfaces/BLEMIDI/ESP32/ble2902.c.o
Compiling .pio/build/raspberrypi-pico/lib333/Control Surface/MIDI_Interfaces/BLEMIDI/ESP32/esp_enums2string.c.o
*** [.pio/build/raspberrypi-pico/libfc1/MIDIUSB/MIDIUSB.cpp.o] Error 1
========================================================= [FAILED] Took 1.71 seconds =========================================================

@tttapa
Copy link
Owner

tttapa commented Jan 20, 2025

@madskjeldgaard that's a different problem. You need to ignore the MIDIUSB library on platforms that don't need it, otherwise, PlatformIO will try to compile it anyway, which of course won't work. See https://tttapa.github.io/Control-Surface/Doxygen/d8/da8/md_pages_Installation.html#platformio.

@madskjeldgaard
Copy link

Ah okay thanks !

@ashojon
Copy link
Author

ashojon commented Jan 21, 2025

I get the following message when I try your suggestion (https://github.com/espressif/arduino-esp32/blob/master/libraries/USB/examples/MIDI/MidiController/MidiController.ino)

#include "USBMIDI.h"
^~~~~~~~~~~
compilation terminated.
Compiling .pio\build\esp32s3usbotg\libb97\Control Surface\AH\Hardware\Button.cpp.o
*** [.pio\build\esp32s3usbotg\src\main.cpp.o] Error 1
.pio/libdeps/esp32s3usbotg/Control Surface/src/AH/Error/Exit.cpp:21:2: warning: #warning "LED_BUILTIN is not available, so it cannot
blink when an error occurs" [-Wcpp]
#warning "LED_BUILTIN is not available, so it cannot blink when an error occurs"

@tttapa
Copy link
Owner

tttapa commented Jan 24, 2025

@ashojon Which version of the arduino-esp32 core are you using? USB MIDI support was added in version 3.0.0: https://github.com/espressif/arduino-esp32/releases/tag/3.0.0-alpha3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants