bsandipk / QCCMEJack-Midi-Controller

0 stars 0 forks source link

ESP32 Midi BLE not sending program or control changes #1

Open bsandipk opened 1 year ago

bsandipk commented 1 year ago

Here is the code - I am able to connect to the CME WIDI jack via ESP32 BLE. The Widi Jack is able to receive program / control changes from other devices e.g. Mainstage in mac or midipad in ios. Here I am just trying to send control for tap tempo to the floor pedal. @RobertoHE

Ardiuno IDE 2.2.1 ESP32 WROOM DA Module

/**

//#include

include

include <hardware/BLEMIDI_ESP32_NimBLE.h>

BLEMIDI_CREATE_INSTANCE("QCWIDI",MIDI) //Connect to a specific name server called QCWIDI

ifndef LED_BUILTIN

define LED_BUILTIN 2 //modify for match with yout board

endif

void ReadCB(void *parameter); //Continuos Read function (See FreeRTOS multitasks)

unsigned long t0 = millis(); bool isConnected = false;

void setup() { Serial.begin(115200); MIDI.begin(1);

BLEMIDI.setHandleConnected([]() { Serial.println("---------CONNECTED---------"); isConnected = true; digitalWrite(LED_BUILTIN, HIGH); });

BLEMIDI.setHandleDisconnected([]() { Serial.println("---------NOT CONNECTED---------"); isConnected = false; digitalWrite(LED_BUILTIN, LOW); });

xTaskCreatePinnedToCore(ReadCB, //See FreeRTOS for more multitask info
"MIDI-READ", 3000, NULL, 1, NULL, 1); //Core0 or Core1

pinMode(LED_BUILTIN, OUTPUT);
digitalWrite(LED_BUILTIN, LOW);

}

void loop() { if (isConnected) // && (millis() - t0) > 1000) { MIDI.sendControlChange(44,127,1); // this is not sending any control change (tap temppo on my gear), I have tried program change too without success vTaskDelay(250/portTICK_PERIOD_MS); //MIDI.sendNoteOff(60, 0, 1); } }

void ReadCB(void *parameter) { // Serial.print("READ Task is started on core: "); // Serial.println(xPortGetCoreID()); for (;;) { MIDI.read(); vTaskDelay(1 / portTICK_PERIOD_MS); //Feed the watchdog of FreeRTOS. } vTaskDelay(1); }

RobertoHE commented 1 year ago

Hi @bsandipk Could you check if you are sending the midi comand to the correct channel to device (Ex.: Channel 16)? Could you send me a link of the manual?

Have you try to send other message type (ex.: NoteOn) for check if only fails with ProgramChanges?

RobertoHE commented 1 year ago

You can debug the comunication ussing a smart phone or pc like midi server.

For Android, Midi+BTLE apk allow you generate a midi server in your phone and see the received messages from esp32. Additionaly, you can see BLE raw communication ussing nRF CONNECT and nRF LOGGER apps.

You can do the same in pc win linking esp32 via BLE and use midiBerry for check messages.

bsandipk commented 1 year ago

The issues was with FreeRTOS - Midi.Read is too quick for the MIDI.sends. Tried increasing the buffer to 6000, no improvement. I used loop instead of RTOS and it works fine.