Buonasera, scrivo sostanzialmente per chiedere una mano per la connessione midi del mio esp32s3, non riesco a trovare tutorial o documentazioni degne a riguardo, vorrei creare una semplice board con pulsanti e potenziometri che comunicano tramite midi, PLS HELP ME
Non so, non ho un ESP32 per fare prove, ma hai provato a vedere questa pagina se può essere di aiuto, e nel caso spiega meglio cosa intendi con "documentazioni degne" e cosa non ti risulta o non ti convince:
Con ESP32-S3 hai due possibilità:
- creare un device MIDI USB
- creare un device MIDI BLE.
Per quanto riguarda la prima opzione ci sono anche ben 4 esempi già inclusi nel core ESP32 per Arduino.
Per quanto riguarda il BLE invece, non mi pare ci siano esempi nel core, ma online si trovano diverse librerie e/o sketch di esempio e sostanzialmente il principio è lo stesso, cambia solo il mezzo di trasporto delle informazioni.
Si ci ho provato ma quando carico lo sketch di esempio e lo attacco al pc non viene visto come midi device dal pc...
me lo vede cosi, ma se apro midi ox o un software audio non me lo vede....(me lo fa con tutti e 4 i sketch di esempio).
Anche con il codice d'esempio midi test di Adafruit Tiny Usb
/*********************************************************************
Adafruit invests time and resources providing this open source code,
please support Adafruit and open-source hardware by purchasing
products from Adafruit!
MIT license, check LICENSE for more information
Copyright (c) 2019 Ha Thach for Adafruit Industries
All text above, and the splash screen below must be included in
any redistribution
*********************************************************************/
/* This sketch is enumerated as USB MIDI device.
* Following library is required
* - MIDI Library by Forty Seven Effects
* https://github.com/FortySevenEffects/arduino_midi_library
*/
#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() {
// Manual begin() is required on core without built-in support e.g. mbed rp2040
if (!TinyUSBDevice.isInitialized()) {
TinyUSBDevice.begin(0);
}
Serial.begin(115200);
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);
// If already enumerated, additional class driverr begin() e.g msc, hid, midi won't take effect until re-enumeration
if (TinyUSBDevice.mounted()) {
TinyUSBDevice.detach();
delay(10);
TinyUSBDevice.attach();
}
// 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);
}
void loop() {
#ifdef TINYUSB_NEED_POLLING_TASK
// Manual call tud_task since it isn't called by Core's background
TinyUSBDevice.task();
#endif
// not enumerated()/mounted() yet: nothing to do
if (!TinyUSBDevice.mounted()) {
return;
}
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);
}
il risultato non cambia, non viene visto come dispositivo midi ma come l'immagine sopra.
Non riesco a capire il motivo, qualche settaggio a monte da fare?
Hai ragione, ho provato anche io ed in effetti gli esempi inclusi nel core sembrano non funzionare come dovrebbero.
In compenso l'esempio incluso nel framework "ufficiale" ESP-IDF di Espressif funziona alla grande, quindi probabilmente il "porting" della libreria TinyUSB in ambiente Arduino ha ancora qualche bug.
Ho provato al volo a modificare l'esempio in questione per compilarlo in ambiente Arduino, ma purtroppo hanno cambiato tutte le API di tinyusb e la cosa non è cosi semplice come credevo.
Ho provato anche l'esempio suggerito da @docdoc che fa più o meno quello che avevo intenzione di fare, ma usando le API tinyusb "Arduino like", però il dispositivo che viene enumerato dal sistema operativo non viene riconosciuto correttamente a differenza di quello che succede invece usando direttamente esp-idf.
Probabilmente c'è qualcosa da sistemare nel descrittore USB.
Ad ogni modo se vuoi provare ad andare avanti partendo dall'esempio "ufficiale" (quindi no Arduino in sostanza) ti posso dare una mano volentieri.
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.
