Skip to content

Midi steps audible when sending a stream of CC messages for volume control #71

Open
@jhsa

Description

@jhsa

As the tittle say, when I send midi CC messages from my volume pedal via BLE it seems to introduce some steps. This does not happen if I connect the Volume pedal directly to the other device via Midi, instead of using the Midi BLE I have on breadboard.
Here is the code I am using. Do you see anything that could add delay to the midi? Or perhaps it comes from within a library?
Thanks.

#include <Arduino.h>
#include <MIDI.h>
#include <Adafruit_TinyUSB.h>
#include "BLEMIDI_Transport.h"
#include "BLEMIDI_Client_ESP32.h"

BLEMIDI_CREATE_DEFAULT_INSTANCE(); //Connect to first server found
MIDI_CREATE_INSTANCE(HardwareSerial, Serial,  MidiSerial);

// 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, MidiUsb);

byte Switch = 40;
int Led = 42; //modify for match with yout board
int MidiPwr = 41;
int timeout = 200;
bool isConnected = false;

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

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

  });

  pinMode(Led, OUTPUT);
  digitalWrite(Led, LOW);
pinMode(MidiPwr, OUTPUT);
  digitalWrite(MidiPwr, LOW);

   pinMode(Switch, INPUT_PULLUP);
  
  TinyUSBDevice.setManufacturerDescriptor("My_Manufacturer");
  TinyUSBDevice.setProductDescriptor("BLE_USB_Aapter");

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

  //  Serial.begin(115200);
  MIDI.begin(MIDI_CHANNEL_OMNI);
  MidiSerial.begin(MIDI_CHANNEL_OMNI);

  MidiSerial.turnThruOff();
  MIDI.turnThruOff();
  MidiUsb.turnThruOff();
delay(500);
  digitalWrite(MidiPwr, HIGH);
  }

  void loop()
  {
    if (MidiSerial.read()) {

      MIDI.send(MidiSerial.getType(),
                MidiSerial.getData1(),
                MidiSerial.getData2(),
                MidiSerial.getChannel());

      MidiUsb.send(MidiSerial.getType(),
                   MidiSerial.getData1(),
                   MidiSerial.getData2(),
                   MidiSerial.getChannel());
    }
    if (MIDI.read()) {


      MidiSerial.send(MIDI.getType(),
                      MIDI.getData1(),
                      MIDI.getData2(),
                      MIDI.getChannel());


      MidiUsb.send(MIDI.getType(),
                   MIDI.getData1(),
                   MIDI.getData2(),
                   MIDI.getChannel());
    }

    if (MidiUsb.read()) {
      MIDI.send(MidiUsb.getType(),
                MidiUsb.getData1(),
                MidiUsb.getData2(),
                MidiUsb.getChannel());


      MidiSerial.send(MidiUsb.getType(),
                      MidiUsb.getData1(),
                      MidiUsb.getData2(),
                      MidiUsb.getChannel());


    }
  }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions