GithubHelp home page GithubHelp logo

Comments (4)

lathoub avatar lathoub commented on August 25, 2024 2

Look at the creation MACRO:

MIDI_NAMESPACE::MidiInterface<BLEMIDI_NAMESPACE::BLEMIDI_Transport<BLEMIDI_NAMESPACE::BLEMIDI_ESP32_NimBLE>, BLEMIDI_NAMESPACE::MySettings> Name((BLEMIDI_NAMESPACE::BLEMIDI_Transport<BLEMIDI_NAMESPACE::BLEMIDI_ESP32_NimBLE> &)BLE##Name);

This prefixes the chosen name (BLUETOOTHMIDI) with BLE and becomes: BLEBLUETOOTHMIDI

Working sketch:

#include <BLEMIDI_Transport.h>

#include <hardware/BLEMIDI_ESP32_NimBLE.h>
//#include <hardware/BLEMIDI_ESP32.h>
//#include <hardware/BLEMIDI_nRF52.h>
//#include <hardware/BLEMIDI_ArduinoBLE.h>

//BLEMIDI_CREATE_DEFAULT_INSTANCE()
BLEMIDI_CREATE_INSTANCE("BLMIDIESP32", BLUETOOTHMIDI)

unsigned long t0 = millis();
bool BLMisConnected = true;  //set it to yes to see it running

// -----------------------------------------------------------------------------
// When BLE connected, LED will turn on (indication that connection was successful)
// When receiving a NoteOn, LED will go out, on NoteOff, light comes back on.
// This is an easy and conveniant way to show that the connection is alive and working. 
// -----------------------------------------------------------------------------
void setup()
{
  BLUETOOTHMIDI.begin();

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

  // uncommented by me
  BLEBLUETOOTHMIDI.setHandleConnected([]() {   
    BLMisConnected = true;
    digitalWrite(4, HIGH);
   });

  // uncommented by me
  // BLEMIDI.setHandleDisconnected([]() {
  //  BLMisConnected = false;
  //  digitalWrite(4, LOW);
  // });

  BLUETOOTHMIDI.setHandleNoteOn([](byte channel, byte note, byte velocity) {
    digitalWrite(4, LOW);
  });
  BLUETOOTHMIDI.setHandleNoteOff([](byte channel, byte note, byte velocity) {
    digitalWrite(4, HIGH);
  });
}

// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
void loop()
{
  BLUETOOTHMIDI.read();

  if (BLMisConnected && (millis() - t0) > 1000)
  {
    t0 = millis();

    BLUETOOTHMIDI.sendNoteOn (60, 100, 1); // note 60, velocity 100 on channel 1
  }
}

Good luck!

from arduino-ble-midi.

lathoub avatar lathoub commented on August 25, 2024

The #include <hardware/BLEMIDI_ESP32.h> indeed creates errors (ESP32 repo has recently changed, that may be the source of the error), but NimBLE works fine.

Change the code to:

#include <BLEMIDI_Transport.h>

#include <hardware/BLEMIDI_ESP32_NimBLE.h>
//#include <hardware/BLEMIDI_ESP32.h>
//#include <hardware/BLEMIDI_nRF52.h>
//#include <hardware/BLEMIDI_ArduinoBLE.h>

from arduino-ble-midi.

rigr avatar rigr commented on August 25, 2024

Thanks for your fast reply, I feel honored. :)

I'd like to use the "BLMisConnected" variable so uncommented this:


BLEMIDI.setHandleConnected([]() {  // 'class midi::MidiInterface<bleMidi::BLEMIDI_Transport<bleMidi::BLEMIDI_ESP32>, 
                                             //  bleMidi::MySettings>' has no member named 'setHandleConnected'
    BLMisConnected = true;
    digitalWrite(4, HIGH);
  });

It does not compile -
28:17: error: 'class midi::MidiInterface<bleMidi::BLEMIDI_TransportbleMidi::BLEMIDI_ESP32_NimBLE, bleMidi::MySettings>' has no member named 'setHandleConnected'
BLUETOOTHMIDI.setHandleConnected( { // 'class midi::MidiInterface<bleMidi::BLEMIDI_TransportbleMidi::BLEMIDI_ESP32,

and when renamed to BLEMIDI I get:
28:3: error: 'BLEMIDI' was not declared in this scope
BLEMIDI.setHandleConnected( { // 'class midi::MidiInterface<bleMidi::BLEMIDI_TransportbleMidi::BLEMIDI_ESP32,

:(
How can I achieve to use that variable?
Thanks!

from arduino-ble-midi.

rigr avatar rigr commented on August 25, 2024

Thank you very much. This worked perfectly!

from arduino-ble-midi.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.