max22- / ESP32-BLE-MIDI

An Arduino library to use Midi over BLE (Bluetooth Low Energy), on ESP32 boards
MIT License
228 stars 27 forks source link

Please how to send midi data from another board to esp32? #34

Open risyanto88 opened 1 week ago

risyanto88 commented 1 week ago

i am experimenting with midi controller with stm32 blue pill with examples from Here and i want to send it between stm32 serial to esp32? This is the project that I have changed to upload to stm32: `#include

// Deklarasi port serial multi-channel USBMultiSerial<2> ms;

USBMIDI midi;

const uint8_t notes[] = {60, 62, 64, 65, 67, 69, 71, 72, 61, 63, 66, 68, 70}; const int numNotes = sizeof(notes) / sizeof(*notes);

void setup() { // Inisialisasi USB Composite ms.begin(); while (!USBComposite); }

void loop() { for (int i = 0; i < numNotes; i++) { sendMIDIOverSerial(0x90, notes[i], 127); // Note On delay(200); sendMIDIOverSerial(0x80, notes[i], 127); // Note Off } }

void sendMIDIOverSerial(uint8_t statusByte, uint8_t data1, uint8_t data2) { ms.ports[0].write(statusByte); // Kirim status byte (Note On/Off) ms.ports[0].write(data1); // Kirim note (pitch) ms.ports[0].write(data2); // Kirim velocity }` and this is the script that I uploaded to the esp32 module:

include

include

include

HardwareSerial SerialMIDI(2); // UART2

void setup() { // Inisialisasi UART2 untuk MIDI dengan baud rate 31250 SerialMIDI.begin(31250, SERIAL_8N1, 16, 17); // RX2=GPIO16, TX2=GPIO17 Serial.begin(115200); Serial.println("Initializing bluetooth"); BLEMidiServer.begin("MIDI device"); Serial.println("Waiting for connections..."); //BLEMidiServer.enableDebugging(); // Uncomment if you want to see some debugging output from the library (not much for the server class...) }

void loop() { if(BLEMidiServer.isConnected()) { // If we've got a connection, we send an A4 during one second, at full velocity (127) BLEMidiServer.noteOn(0, 69, 127); delay(1000); BLEMidiServer.noteOff(0, 69, 127); // Then we make a delay of one second before returning to the beginning of the loop delay(1000); } if (SerialMIDI.available()) { int midiByte = SerialMIDI.read(); Serial.print("Received MIDI Byte: "); Serial.println(midiByte, HEX); } } ` I use fl studio mobile software for the bluetooth data receiver, and it can be read properly, but I am confused about how to send data from stm32 to esp32, because data from stm32 is never sent to fl studio, only midi note data from esp32 that is programmed can be received properly. what should I do, is there an error in the script that I wrote? if so, please help me fix it.

max22- commented 5 days ago

Why do you send data over usb on your stm32 ? how did you wire your circuit ?