Skip to content

ESP32-S3 not appearing as a MIDI device #279

@algomusic

Description

@algomusic

Operating System

MacOS

Arduino IDE version

2.0.4

Board

ESP32-S3 dev board

ArduinoCore version

ESP32

TinyUSB Library version

2.0.3

Sketch as ATTACHED TXT

#include <Arduino.h>
#include <Adafruit_TinyUSB.h>
#include <MIDI.h>

// USB MIDI object
Adafruit_USBD_MIDI usb_midi;

// Create a new instance of the Arduino MIDI Library,
// and attach usb_midi as the transport.
MIDI_CREATE_INSTANCE(Adafruit_USBD_MIDI, usb_midi, MIDI);

// Variable that holds the current position in the sequence.
uint32_t position = 0;

// Store example melody as an array of note values
byte note_sequence[] = {
74,78,81,86,90,93,98,102,57,61,66,69,73,78,81,85,88,92,97,100,97,92,88,85,81,78,
74,69,66,62,57,62,66,69,74,78,81,86,90,93,97,102,97,93,90,85,81,78,73,68,64,61,
56,61,64,68,74,78,81,86,90,93,98,102
};

void setup()
{
#if defined(ARDUINO_ARCH_MBED) && defined(ARDUINO_ARCH_RP2040)
// Manual begin() is required on core without built-in support for TinyUSB such as mbed rp2040
TinyUSB_Device_Init(0);
#endif
pinMode(LED_BUILTIN, OUTPUT);

//usb_midi.setStringDescriptor("TinyUSB MIDI");

// Initialize MIDI, and listen to all MIDI channels
// This will also call usb_midi's begin()
MIDI.begin(MIDI_CHANNEL_OMNI);

// Attach the handleNoteOn function to the MIDI Library. It will
// be called whenever the Bluefruit receives MIDI Note On messages.
MIDI.setHandleNoteOn(handleNoteOn);

// Do the same for MIDI Note Off messages.
MIDI.setHandleNoteOff(handleNoteOff);

Serial.begin(115200);

// wait until device mounted
while( !TinyUSBDevice.mounted() ) delay(1);
}

void loop()
{
static uint32_t start_ms = 0;
if ( millis() - start_ms > 266 )
{
start_ms += 266;

// Setup variables for the current and previous
// positions in the note sequence.
int previous = position - 1;

// If we currently are at position 0, set the
// previous position to the last note in the sequence.
if (previous < 0) {
  previous = sizeof(note_sequence) - 1;
}

// Send Note On for current position at full velocity (127) on channel 1.
MIDI.sendNoteOn(note_sequence[position], 127, 1);

// Send Note Off for previous note.
MIDI.sendNoteOff(note_sequence[previous], 0, 1);

// Increment position
position++;

// If we are at the end of the sequence, start over.
if (position >= sizeof(note_sequence)) {
  position = 0;
}

}

// read any new MIDI messages
MIDI.read();
}

void handleNoteOn(byte channel, byte pitch, byte velocity)
{
// Log when a note is pressed.
Serial.print("Note on: channel = ");
Serial.print(channel);

Serial.print(" pitch = ");
Serial.print(pitch);

Serial.print(" velocity = ");
Serial.println(velocity);
}

void handleNoteOff(byte channel, byte pitch, byte velocity)
{
// Log when a note is released.
Serial.print("Note off: channel = ");
Serial.print(channel);

Serial.print(" pitch = ");
Serial.print(pitch);

Serial.print(" velocity = ");
Serial.println(velocity);
}

Compiled Log as ATTACHED TXT

Sketch uses 269553 bytes (20%) of program storage space. Maximum is 1310720 bytes.
Global variables use 21128 bytes (6%) of dynamic memory, leaving 306552 bytes for local variables. Maximum is 327680 bytes.
esptool.py v4.5.1
Serial port /dev/cu.wchusbserial56292538521
Connecting....
Chip is ESP32-S3 (revision v0.1)
Features: WiFi, BLE
Crystal is 40MHz

What happened ?

The code compiles and uploads, but the Microcontroller does not appear on my computer as a USB MIDI device. No data is able to be transmitted.

Similar code using a similar library at https://github.com/chegewara/EspTinyUSB does appear as a MIDI device but that library has other issues that MIDI message send and receive are not (yet) working.

How to reproduce ?

  1. Connect the ESP32-S3 dev board to the computer via the 'com' USB port and compile and upload the code.
  2. Shift the USB connection to the 'usb' USB port and reset the ESP32-S3. It should appear in the OS (and other apps) on the computer as a MIDI device, as it does with other boards such as the ESP32 and ESP32-S2 that I have tested.

Debug Log

N/A

Screenshots

N/A

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions