BLE vs "Classic bluetooth" Sending MIDI messages to debuggers in windows

HelLo comunity.

This is my first post and even when i am a newbie on the platform, i have been able to learn a lot on the last days, since i got my esp32 board (TTGO t-display)

I wonder if there is a way to do a "deep debugging" using platformio or arduino IDE as i am facing a weird case.

i have edited some codes i got from internet. The first one is a very simple for sending somo midi notes when i press the one of the 2 buttons on the board (GPIO 0 or 35) i found one one web site that BUTTON1 (close to the reset button) has pullup resistor on pcb and the other ones does not. This last information is not very relevant now i believe.

So, for the first code, i am using the "classic version of bluetooth" meaning i am using the serial port created when connected to my PC, then, i use Hairless app to do the translation and sending the date to Loop MIDI and finally to my DAW. Code goes like this:

#include <Arduino.h>

const int nBotones = 2; //este es el número de botones
const int calibracion=130; //este valor funciona como una especie delay (es el numero de loops minimo de espera que debe haber entre cada repetición de nota)
boolean notaioff[nBotones];
int contador[nBotones];
//el array notas[] debe tener un mismo número de elementos
//que el número de botones, pues cada nota corresponde a un botón
byte notas[] = {22,23}; //estás son las notas que se dispararán los botones
byte botones[] = {0,35}; //aqui se ponen los GPIO de cada boton, el numero de elementos debe ser nBotones

bool hayip=false;

#include "BluetoothSerial.h"

#if !defined(CONFIG_BT_ENABLED) || !defined(CONFIG_BLUEDROID_ENABLED)
#error Bluetooth is not enabled! Please run `make menuconfig` to and enable it
#endif
BluetoothSerial SerialBT;

void setup() {


  Serial.begin(115200);
  SerialBT.begin("MIDI-blue"); //Bluetooth device name
  Serial.println("The device started, now you can pair it with bluetooth!");  
  
  for (int i=0;i<nBotones;i++)
  {
   pinMode(botones[i], INPUT_PULLUP);
  }
  analogReadResolution(10);
  
}

void midi(unsigned char command, unsigned char note,unsigned char vel)
{
    SerialBT.write(command);
    SerialBT.write(note);
    SerialBT.write(vel);
}


void loop() {
  

    
  
  for (int i=0; i<nBotones; i++) //la variable i recorre los números del 2 al 6
  {
      if (digitalRead(botones[i]) == LOW) //botón presionado
      {
        if (contador[i]==0)//cuenta regresiva terminada ?
        {
          if (notaioff[i]== 1) //¿la nota esta apagada?
          {
            contador[i]=calibracion; //valor de cuenta regresiva 
            midi(144,notas[i],100); //se envía la nota
            notaioff[i] = 0; //la nota no esta apagada (esta encendida)
          }
        }
        
      }
      else //botón sin presionar (posible envio de Note Off)
      {
        if (contador[i]==0) //cuenta regresiva terminada ?
        {
          if (notaioff[i] ==0) //¿La nota esta esta activada?
          {
            contador[i]=calibracion; //valor de cuenta regresiva 
            midi(144,notas[i],0); //envio de note off
            notaioff[i] = 1;  //la nota ya no está encendida
          }
        }
      }
  }

  
for (int i=0; i<nBotones;i++)
{
if (contador[i]>0) contador[i]--;
}


delay(1); //para estabilidad
}

What i really wanted to do is instead of producing notes, i want to be able to send MIDI CC messages in order to "move" between music tracks, something like next and previous buttons. I havent done this yet because i lack coding skills.

This is how it looks on the test code: test - YouTube

Now it comes the interesintg part. I found a library that is compatible with BLE on ESP32 boards, it has been mentioned on the forum before but is the control Surface lbrary available on : GitHub - tttapa/Control-Surface: Arduino library for creating MIDI controllers and other MIDI devices.

It is very easy to use and it has an example for the code i want to implement. The problem is, the new BLE profile is created succesfully, the connection between the board and the laptop works, MIDI berry recognize and can make the bridge between the BLE and the Loop midi app, but the buttons does not send any data. I have tried with many example codes, and i wonder if someone with an ESP32, would be so kind to try from their side or how to debug deeply the second case

The code i am currently using is for BLE is:

Thank you!

// Include the Control Surface library and the Bluetooth MIDI Interface
#include <Control_Surface.h>
//#include <MIDI_Interfaces/BluetoothMIDI_Interface.hpp>

// Instantiate a MIDI over BLE interface.
BluetoothMIDI_Interface midi;




// Instantiate a CCIncrementDecrementButtons object
CCIncrementDecrementButtons buttons {
  {35, 0},              // Button pins: 35 increments, 0 decrements
  MCU::V_POT_1,        // Increment/Decrement CC address
  1,                   // Multiplier
  MCU::V_POT_SELECT_1, // Reset note address
};

void setup() {
  // Use the Mackie Control protocol for sending relative MIDI CC messages.
  //RelativeCCSender::setMode(MACKIE_CONTROL_RELATIVE);

  Control_Surface.begin(); // Initialize Control Surface
}

void loop() {
  Control_Surface.loop(); // Update the control surface
}

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.